This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

1.4 Compiler - 1.3 JRE

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I write a program and compile it use the 1.4.1 compiler but I know that all the API's I used are the same as 1.3.x, is it safe to say that the application will run correctly on a 1.3.x JRE?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would venture to say probably not. Even though the API spec hasn't changed, perhaps some minor change in the way the two versions create the byte codes in the class file could cause it to not run correctly, if at all. However, if you use a 1.3.x compiler, it should run on both 1.3.x and 1.4.x JREs.
Disclaimer: This is my (only slightly) educated guess. Hopefully someone else will chip in if I am too far off base.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a 1.4 compiler to create .class files which execute on 1.3 with the -target option:
javac -target1.3 MyClass.java
If your code uses any features that are only available in 1.4, you'll get an appropriate error message when you compile.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if you don't use the -target option. Any documentation on the difference in bytecode from one version to the other without reading the VM specs for each version and figureing it out? Did anyone just say "Here is the difference"?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic