javac and jikes generate a synthetic constructor for the example given: 5: invokespecial #3=<Method Outer$Inner.<init> (Outer$1)void> gcj however attempts to access the constructor declared private, failing at runtime with an IllegalAccessError: 4: invokespecial #13=<Method Outer$Inner.<init> ()void> Also gcj doesn't generate the synthetic Outer$Inner constructor at all. Release: gcj (GCC) 3.4 20021230 (experimental) How-To-Repeat: $ cat Outer.java public class Outer { public Object getInner() { return new Inner(); } private static class Inner { private Inner() { } public String toString() { return "OK"; } } public static void main(String[] args) { Outer outer = new Outer(); System.out.println(outer.getInner()); } } $ gcj -C Outer.java $ gij Outer Exception in thread "main" java.lang.IllegalAccessError at _Jv_SearchMethodInClass(java.lang.Class, java.lang.Class, _Jv_Utf8Const, _Jv_Utf8Const) (/opt/gcc/lib/libgcj.so.4.0.0) at _Jv_ResolvePoolEntry(java.lang.Class, int) (/opt/gcc/lib/libgcj.so.4.0.0) at Outer.getInner() (Unknown Source) at Outer.main(java.lang.String[]) (Unknown Source)
State-Changed-From-To: open->analyzed State-Changed-Why: Still a bug
Note to get the error when running with Sun's java, you have to use -Xfuture.
*** Bug 19870 has been marked as a duplicate of this bug. ***
Hmm, even though GCJ -C produces the same bytecode for Outer as far as I can see, we now produce something which actually works with both gij and java (with -Xfuture).
This no longer fails due to a change that went in as part of the fix for PR 8618. In particular, we now emit the 'Inner' constructor as package-private, not private. This is kind of a slacker approach to implementing accessors. For constructors and static methods it probably has the desired effect without doing harm, though I haven't considered it in great detail. For ordinary methods it might be a problem due to overriding. This PR should only be marked as "fixed" if there is another PR for the case of accessors for methods and fields. Even then it isn't entirely clear if this is more hack or more fix.
All gcj front end bugs have been fixed by the gcj-eclipse branch merge. I'm mass-closing the affected PRs. If you believe one of these was closed in error, please reopen it with a note explaining why. Thanks.