Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6643627
Votes 0
Synopsis JMX source code includes incorrect Java code
Category jmx:classes
Reported Against
Release Fixed 6-open(b04), 7(b26) (Bug ID:2158066)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6400189
Submit Date 19-DEC-2007
Description
The JMX source code inadvertently trips over a javac bug (6400189) which leads the compiler to accept code that is not correct.  Specifically, in the class com.sun.jmx.mbeanserver.OpenConverter there is the following code:
           for (Constructor constr : annotatedConstrList) {
               String[] propertyNames =
                   constr.getAnnotation(propertyNamesClass).value();
               ...
The method Constructor.getAnnotation is declared like this:
    public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
This 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 in this case the compiler should consider that constr.getAnnotation(propertyNamesClass) is of type Annotation, and complain that Annotation does not have a value() method.

The fix is trivial: change Constructor to Constructor<?> in the declaration of constr.

A similar problem exists in the method java.beans.MetaData.getAnnotationValue(Constructor), where the parameter type should be changed to Constructor<?>.

This bug was reported by Roman Kennke of aicas GmbH.
Posted Date : 2007-12-19 09:28:19.0
Work Around
Users can of course make the change themselves before compiling the JDK.
Evaluation
This bug causes compilation of the JDK to fail with the Eclipse compiler.  The fix is trivial and should not have any effect on the generated byte code.
Posted Date : 2007-12-19 09:25:31.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang