Make the NotNull instrumenter work with stock asm
authorLubomir Rintel <lkundrak@v3.sk>
Wed, 10 Mar 2010 06:26:06 +0000 (10 07:26 +0100)
committerLubomir Rintel <lkundrak@v3.sk>
Wed, 10 Mar 2010 08:51:27 +0000 (10 09:51 +0100)
java/compiler/notNull/src/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenter.java

index ee4c4de..0839f63 100644 (file)
@@ -75,6 +75,7 @@ public class NotNullVerifyingInstrumenter extends ClassAdapter {
     return new MethodAdapter(v) {
 
       private final ArrayList myNotNullParams = new ArrayList();
+      private int synthetics = 0;
       private boolean myIsNotNull = false;
       public Label myThrowLabel;
       private Label myStartGeneratedCodeLabel;
@@ -87,10 +88,15 @@ public class NotNullVerifyingInstrumenter extends ClassAdapter {
         av = mv.visitParameterAnnotation(parameter,
                                          anno,
                                          visible);
-        if (isReferenceType(args[parameter]) &&
-            anno.equals("Lorg/jetbrains/annotations/NotNull;")) {
-          myNotNullParams.add(new Integer(parameter));
-        }
+        if (isReferenceType(args[parameter])) {
+          if (anno.equals("Lorg/jetbrains/annotations/NotNull;")) {
+            myNotNullParams.add(new Integer(parameter));
+         } else if (anno.equals("Ljava/lang/Synthetic;")) {
+           // See asm r1278 for what we do this,
+           // http://forge.objectweb.org/tracker/index.php?func=detail&aid=307392&group_id=23&atid=100023
+            synthetics++;
+         }
+       }
         return av;
       }
 
@@ -112,7 +118,7 @@ public class NotNullVerifyingInstrumenter extends ClassAdapter {
         }
         for (int p = 0; p < myNotNullParams.size(); ++p) {
           int var = ((access & Opcodes.ACC_STATIC) == 0) ? 1 : 0;
-          int param = ((Integer)myNotNullParams.get(p)).intValue();
+          int param = ((Integer)myNotNullParams.get(p)).intValue() - synthetics;
           for (int i = 0; i < param + startParameter; ++i) {
             var += args[i].getSize();
           }