src/share/classes/com/sun/tools/javac/jvm/Gen.java

Print this page

        

@@ -555,11 +555,10 @@
     private List<Attribute.TypeCompound> getAndRemoveNonFieldTAs(VarSymbol sym) {
         List<TypeCompound> tas = sym.getRawTypeAttributes();
         ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<>();
         ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<>();
         for (TypeCompound ta : tas) {
-            Assert.check(ta.getPosition().type != TargetType.UNKNOWN);
             if (ta.getPosition().type == TargetType.FIELD) {
                 fieldTAs.add(ta);
             } else {
                 nonfieldTAs.add(ta);
             }

@@ -1930,38 +1929,29 @@
         MethodSymbol meth = code.meth;
         boolean initOrClinit = code.meth.getKind() == javax.lang.model.element.ElementKind.CONSTRUCTOR
                 || code.meth.getKind() == javax.lang.model.element.ElementKind.STATIC_INIT;
 
         for (Attribute.TypeCompound ta : meth.getRawTypeAttributes()) {
-            if (ta.hasUnknownPosition())
-                ta.tryFixPosition();
-
-            if (ta.position.matchesPos(treePos))
+            if (ta.position != null && ta.position.matchesPos(treePos))
                 ta.position.updatePosOffset(code.cp);
         }
 
         if (!initOrClinit)
             return;
 
         for (Attribute.TypeCompound ta : meth.owner.getRawTypeAttributes()) {
-            if (ta.hasUnknownPosition())
-                ta.tryFixPosition();
-
-            if (ta.position.matchesPos(treePos))
+            if (ta.position != null && ta.position.matchesPos(treePos))
                 ta.position.updatePosOffset(code.cp);
         }
 
         ClassSymbol clazz = meth.enclClass();
         for (Symbol s : new com.sun.tools.javac.model.FilteredMemberList(clazz.members())) {
             if (!s.getKind().isField())
                 continue;
 
             for (Attribute.TypeCompound ta : s.getRawTypeAttributes()) {
-                if (ta.hasUnknownPosition())
-                    ta.tryFixPosition();
-
-                if (ta.position.matchesPos(treePos))
+                if (ta.position != null && ta.position.matchesPos(treePos))
                     ta.position.updatePosOffset(code.cp);
             }
         }
     }
 

@@ -2329,12 +2319,12 @@
     public void visitWildcard(JCWildcard tree) {
         throw new AssertionError(this.getClass().getName());
     }
 
     public void visitTypeTest(JCInstanceOf tree) {
-        setTypeAnnotationPositions(tree.pos);
         genExpr(tree.expr, tree.expr.type).load();
+        setTypeAnnotationPositions(tree.pos);
         code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
         result = items.makeStackItem(syms.booleanType);
     }
 
     public void visitIndexed(JCArrayAccess tree) {