# HG changeset patch # User jjg # Date 1264032746 28800 # Node ID 0eaf89e085648ba798c52f769244c39f09e90870 # Parent f23b985beb78254a3552dc0018be96a8f5a8f746 6918127: improve handling of TypeAnnotationPosition fields Reviewed-by: jjg, darcy Contributed-by: mali@csail.mit.edu, mernst@cs.washington.edu diff -r f23b985beb78 -r 0eaf89e08564 src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java --- a/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java Tue Jan 19 14:28:45 2010 -0800 +++ b/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java Wed Jan 20 16:12:26 2010 -0800 @@ -264,18 +264,18 @@ public int offset = -1; // For locals. - public int[] lvarOffset = new int[] { -1 }; - public int[] lvarLength = new int[] { -1 }; - public int[] lvarIndex = new int[] { -1 }; + public int[] lvarOffset = null; + public int[] lvarLength = null; + public int[] lvarIndex = null; // For type parameter bound - public int bound_index = -1; + public int bound_index = Integer.MIN_VALUE; // For type parameter and method parameter - public int parameter_index = -1; + public int parameter_index = Integer.MIN_VALUE; // For class extends, implements, and throws classes - public int type_index = -2; + public int type_index = Integer.MIN_VALUE; // For wildcards public Position wildcard_position = null; diff -r f23b985beb78 -r 0eaf89e08564 src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java --- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Tue Jan 19 14:28:45 2010 -0800 +++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Wed Jan 20 16:12:26 2010 -0800 @@ -49,18 +49,18 @@ public int offset = -1; // For locals. arrays same length - public int[] lvarOffset = new int[] { -1 }; - public int[] lvarLength = new int[] { -1 }; - public int[] lvarIndex = new int[] { -1 }; + public int[] lvarOffset = null; + public int[] lvarLength = null; + public int[] lvarIndex = null; // For type parameter bound - public int bound_index = -1; + public int bound_index = Integer.MIN_VALUE; // For type parameter and method parameter - public int parameter_index = -1; + public int parameter_index = Integer.MIN_VALUE; // For class extends, implements, and throws classes - public int type_index = -2; + public int type_index = Integer.MIN_VALUE; // For wildcards public TypeAnnotationPosition wildcard_position = null; diff -r f23b985beb78 -r 0eaf89e08564 src/share/classes/com/sun/tools/javac/jvm/Code.java --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Jan 19 14:28:45 2010 -0800 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Jan 20 16:12:26 2010 -0800 @@ -1926,9 +1926,9 @@ for (Attribute.TypeCompound ta : lv.sym.typeAnnotations) { TypeAnnotationPosition p = ta.position; while (p != null) { - p.lvarOffset[0] = (int)lv.start_pc; - p.lvarLength[0] = (int)lv.length; - p.lvarIndex[0] = (int)lv.reg; + p.lvarOffset = new int[] { (int)lv.start_pc }; + p.lvarLength = new int[] { (int)lv.length }; + p.lvarIndex = new int[] { (int)lv.reg }; p.isValidOffset = true; p = p.wildcard_position; } diff -r f23b985beb78 -r 0eaf89e08564 src/share/classes/com/sun/tools/javac/jvm/Gen.java --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Jan 19 14:28:45 2010 -0800 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jan 20 16:12:26 2010 -0800 @@ -1714,7 +1714,7 @@ for (Attribute.TypeCompound ta : meth.typeAnnotations) { if (ta.position.pos == treePos) { ta.position.offset = code.cp; - ta.position.lvarOffset[0] = code.cp; + ta.position.lvarOffset = new int[] { code.cp }; ta.position.isValidOffset = true; } } @@ -1726,7 +1726,7 @@ for (Attribute.TypeCompound ta : meth.owner.typeAnnotations) { if (ta.position.pos == treePos) { ta.position.offset = code.cp; - ta.position.lvarOffset[0] = code.cp; + ta.position.lvarOffset = new int[] { code.cp }; ta.position.isValidOffset = true; } } @@ -1738,7 +1738,7 @@ for (Attribute.TypeCompound ta : s.typeAnnotations) { if (ta.position.pos == treePos) { ta.position.offset = code.cp; - ta.position.lvarOffset[0] = code.cp; + ta.position.lvarOffset = new int[] { code.cp }; ta.position.isValidOffset = true; } }