File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Is Bytecode is under system programming language? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is Bytecode is under system programming language?" Watch "Is Bytecode is under system programming language?" New topic
Author

Is Bytecode is under system programming language?

Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 485
I read following link
-------------------
JVM.

JVM Specification.

ByteCode.

java Bytecode.

JVM_Languages.

Interpretor

Code generation compiler
--------------------------

I am getting more interest after reading this
as suggested in the IBM developerWorks journal, "Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ programmer."

After reading above page i want to ask,
The terms Mnemonic,opcode,etc use in java byte code, same as System programming. Then why not we can see what is java bytecode generated by our java program. Is there any tool for that.
Is we read source codeuse in the binary Java classes? I read this term in following links
------------------------
Byte Code Engineering Library

BCEL

ASM

java assist

------------
I really confuse reading so much about java byte code but cant read simple java program's (which calculate 1+1=2) java bytecode. If system programming can done by human then is this also possible?


Millions saw the apple fall, but Newton asked why.
If you understand, say "understand". If you don't understand, say "don't understand". But if you understand and say "don't understand". How do I understand that you understand? Understand!
denis sorn
Ranch Hand

Joined: Apr 30, 2008
Posts: 33
Hi. I don't know why we can't read bytecode from *.class files, but you should be able to find (google) some java byte code examples and tutorials. Have not checked links you provided maybe it's already there.

If it isn't I can tell you that java byte code is like asmbler for stack mashine, and you can find a lot of 2+2 examples.

EDIT:

Sorry, I have just noticed that I didn't understand you quite well. You have just asked why we can't read class files. Sorry. There were some java decompilers around, maybe one could use them to decompile a class file, but I am not sure if java byte code is what they produce.

Actually I already used decompiler once but if I remeber good I got only classes and methods names fromt it.
[ July 19, 2008: Message edited by: denis sorn ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Decompiling recreates the source code, so that's not very helpful in trying to find out how the JVM works. You can see the bytecode for a class by using the javap tool. Type "javap -c MyClass", and it will print it.

This article talks a bit more how to use javap, as does this one.

Note that while there are people who code in assembler, I think there are very few, if any, who code in bytecode.
[ July 19, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
Gulsum Ramazanoglu
Ranch Hand

Joined: Jun 27, 2008
Posts: 51
Mandar says ;


I really confuse reading so much about java byte code but cant read simple java program's (which calculate 1+1=2) java bytecode.


Mandar, you are so sweet..
You will
Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 485
As Ulf Dittmer gives us links, i get very good idea about how program turn into bytecode in easy language. Diagram helps to understand how values goes into heap memory.
Thanks sheriff.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
Where did you get the quote about bytecode and assembler from, Mandar Khire? Please quote a source.

It is absolutely true that knowing bytecode is as important for Java programming as assembler is for C programming. But what they don't tell you is that knowing assembler for C programming is as important as knowing the rules of the road is for fishing. That means: not at all.

You can program C without knowing any assembler and you can program Java without knowing any bytecode.
Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 485
respected Sir,
As you ask
Where did you get the quote about bytecode and assembler from, Mandar Khire?

I read it on wikipedia

So i ask the above question for improving knowledge. Am i mistaking?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
Originally posted by Mandar Khire:
Am i mistaking?
No, not at all.

But you would have done well to quote the whole paragraph from Wikipedia, which clearly says you don't need to know bytecode.

I haven't got the time to read the whole IBM article yet, but shall look at it later.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
Not sure about the Haggar article, which does make bytecode clear. But the article is 7 years old, so its conclusions might be out of date.
Particularly about the relation between length of bytecode and performance.
According to Brian Goetz (here) optimisation in Java is now done by the JIT (just-in-time) compiler in the JVM, and performance is variable from computer to computer. He says that writing simple code is the best way to get the JVM to optimise your code.

Although it is interesting to understand how bytecode works [it is very similar to assembler], and it is always useful to get additional knowledge, I still agree with what it said in Wikipedia that you don't have to know bytecode or assembler to program Java or C/C++.
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
I was thinking that, although interesting, its a bit pointless knowing what byte code will be produced, as the JVM will optimise the running code anyway, so gives little practical benifit.

I always believed knowing assemblier only ever became useful if you were having to optimise, for example knowing the shift operation would be quicker then a (power of 2?) division or multiplication. Thats sort of thing.

Just my thoughts
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Bytecode is under system programming language?
 
Similar Threads
byte code
JVM
Bytecode
Compiler v/s Interpreter
What happens after code is compiled ?