Thanks for bringing this to our attention, Alan. Roman is right - the code in question should not compile and we should change it as he suggests so that it is correct.

(For people interested in the gory details, the method
<T extends Annotation> T getAnnotation(Class<T> annotationClass)
returns T only if it is called on a properly generic variable, such as a Constructor<?> or Constructor<? extends Foo> or Constructor<E>. If it is called on a plain Constructor with no type parameter, then that is a "raw type", and the return type is "erased" to Annotation. So something like
ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class)
should not compile if constructor is declared as Constructor rather than Constructor<?> or whatever.)

Éamonn McManus   JMX Spec Lead   http://weblogs.java.net/blog/emcmanus/


Alan Bateman wrote:

I don't know if the JMX  team or the JavaBeans maintainers are on the core-libs-dev mailing list.




Subject:
Fix compiler problem
From:
Roman Kennke <[EMAIL PROTECTED]>
Date:
Tue, 18 Dec 2007 15:32:06 +0100
To:
Core-Libs-Dev <[EMAIL PROTECTED]>
To:
Core-Libs-Dev <[EMAIL PROTECTED]>

When trying to compile OpenJDK with the Eclipse compiler, I noticed two
compiler errors related to generics. It turned out that the code there
is invalid and only javac (incorrectly) accepts it. See the following
bug reports for details:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=212147
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6400189

The attached changeset fixes the problem. Could this be included?

/Roman

  

Reply via email to