Community
Participate
Working Groups
try compile and run the following code. javac 1.5_01 signals an error in code. eclipse 31M4 is happy to compile (with 1.4 scr/bin compliance) but on running the code surprisingly MyFoo$Bar is not generated ---------------------------------- package com.foo; public class OuterClass { public static void main(String[] args) { System.out.println(OuterClass.class); System.out.println(MyFoo.class); System.out.println(MyFoo$Bar.class); System.out.println(MyFoo.Bar.class); System.out.println(MyFoo$Bar.class==MyFoo.Bar.class); System.out.println(new MyFoo$Bar()); System.out.println(new MyFoo.Bar()); } static class MyFoo { static class Bar { public String toString() { return "MyFoo.Bar instance"; } } } static class MyFoo$Bar { public String toString() { return "MyFoo$Bar instance"; } } }
Reproduced in M6.
We do not check for this scenario, and should report duplicateNestedType(memberContext) Note that a variation of this scenario is the case where MyFoo$Bar is another toplevel type, and another one when defined in a different file.
The 2 cases where MyFoo$Bar is a secondary top-level type in the same file or in a different file are already detected as duplicates. Need to look into the best place to detect the member type duplicate.
Created attachment 65637 [details] Proposed patch
Now we do report a duplicate nested type as javac.
Released into HEAD for 3.3 RC1
Verified for 3.3RC1 using I20070515-0010