This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

The Java Performance Companion Question: Could bytecode be improved  RSS feed

 
Hinok Yohannes
Greenhorn
Posts: 15
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could Bytecode be improved?
 
Tim Moores
Saloon Keeper
Posts: 3881
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean bytecode in general, or for a specific application? Improved in which way?
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you expecting optimisation from the AOT compiler (=the javac tool, an Ahead Of Time compiler) as opposed to the JIT optimisation we have at present?
 
Bengt Rutisson
author
Greenhorn
Posts: 7
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Byte codes could be improved but, as mentioned in the other replies, the byte codes are not executed directly for most performance critical applications. Instead the JIT compiler steps in and transforms the byte code to highly efficient native code. Thus, improving the byte code does not necessarily lead to improved application performance.
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bengt Rutisson wrote:. . . Thus, improving the byte code does not necessarily lead to improved application performance.
Would it also make the bytecode impossible to execute on old JVMs? If so, goodbye backward compatibility.
 
Simon Roberts
Author
Ranch Hand
Posts: 176
9
Java Linux Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Would it also make the bytecode impossible to execute on old JVMs? If so, goodbye backward compatibility.


We don't have this anyway--for precisely this reason. Classfiles are versioned, and if you compile something on Java 8 and try to run it on Java 6, for example, it'll fail. Like this, which comes from hello world compiled with JDK 8 and executed on 7:

Exception in thread "main" java.lang.UnsupportedClassVersionError: X : Unsupported major.minor version 52.0

But you can still (largely) _compile_ to an older bytecode. Mostly, sometimes, if you don't use the wrong new language features, or libraries...
 
Hinok Yohannes
Greenhorn
Posts: 15
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hinok Yohannes wrote:Could Bytecode be improved?

Thank you so much for your replies I could only understand so much being a beginner and all.
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simon Roberts wrote:. . . Classfiles are versioned, and if you compile something on Java 8 and try to run it on Java 6, for example, it'll fail. . . .
Damn! I forgot all about that phenomenon.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!