Link Details

Link 3375 thumbnail
User 168451 avatar

By aalmiray
via madbean.com
Published: Sep 16 2006 / 05:08

You think that using JDK5 with -target 1.4 and -source 1.4 generates compatible code that runs on JVM 1.4 ? think again... =[
  • 14
  • 0
  • 729
  • 216

Comments

Add your comment
User 197767 avatar

csar replied ago:

0 votes Vote down Vote up Reply

This seems not to be so rare, I also ran into this: http://www.saager.org/2006/08/12/to-deprecate-or-to-be-deprecated.html (See there also how you can cause trouble using JDK6 to produce code that won't compile without any clean remedy),

User 107114 avatar

daniel replied ago:

0 votes Vote down Vote up Reply

So, this blog is basically saying that if you want to have backwards compatible code, don't use libraries that aren't backwards compatible? This seems like a pretty basic concept to me. :-)

Actually, his problem was probably caused by a string concatenation that the compiler tried to optimize. In my experience, all you have to do is use a little common sense and work a bit and your code should be perfectly backward compatible. (using the Sun compiler rather than ejc or something like that is helpful too)

User 202331 avatar

guymac replied ago:

0 votes Vote down Vote up Reply

Isn't this obvious? The -source and -target switches only check syntax / language features, not use of particular API methods / classes.

User 201716 avatar

unchqua replied ago:

0 votes Vote down Vote up Reply

@guymac
Then these options are evil catch. I wonder how JDK can compile 1.4-compatible code when I use, for example, generics in it? .class bytecode AFAIK contains JRE's minimal version number, inside which it can run. So compiler should obey these options fullier and not to allow to successfully build a project, in which I try to compile my (forced to) 1.4 code against any 1.5 libraby, be it genuine Sun package or third party one.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (14)



Voters Against This Link (0)