Skip to main content

Forget open source: Sun forked Java!

4 replies [Last post]
cajo
Offline
Joined: 2003-09-28
Points: 0

With the release of JRE 1.5, Sun changed the class file format, making it incompatible with earlier Virtual Machines.

Given the enormous current installed Java user base, this was nothing short of foolhardy. Fortunately, the 1.5 JRE can still run code in the original class file format.

I expect if Sun does not fix this by 1.6, there will be a schism; between the "compatible with all JREs" original-format developers, and the "compatible with new JREs" modified-format developers.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tackline
Offline
Joined: 2003-06-19
Points: 0

IIRC, all major versions of the JRE have introduced "incompatible" versions of the class file format. The only thing that's changed is a default switch on javac.

cajo
Offline
Joined: 2003-09-28
Points: 0

Changes yes, but never incompatible ones.

I spend a lot of time each day developing for a J2ME embedded Linux device. Its JRE is only 1.1.8, and I use a JDK 1.4.2 for development. I noticed the problem immediately when I [i]"upgraded"[/i] to JDK 1.5, and suddenly everything broke.

The -target switch will cause javac for 1.5 to generate 1.4 compatible class files, but that me think how foolish it would be to deploy a large user base application with these [i]new-fangled[/i] class files. It would require every user to upgrade his runtime.

Yet the old format works with everything.

tackline
Offline
Joined: 2003-06-19
Points: 0

I don't get your point.

In JDK 1.4.2 if you use assert then you need source and target as 1.4. The object code will then not run under JRE 1.3. It can be a useful thing to change the class file version number so early versions of the JRE will not even attempt to load classes that they cannot deal with.

Even with a lower -target set, if you use any new API then your code wont work on earlier JREs.

None of this is really surprising.

cajo
Offline
Joined: 2003-09-28
Points: 0

You are correct in that regard Tom. I have to write 1.1.8 compatible source code to run on a J2ME device. In essence, the lower the JDK you target, the broader the number of JREs you support.

My point is, that prior to 1.5, I could compile this source on [i]any[/i] version of the JDK, and it would work correctly with [i]any[/i] version of the JRE. The new 1.5 compiler by default generates class files that only run in a 1.5 runtime. So now there is a 1.1+ original class file format, [i]and[/i] a new 1.5+ format.

Of course you can use the javac -target switch, which forces the 1.5 compiler to produce original class file format. Unfortunately this situation forces developers to choose between a works with [u][i]everything[/i][/u] format (including 1.5+), and a works [u][i]only[/i][/u] with 1.5+ format. Most don't even know it yet.

Which one are you going to pick? I think it is pretty clear that I am staying with the original. I think many other developers will too; those who feel that few new language features are not worth the tremendous loss of compatibility, with an enormous installed user base.

The tragic part is this appears totally unnecessary. The 1.5 language features are possible with the original class file format. After all, the [url=http://retroweaver.sourceforge.net/overview.html]retroweaver[/url] guys seemed to have figured out how to do it.