Community
Participate
Working Groups
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729) Build Identifier: I20080617-2000 The synthesized constructor for an inner class's private constructor may match the signature of an explicit constructor causing a class load error at runtime due to a duplicate method signature. The Sun compiler correctly compiles the sample code by generating an extra anonymous class. Reproducible: Always Steps to Reproduce: 1. Compile sample code - no errors 2. Run - execution fails when inner class object is instantiated 3. If the single parameter constructor is changed to public, there is no error. Error Exception in thread "main" java.lang.ClassFormatError: Duplicate method name&signature in class file LList$Node at java.lang.ClassLoader.defineClass1(Native Method) ...
Created attachment 147264 [details] test case I think the synthesized constructor for the private Node(T e) is Node(T e, Node x) which matches the second constructor. javac produces 3 class files LList LList$1 LList$Node eclipse generates only 2 LList LList$Node (The sample program produces no output, except for the error trace)
The compiler doesn't detect the collision, because it compares a parameterized signature with a raw one. Within method SyntheticMethodBinding.initializeConstructorAccessor(MethodBinding) it is not OK to use areParametersEqual(MethodBinding), but erasures must be compared. Switching from areParametersEqual to areParameterErasuresEqual solves this problem.
Created attachment 147451 [details] Proposed patch and testcase Thanks Stephan
Released to HEAD for 3.6M3
Verified for 3.6M3 using build I20091025-2000