Community
Participate
Working Groups
In the following code, the printed modifier is "static" when compiled with javac while its empty when compiled with ajc package org.mywork.akka.monitor; import java.lang.reflect.Modifier; public class MyClass { public static interface TestInterface{ public void test(); } public static void main(String [] args){ TestInterface t = new TestInterface() { @Override public void test() { System.out.println("created..."); } }; int mods = t.getClass().getModifiers(); System.out.println("Modifiers are: " + Modifier.toString(mods)); } }
This looks like a javac bug. From the JLS, see the last clause here: http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.9.5 === An anonymous class declaration is automatically derived from a class instance creation expression by the Java compiler. An anonymous class is never abstract (§8.1.1.1). An anonymous class is always implicitly final (§8.1.1.2). An anonymous class is always an inner class (§8.1.3); it is never static (§8.1.1, §8.5.1). ===
Thanks Andrew! I have opened a defect for javac. Feel free to close this out.
tidying up, closing this.