views:

145

answers:

5

I'm working on a school project where I am required to use the GNU Compiler for Java. I've always worked using the official Sun JDK and now I'm concerned about differences that might complicate my work.

I'm specially interested in which version of Java is the one supported by the latest GCJ compiler

Could someone shed some light in the differences between one or the other?

PS: I searched on google but failed in finding a recent answer

+1  A: 

Since gcj is a compiler on top of GNU Classpath you need the differences between official JDK & GNU Classpath. For SUN JDK 1.4 see this for SUN JDK 1.5 see this one instead.

cartman
Great answer, thanks to the links. Highly informative!
Carl Smotricz
Note that those links only show the differences that can be detected by examining the respective bytecode signatures. The more tricky ones are the differences in behavior. Unfortunately, the Classpath team were never able to get hold of the Sun test kit, so they had to rely on test suites they wrote themselves.
Stephen C
A: 

Well from it's home page:

http://gcc.gnu.org/java/

Compiled applications are linked with the GCJ runtime, libgcj, which provides the core 
class libraries, a garbage collector, and a bytecode interpreter. libgcj can dynamically 
load and interpret class files, resulting in mixed compiled/interpreted applications. It 
has been merged with GNU Classpath and supports most of the 1.4 libraries plus some 1.5 
additions.
chollida
A: 

From the GCJ website. It looks like the GNU compiler is an ahead-of-time compiler and not a just-in-time compiler like Sun's. So there's one difference right there. The front page is a little vague and references that it does have some byte-code interpretation facilities built into the libgcj runtime.

I'd be wary of any library that covers MOST of the 1.4 and 1.5 libraries. If you target 1.4 your probably alright. 1.6 and you're probably in for a world of hurt.

Bear in mind if GCJ can only INTERPRET class files then it could be much slower running uncompiled code than Sun's JIT compiler.

Randaltor
Do you know if there is a way to find which parts of the MOST were actually implemented?
Kiranu
A: 

I have run into subtle differences in date parsing last time I looked.

AS the gnu JVM has not passed the Java TCK you must basically treat it as a new platform with full testing needed.

Thorbjørn Ravn Andersen
+1  A: 

If this answer should become the highest voted answer, it means that you should ask your prof to please reconsider why he's making you use such an unusual platform. In the real world, people use Sun JDKs predominantly. I don't see this changing much in the near future. It is a quality product, for the most part.

Can this really be helping you learn?

Kevin Bourrillion
I don't study in the US, I study in Venezuela. Here a professor's job is to make everything as hard as it can be. Asking him that is close to pointless
Kiranu
What do professors do in the U.S.?
Kevin Bourrillion