Community
Participate
Working Groups
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.
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 ?
*** This bug has been marked as a duplicate of 33843 ***
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.
Need to investigate a little more to determine if compliance level is enough to change behavior or simply the target level.
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.
Released changes to look at targetJDK instead of complianceLevel to trigger this behavior. Olivier - please double check, and tag as fixed if verified ok.
Actually, only tag as verified after verification.
Verified.