Bug 162356 - [compiler] Eclipse java compiler does not provide some attributes to local classes
Summary: [compiler] Eclipse java compiler does not provide some attributes to local cl...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-26 02:51 EDT by esemukhina CLA
Modified: 2006-10-30 02:22 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description esemukhina CLA 2006-10-26 02:51:09 EDT
Eclipse compiler does not provide info about enclosing class and enclosing method for local classes.
The following test being compiled with javac prints needed names while Eclipse compiler prints null:

import java.lang.reflect.*;

public class TestLocalClass {

	public void test() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

		class LocalClass {
			public void method() {
			}
		};

		LocalClass localClass = new LocalClass();
		Class cc = localClass.getClass();
		System.out.println("enclosing class = " + cc.getEnclosingClass());
		System.out.println("enclosing method = " + cc.getEnclosingMethod());

	}

	public static void main(String args[]) {

		TestLocalClass t = new TestLocalClass();
		try {
			t.test();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
Comment 1 Philipe Mulet CLA 2006-10-26 05:22:45 EDT
Olivier - are we missing some classfile attributes ?
Comment 2 Olivier Thomann CLA 2006-10-26 08:45:43 EDT
I get:
enclosing class = class TestLocalClass
enclosing method = public void TestLocalClass.test() throws java.lang.NoSuchMethodException,java.lang.IllegalAccessException,java.lang.reflect.InvocationTargetException

Using latest and 3.2.0 (v_671).
Are you compiling in 1.5 compliance ?
Comment 3 Olivier Thomann CLA 2006-10-26 17:43:14 EDT
Those attributes are only available in compliance 1.5.
Could you please provide your compiler settings?
Comment 4 Olivier Thomann CLA 2006-10-26 18:04:48 EDT
Added regression test in:
org.eclipse.jdt.core.tests.compiler.regression.EnclosingMethodAttributeTest#test003
Comment 5 Olivier Thomann CLA 2006-10-26 21:39:39 EDT
Closing as INVALID.
Please reopen if you are using compliance 1.5.
Comment 6 Alexey Varlamov CLA 2006-10-30 02:22:24 EST
Checked with 3.2.0: indeed the requested attributes are present if compiled with "-1.5" option.