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

getAnnotation() failure with array-valued elements

XMLWordPrintable

    • apt
    • b56
    • x86
    • windows_2000


      ###@###.### 2004-05-24

      J2SE Version (please include all output from java -version flag):
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b50)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b50, mixed mode, sharing)

      Does this problem occur on J2SE 1.4 or 1.4.1 or 1.4.2? Yes / No (pick one)
        N/A

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

      Hardware Configuration Information (be specific):
        N/A

      Bug Description:
        Problem encountered during annotation processing.

        The proxy returned from Declaration.getAnnotation() throws a
        ClassCastException when accessing a member/element whose type is an array.

      java.lang.ClassCastException: [Ljava.lang.Object;
              at $Proxy0.value(Unknown Source)
              at MyProcessor.process(MyProcessor.java:20)
              at com.sun.mirror.util.CompositeAnnotationProcessor.process(CompositeAnn
      otationProcessor.java:51)
              at com.sun.tools.apt.comp.Apt.main(Apt.java:370)
              at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:418)
              at com.sun.tools.apt.main.Main.compile(Main.java:939)
              at com.sun.tools.apt.main.Main.compile(Main.java:822)
              at com.sun.tools.apt.Main.compile(Main.java:41)
              at com.sun.tools.apt.Main.main(Main.java:32)

      Steps to Reproduce (be specific):
        - Unpack the attached jar.
        - recompile the *.java files with javac with tools.jar on the classpath
         (class files are included but you might want to recompile first)
        - run apt with the unpacked root on the classpath, and the source
          files as the source.

      ON Windows
       U:>javac -cp "C:\Program Files\Java\jdk1.5.0\lib\tools.jar" *.java

       U:>apt -cp .;"C:\Program Files\Java\jdk1.5.0\lib\tools.jar" *.java
      Note: @MyAnn found on MyAnnTarget
      error: java.lang.ClassCastException: [Ljava.lang.Object;
      java.lang.ClassCastException: [Ljava.lang.Object;
              at $Proxy0.value(Unknown Source)
              at MyProcessor.process(MyProcessor.java:20)
              at com.sun.mirror.util.CompositeAnnotationProcessor.process(CompositeAnn
      otationProcessor.java:51)
              at com.sun.tools.apt.comp.Apt.main(Apt.java:370)
              at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:418)
              at com.sun.tools.apt.main.Main.compile(Main.java:939)
              at com.sun.tools.apt.main.Main.compile(Main.java:822)
              at com.sun.tools.apt.Main.compile(Main.java:41)
              at com.sun.tools.apt.Main.main(Main.java:32)
      Note: @MyAnn found on MyAnnTarget2
      error: java.lang.ClassCastException: [Ljava.lang.Object;
      java.lang.ClassCastException: [Ljava.lang.Object;
              at $Proxy0.value(Unknown Source)
              at MyProcessor.process(MyProcessor.java:20)
              at com.sun.mirror.util.CompositeAnnotationProcessor.process(CompositeAnn
      otationProcessor.java:51)
              at com.sun.tools.apt.comp.Apt.main(Apt.java:370)
              at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:418)
              at com.sun.tools.apt.main.Main.compile(Main.java:939)
              at com.sun.tools.apt.main.Main.compile(Main.java:822)
              at com.sun.tools.apt.Main.compile(Main.java:41)
              at com.sun.tools.apt.Main.main(Main.java:32)
      2 errors


        The source files MyAnn, MyAnnTarget and MyProcessor can be easily modified
        to get the same fault when the element type is int[]. It also occurs for
        booleans.


            sseligmasunw Scott Seligman (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: