Summary: | Compiler incorrectly generating static method calls | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Jon Skeet <skeet> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | RESOLVED WONTFIX | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | dkel50, philippe_mulet |
Version: | 2.1 | ||
Target Milestone: | 2.1 RC2 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Jon Skeet
2003-03-05 10:37:52 EST
(Sorry, should have said: reported against RC1) Were you using the 1.3 or the 1.4 compliance setting? A static method invocation is still to be performed, however in between 1.3 and 1.4 a small nuance was made. The declaring type of the reference to #foo() in Main is 'Base' in 1.3, and 'Derived' in 1.4 (the declaring type is the receiver type from 1.4 on). This can actually make a difference when playing with binary compatibility, and adding a definition of #foo() on Derived without recompiling Main. Olivier - pls check javac behavior, I believe we have the same. JDK1.3.1 does indeed exhibit the 1.3 behaviour - but I would argue that that's just a bug in the 1.3.1 compiler, which shouldn't be emulated here. No doubt 1.3 had other bugs - do you wish to emulate all of them? There's a difference (IMO) between compliance to varying standards, and emulation of bugs in prior implementations of those standards. The 1.3 and 1.4 compliance mode follows exactly the same behavior than respectively javac 1.3.1 and javac 1.4.1. I am not sure we can actually change this behavior in our 1.3 compliance mode and still pass all JCK 1.3 tests. Philippe, what do you think? One note of potential interest: when you compile with javac -target 1.3 where javac is from JDK1.4.1, it doesn't revert to the 1.3 behaviour. If javac isn't going to emulate its previous bugs, why should Eclipse? ;) Javac from jdk1.4 is matching Eclipse Java compiler 1.4 compliant mode. Javac from jdk1.3 is matching Eclipse Java compiler 1.3 compliant mode. The target setting is irrelevant, it denotes the version tagged into classfiles (major/minor). The source setting level is also irrelevant, it enables/disables assertion. So toggling the compliance mode is the way to go to get the proper behavior. There are many more differences in our 1.3 and 1.4 compliant mode, most of them account for clarifications of the specs which occurred since 1.3 went out. One thing to keep in mind is that there isn't a global JCK, but rather a JCK1.3 and a JCK1.4 which makes some assumption on the respective compiler behaviors... Closing, working as designed. Toggling compliance level is the proper way to match expectation. *** Bug 34000 has been marked as a duplicate of this bug. *** One small nuance to this is that if target >= 1.2, then the receiver type is used (as opposed to declaring type), also see bug 34078. Related bug is rather bug 34000 |