Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6278240

Exception from AnnotationValue.getValue() should list the found type not the required type

    XMLWordPrintable

Details

    • b113
    • x86
    • windows_2000
    • Verified

    Description

      J2SE Version (please include all output from java -version flag):
        java version "1.5.0_03"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
        Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
        and
        java version "1.6.0-ea"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b38)
        Java HotSpot(TM) Client VM (build 1.6.0-ea-b38, mixed mode)


      Does this problem occur on J2SE 1.3.x or 1.4.x? Yes / No (pick one)
        N/A

      Operating System Configuration Information (be specific):
        Win 2K

      Bug Description:
        apt, Class<?> annotation value not matching required bounds,
        Declaration.getAnnotation() throws AnnotationTypeMismatchException
        which is not documented as thrown, and isn't strictly appropriate at
        this point (tho' its undoubtedly the most appropriate one in the java.lang
        packages)

        Further, this Exception's toString(), and foundType() methods indicate the
        wrong type found. They actually list the required type, not the found type.
        (this might be 2 separate bugs, throwing the undeclared exception, and having
        the wrong data inside it). The javac error does list the correct values for
        "found" and "required". Although its an unchecked exception, it is still good
        to declare it so users can anticipate this situation and dealt with it correctly
        rather than having apt do its "internal error in processor" song.

        (Also in 1.5.0_01 calling foundType() on the Exception threw a StackOverflowError
         but this is now fixed in 1.5.0_03)


      Steps to Reproduce (be specific):
         In same directory as attached source files

         javac -cp "%JAVA_HOME%\lib\tools.jar" SomeProcessor.java Programatic.java
         java -cp .;"%JAVA_HOME%\lib\tools.jar" Programatic

         see AnnotationTypeMismatchException stacktrace, and output of foundType()

         In the example Class<? extends Number> is the required type, the found
         type is Class<String>, but each lists the found type as Class<? extends Number>

         The javadoc does not mention this Exception being thrown here.











      ###@###.### 2005-05-31 16:04:46 GMT

      Attachments

        Issue Links

          Activity

            People

              jlahoda Jan Lahoda
              tyao Ting-Yun Ingrid Yao (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: