< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java

Print this page

        

*** 48,57 **** --- 48,58 ---- import static com.sun.tools.javac.jvm.ClassFile.CONSTANT_MethodType; import static com.sun.tools.javac.jvm.ClassFile.CONSTANT_Methodref; import static com.sun.tools.javac.jvm.ClassFile.CONSTANT_String; import static com.sun.tools.javac.jvm.UninitializedType.*; import static com.sun.tools.javac.jvm.ClassWriter.StackMapTableFrame; + import java.util.Arrays; /** An internal structure that corresponds to the code attribute of * methods in a classfile. The class also provides some utility operations to * generate bytecode instructions. *
*** 2073,2082 **** --- 2074,2084 ---- char length = (char)(curCP() - v.lastRange().start_pc); if (length < Character.MAX_VALUE) { lvar[adr] = v.dup(); v.closeRange(length); putVar(v); + fillLocalVarPosition(v); } else { v.removeLastRange(); } } }
*** 2104,2127 **** } private void fillLocalVarPosition(LocalVar lv) { if (lv == null || lv.sym == null || lv.sym.isExceptionParameter()|| !lv.sym.hasTypeAnnotations()) return; ! LocalVar.Range widestRange = lv.getWidestRange(); for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { TypeAnnotationPosition p = ta.position; ! if (widestRange.closed() && widestRange.length > 0) { ! p.lvarOffset = new int[] { (int)widestRange.start_pc }; ! p.lvarLength = new int[] { (int)widestRange.length }; ! p.lvarIndex = new int[] { (int)lv.reg }; ! p.isValidOffset = true; ! } else { ! p.isValidOffset = false; ! } } } // Method to be called after compressCatchTable to // fill in the exception table index for type // annotations on exception parameters. public void fillExceptionParameterPositions() { for (int i = 0; i < varBufferSize; ++i) { --- 2106,2140 ---- } private void fillLocalVarPosition(LocalVar lv) { if (lv == null || lv.sym == null || lv.sym.isExceptionParameter()|| !lv.sym.hasTypeAnnotations()) return; ! LocalVar.Range[] validRanges = lv.aliveRanges.stream().filter(r -> r.closed() && r.length > 0).toArray(s -> new LocalVar.Range[s]); ! if (validRanges.length == 0) ! return ; ! int[] lvarOffset = Arrays.stream(validRanges).mapToInt(r -> r.start_pc).toArray(); ! int[] lvarLength = Arrays.stream(validRanges).mapToInt(r -> r.length).toArray(); ! int[] lvarIndex = Arrays.stream(validRanges).mapToInt(r -> lv.reg).toArray(); for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { TypeAnnotationPosition p = ta.position; ! p.lvarOffset = appendArray(p.lvarOffset, lvarOffset); ! p.lvarLength = appendArray(p.lvarLength, lvarLength); ! p.lvarIndex = appendArray(p.lvarIndex, lvarIndex); ! p.isValidOffset = true; } } + private int[] appendArray(int[] source, int[] append) { + if (source == null || source.length == 0) return append; + + int[] result = new int[source.length + append.length]; + + System.arraycopy(source, 0, result, 0, source.length); + System.arraycopy(append, 0, result, source.length, append.length); + return result; + } + // Method to be called after compressCatchTable to // fill in the exception table index for type // annotations on exception parameters. public void fillExceptionParameterPositions() { for (int i = 0; i < varBufferSize; ++i) {
< prev index next >