changeset 3203:7e9c983565ac

Fix ClassReader reading local and resource variable type annotations.
author wmdietl
date Fri, 07 Feb 2014 19:23:17 -0500
parents 842ca57f65fb
children f50269f5606c
files src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
diffstat 1 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Feb 07 19:20:56 2014 -0500
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Feb 07 19:23:17 2014 -0500
@@ -1506,35 +1506,41 @@
         // local variable
         case LOCAL_VARIABLE: {
             final int table_length = nextChar();
-            final TypeAnnotationPosition position =
-                TypeAnnotationPosition.localVariable(readTypePath());
-
-            position.lvarOffset = new int[table_length];
-            position.lvarLength = new int[table_length];
-            position.lvarIndex = new int[table_length];
+            final int[] newLvarOffset = new int[table_length];
+            final int[] newLvarLength = new int[table_length];
+            final int[] newLvarIndex = new int[table_length];
 
             for (int i = 0; i < table_length; ++i) {
-                position.lvarOffset[i] = nextChar();
-                position.lvarLength[i] = nextChar();
-                position.lvarIndex[i] = nextChar();
+                newLvarOffset[i] = nextChar();
+                newLvarLength[i] = nextChar();
+                newLvarIndex[i] = nextChar();
             }
+
+            final TypeAnnotationPosition position =
+                    TypeAnnotationPosition.localVariable(readTypePath());
+            position.lvarOffset = newLvarOffset;
+            position.lvarLength = newLvarLength;
+            position.lvarIndex = newLvarIndex;
             return position;
         }
         // resource variable
         case RESOURCE_VARIABLE: {
             final int table_length = nextChar();
-            final TypeAnnotationPosition position =
-                TypeAnnotationPosition.resourceVariable(readTypePath());
-
-            position.lvarOffset = new int[table_length];
-            position.lvarLength = new int[table_length];
-            position.lvarIndex = new int[table_length];
+            final int[] newLvarOffset = new int[table_length];
+            final int[] newLvarLength = new int[table_length];
+            final int[] newLvarIndex = new int[table_length];
 
             for (int i = 0; i < table_length; ++i) {
-                position.lvarOffset[i] = nextChar();
-                position.lvarLength[i] = nextChar();
-                position.lvarIndex[i] = nextChar();
+                newLvarOffset[i] = nextChar();
+                newLvarLength[i] = nextChar();
+                newLvarIndex[i] = nextChar();
             }
+
+            final TypeAnnotationPosition position =
+                    TypeAnnotationPosition.resourceVariable(readTypePath());
+            position.lvarOffset = newLvarOffset;
+            position.lvarLength = newLvarLength;
+            position.lvarIndex = newLvarIndex;
             return position;
         }
         // exception parameter