Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.4
-
None
-
None
-
OS X (suspected all)
Description
The following code shows a static field on an interface not initialized at the point when the constructor of an instance of an implementing class is being run.
package ignored.alex.failingcallsite import java.lang.reflect.Field; class FailingCallSiteLocalClass { public static void main(String[] args) { new B() } } interface A { public static X x = new X() { public void foo() {} } } interface X { void foo() } class B implements A { public B() { for (Field f in getClass().getFields()) { println f println f.get(this) } } }
Throws java.lang.IllegalAccessError when x is accessed via f.get(this).
I would expect x to have been initialized by this point. Is there something subtle in when interfaces are initialized?
There is no problem if A is a class extended by B, and more curiously, no problem if x is set equal to a named outer class (e.g. a class X2 implements X).
Attachments
Issue Links
- links to