public class SameName { public Object foo () { class SingleName { public String toString () { return "foo.SingleName"; } } return new SingleName (); } public Object bar () { class SingleName { public String toString () { throw new RuntimeException ("bar.SingleName"); } } return new SingleName (); } public static void main (String[] args) { System.out.println (new SameName ().foo().toString()); } } cagney@localhost$ ./a.out Exception in thread "main" java.lang.RuntimeException: bar.SingleName at SameName$2$SingleName.toString() (Unknown Source) at SameName.main(java.lang.String[]) (Unknown Source) at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0) at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
This is very related to PR 12257 which is a crash for inner classes with the same name.
This will be fixed with ecj.