This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java/9369: wrong bytecode generated for static inner class with private constructor


>Number:         9369
>Category:       java
>Synopsis:       wrong bytecode generated for static inner class with private constructor
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 19 18:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     jsturm@one-point.com
>Release:        gcj (GCC) 3.4 20021230 (experimental)
>Organization:
>Environment:

>Description:
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.
>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)
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]