Bug 34000 - JDK Compliance doesn't match javac generation from an IBM or SUN JDK
Summary: JDK Compliance doesn't match javac generation from an IBM or SUN JDK
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.1 RC3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-06 13:01 EST by D Kelsey CLA
Modified: 2003-03-10 08:52 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description D Kelsey CLA 2003-03-06 13:01:44 EST
java 1.3 and 1.4 compilers from sun and IBM support the -target facility which 
allows you to target a particular JVM, it also changes the format of the class 
files generated. the eclipse compiler has the same facility but the class files 
generated do not match those generated by SUN or IBM compilers.

I have a class called BaseAPI which implements a method baseCall. I then have a 
class called TheAPI which extends BaseAPI and implements a method mainCall. I 
have a class called use which instantiates an object of type TheAPI and invokes 
baseCall and mainCall. 

Using a Sun or IBM compiler with a target of 1.1 JVM, the class file holds a 
reference to the BaseAPI class. When I target a 1.2, 1.3 or 1.4 JVM, this 
reference is no longer present.
Using the eclipse compiler on 2.01, 2.02 and 2.1rc1 specifying a target JVM of 
1.2 or 1.3, the reference to the BaseAPI class is still present. Only if I 
target a JVM of 1.4 this reference is removed. 

I cannot target a JVM of 1.4, but need to write an application that references 
an API which has 2 implementations without having to recompile my application 
against each of the APIs. There are 2 implementations of the API, one where 
some of the methods are in super classes and the other where all the methods 
are in a single class. Under Eclipse I can only get this to work if I target a 
1.4 JVM which ensures that the API I compiled against doesn't associate any 
super classes within the class file of my application and thus my compiled 
application will run against both implementations on the API. If I target a 1.2 
or 1.3 JVM then my application can only run if I compiled it against the API 
version which doesn't have super classes. 

If I use javac from a SUN or IBM JDK, then I can compile my application against 
the super class version of the API and specify a target of 1.2-1.4 and it will 
work against the non super class version of the API without recompilation.
Comment 1 Philipe Mulet CLA 2003-03-06 13:09:11 EST
This feels like the same problem as described in bug 33843.
Did you notice the compliance setting in the Java compiler preference page (on 
classfile tab).

It allows you to inform the compiler to mimic either jdk1.3 or jdk1.4 behavior 
(independantly from setting the target level). The behavior you expect is only 
available in 1.4 compliant mode (where you can toggle the target level to 1.1, 
and source level to 1.3).

Is it ok to close ?
Comment 2 Philipe Mulet CLA 2003-03-07 06:23:53 EST

*** This bug has been marked as a duplicate of 33843 ***
Comment 3 Philipe Mulet CLA 2003-03-07 07:06:34 EST
From reporter:
The description could match the problem, but I don't know for sure.
I do know that on IBM and Sun javac compilers (jdk 1.3 and 1.4), compiling 
with a target of 1.2 or higher resolves the problem we see. However bug 
33843 seems to not talk too much about the effects of target.
Comment 4 Philipe Mulet CLA 2003-03-07 07:07:15 EST
Need to investigate a little more to determine if compliance level is enough to 
change behavior or simply the target level.
Comment 5 Olivier Thomann CLA 2003-03-07 09:29:44 EST
Indeed -target has an side effect on the namelookup. To get this behavior in
Eclipse, you need to change the compliance level. I tried to look for more
documentation on this, but unsuccessfully. We know that -target changes the
version numbers (major and minor).
Would you have any pointer I could look at about the -target side-effects?

Thanks.
Comment 6 Philipe Mulet CLA 2003-03-07 13:19:27 EST
Released changes to look at targetJDK instead of complianceLevel to trigger 
this behavior. 

Olivier - please double check, and tag as fixed if verified ok.
Comment 7 Philipe Mulet CLA 2003-03-07 13:22:38 EST
Actually, only tag as verified after verification.
Comment 8 Olivier Thomann CLA 2003-03-10 08:52:02 EST
Verified.