Bug 162296 - [compiler] Anonymous and local classes are tagged as final and/or private in the inner class infos
Summary: [compiler] Anonymous and local classes are tagged as final and/or private in ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-25 15:46 EDT by Olivier Thomann CLA
Modified: 2008-07-09 14:28 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix (30.60 KB, patch)
2006-10-26 17:39 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression tests (5.14 KB, patch)
2006-10-26 17:42 EDT, Olivier Thomann CLA
no flags Details | Diff
Updated regression tests (6.11 KB, patch)
2006-10-26 18:10 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2006-10-25 15:46:05 EDT
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();
		}
	}
}
Comment 1 Tim Ellison CLA 2006-10-26 04:45:10 EDT
See also: Bug#162356.
Comment 2 Olivier Thomann CLA 2006-10-26 17:39:47 EDT
Created attachment 52795 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2006-10-26 17:42:05 EDT
Created attachment 52796 [details]
Regression tests
Comment 4 Olivier Thomann CLA 2006-10-26 18:10:43 EDT
Created attachment 52799 [details]
Updated regression tests

Regression test for bug 162356 needs to be updated (changes in the disassembled output).
Comment 5 Olivier Thomann CLA 2006-10-27 14:01:28 EDT
Released for 3.3M3.
Comment 6 Olivier Thomann CLA 2006-10-27 14:02:57 EDT
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.
Comment 7 Philipe Mulet CLA 2006-10-30 04:02:35 EST
+1 for 3.2.2. Our current behavior violates the spec.
Comment 8 David Audel CLA 2006-10-30 06:36:50 EST
Verified for 3.3 M3 using build I20061030-0010
Comment 9 Olivier Thomann CLA 2006-11-08 20:30:46 EST
Released for 3.2.2.
Comment 10 Frederic Fusier CLA 2007-01-15 04:07:13 EST
Reopen for verification
Comment 11 Frederic Fusier CLA 2007-01-15 04:10:59 EST
(In reply to comment #9)
> Released for 3.2.2.
> 

Comment 12 Maxime Daniel CLA 2007-01-16 05:18:05 EST
Checked the generated code for EnclosingMethodAttributeTest#test002.
Verified for 3.2.2 using build M20070112-1200.
Comment 13 Olivier Thomann CLA 2007-01-26 10:48:00 EST
Tim,

Please have a look at bug 171749.
Comment 14 Olivier Thomann CLA 2008-07-09 14:28:35 EDT
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.