Community
Participate
Working Groups
We might want to double-check this. javac is using the package default visibility in this case. Test case: Using 1.5 libraries, compile the following code: import java.lang.reflect.*; public class X { interface I {} public void test() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { class LocalClass { public void qq() { } }; LocalClass action = new LocalClass(); action.qq(); action.getClass().getMethod("qq", (Class[])null).invoke(action, (Object[])null); Class cc = action.getClass(); System.out.println("TEST: enclosing class = " + cc.getEnclosingClass()); System.out.println("TEST: declaring class = " + cc.getDeclaringClass()); System.out.println("TEST: is local class = " + cc.isLocalClass()); } public abstract class MyClass { } public void test2() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { MyClass action = new MyClass() { public String qq() { return "qq"; } }; action.getClass().getMethod("qq", null).invoke(action, null); } public static void main(String args[]) { X t = new X(); try { t.test(); t.test2(); } catch (Exception e) { e.printStackTrace(); } } }
See also: Bug#162356.
Created attachment 52795 [details] Proposed fix
Created attachment 52796 [details] Regression tests
Created attachment 52799 [details] Updated regression tests Regression test for bug 162356 needs to be updated (changes in the disassembled output).
Released for 3.3M3.
If we fix in 3.2.2, I would not backport the changes in the disassembler. Just the one in ClassFile and the patch for HEAD is applicable for 3.2 maintenance.
+1 for 3.2.2. Our current behavior violates the spec.
Verified for 3.3 M3 using build I20061030-0010
Released for 3.2.2.
Reopen for verification
(In reply to comment #9) > Released for 3.2.2. >
Checked the generated code for EnclosingMethodAttributeTest#test002. Verified for 3.2.2 using build M20070112-1200.
Tim, Please have a look at bug 171749.
I think we should also remove the final bit from the access flag of the class file. We removed it from the inner info entry, but not from the class file access flag. See bug 240214.