Bug 223490 - [compiler] Eclipse miscompiles uses of java.beans.ContructorProperties in the Sun JDK 6 src.zip
Summary: [compiler] Eclipse miscompiles uses of java.beans.ContructorProperties in the...
Status: RESOLVED DUPLICATE of bug 167952
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-21 08:44 EDT by Markus Milleder CLA
Modified: 2008-03-21 11:53 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***