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

JSR 269 annotation processing breaks with assertion, in Types.isAssignable() method.

      The case its trying to access 'isAssignable' and fails with Assertion, I was expecting a false return value.
       Comparing ()void with ()void
        ()void Assignable ()void
       Comparing ()void with (java.lang.String)void


      An annotation processor threw an uncaught exception.
      Consult the following stack trace for details.
      java.lang.AssertionError: isSubType 12
              at com.sun.tools.javac.code.Types$5.visitType(Types.java:345)
              at com.sun.tools.javac.code.Types$5.visitType(Types.java:430)
              at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visitMethodType(Types.java:2871)
              at com.sun.tools.javac.code.Type$MethodType.accept(Type.java:783)
              at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:2867)
              at com.sun.tools.javac.code.Types.isSubType(Types.java:307)
              at com.sun.tools.javac.code.Types.isSubTypeUnchecked(Types.java:285)
              at com.sun.tools.javac.code.Types.isConvertible(Types.java:254)
              at com.sun.tools.javac.code.Types.isAssignable(Types.java:1398)
              at com.sun.tools.javac.code.Types.isAssignable(Types.java:1359)
              at com.sun.tools.javac.model.JavacTypes.isAssignable(JavacTypes.java:77)
              at CaseAP.process(CaseAP.java:29)
              at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:497)
              at com.sun.tools.javac.processing.JavacProcessingEnvironment.discovery(JavacProcessingEnvironment.java:421)
              at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:569)
              at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:843)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:629)
              at com.sun.tools.javac.main.Main.compile(Main.java:756)
              at com.sun.tools.javac.main.Main.compile(Main.java:681)
              at com.sun.tools.javac.main.Main.compile(Main.java:670)
              at com.sun.tools.javac.Main.compile(Main.java:70)
              at com.sun.tools.javac.Main.main(Main.java:55)
      java version "1.6.0-auto"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-292b)
      Java HotSpot(TM) Server VM (build 1.6.0-ea-b56, mixed mode)

      Annotation processor and input java file for are used.
      $JAVA_HOME/bin/javac -classpath $CLASSPATH -processor CaseAP Case1.java
      bash-3.00$ cat Case1.java
      public class Case1 {
          public void doMethod2_1(String message){
              System.out.println(" message "+message);
          }
      }
      bash-3.00$ cat CaseAP.java
      import java.util.*;
      import javax.annotation.processing.*;
      import javax.lang.model.element.*;
      import javax.lang.model.type.*;
      import javax.lang.model.util.*;
      import static javax.lang.model.SourceVersion.*;
      import static javax.lang.model.type.TypeKind.*;

      @SupportedAnnotationTypes("*")
      @SupportedSourceVersion(RELEASE_6)
      @SupportedOptions("-verbose")
      public class CaseAP extends AbstractProcessor {
          public void init(ProcessingEnvironment penv) {
              super.init(penv);
          }
          public boolean process(Set<? extends TypeElement> typeElementSet,
                  RoundEnvironment renv) {
              Vector<TypeMirror> listArrayElementList = new Vector<TypeMirror>();
              for( TypeElement element : renv.getSpecifiedTypeElements()) {
                  List<? extends Element > list = element.getEnclosedElements();
                  for( Element e : list) {
                      listArrayElementList.add(e.asType());
                  }
                  listArrayElementList.add(element.asType());
              }
              for(TypeMirror mirror : listArrayElementList) {
                  for (TypeMirror mirror_ : listArrayElementList) {
                      System.out.println(" Comparing "+mirror.toString() +" with "+mirror_.toString());
                      if ( processingEnv.getTypeUtils().isAssignable(mirror_, mirror) ) {
                          System.out.println(" "+mirror.toString()+
                                  " Assignable "+mirror_.toString() );
                      } else {
                          System.out.println(" "+mirror.toString()+
                                  " not Assignable "+mirror_.toString() );
                      }
                  }
              }
              return true ;
          }
      }
      bash-3.00$


      Please do see attached files with this CR.

            sseligmasunw Scott Seligman (Inactive)
            vvegurusunw Viswadeep Veguru (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: