Bug 223490

Summary: [compiler] Eclipse miscompiles uses of java.beans.ContructorProperties in the Sun JDK 6 src.zip
Product: [Eclipse Project] JDT Reporter: Markus Milleder <Markus.Milleder>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: philippe_mulet
Version: 3.4   
Target Milestone: 3.4 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Markus Milleder CLA 2008-03-21 08:44:15 EDT
To see the bug:
Create a new Java project
Import the Sun JDK 6 src.zip into the source folder
wait :-)

Tried with 3.4M5, compiler compliance level 1.6
This doesn't work in 3.3.2 either.

The errors:
In java.beans.MetaData#isValid:
Type mismatch: cannot convert from Annotation to ContructorProperties
calling java.lang.reflect.Constructor.getAnnotation(ContructorProperties.class)

In com.sun.jnx.mbeanserver.OpenConverter
The method value() is undefined for type Annotation, also calling Constructor.getAnnotation

It seems that the compiler does not fully realize that ConstructorProperties is derived from Annotation.

A simple test case does not show this problem:
// -------
package anno;

public @interface Anno {
	public String getName();
}
// -------
package bug;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;

import anno.Anno;

public class Test {
	Map<Class, Annotation> annoMap = new HashMap<Class, Annotation>();

	public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
        return (T) annoMap.get(annotationClass);
    }

	public static void main(String[] args) {
		Test test = new Test();
		test.getAnnotation(Anno.class).getName();
	}
}
Comment 1 Philipe Mulet CLA 2008-03-21 11:53:10 EDT
This is not our bug. Some bogus code is released in 1.6 source libs, due to a bug in javac.

Also see bug 167952

*** This bug has been marked as a duplicate of bug 167952 ***