### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java,v retrieving revision 1.164 diff -u -r1.164 CodeStream.java --- compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java 7 Jul 2008 17:08:07 -0000 1.164 +++ compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java 16 Sep 2008 13:07:37 -0000 @@ -27,7 +27,6 @@ import org.eclipse.jdt.internal.compiler.util.Util; public class CodeStream { - public static final boolean DEBUG = false; // It will be responsible for the following items. // -> Tracking Max Stack. @@ -41,89 +40,7 @@ static LocalVariableBinding[] noLocals = new LocalVariableBinding[LOCALS_INCREMENT]; static LocalVariableBinding[] noVisibleLocals = new LocalVariableBinding[LOCALS_INCREMENT]; public static final CompilationResult RESTART_IN_WIDE_MODE = new CompilationResult((char[])null, 0, 0, 0); - /** - * This methods searches for an existing entry inside the pcToSourceMap table with a pc equals to @pc. - * If there is an existing entry it returns -1 (no insertion required). - * Otherwise it returns the index where the entry for the pc has to be inserted. - * This is based on the fact that the pcToSourceMap table is sorted according to the pc. - * - * @param pcToSourceMap the given pcToSourceMap array - * @param length the given length - * @param pc the given pc - * @return int - */ - public static int insertionIndex(int[] pcToSourceMap, int length, int pc) { - int g = 0; - int d = length - 2; - int m = 0; - while (g <= d) { - m = (g + d) / 2; - // we search only on even indexes - if ((m & 1) != 0) // faster than ((m % 2) != 0) - m--; - int currentPC = pcToSourceMap[m]; - if (pc < currentPC) { - d = m - 2; - } else - if (pc > currentPC) { - g = m + 2; - } else { - return -1; - } - } - if (pc < pcToSourceMap[m]) - return m; - return m + 2; - } - public static final void sort(int[] tab, int lo0, int hi0, int[] result) { - int lo = lo0; - int hi = hi0; - int mid; - if (hi0 > lo0) { - /* Arbitrarily establishing partition element as the midpoint of - * the array. - */ - mid = tab[lo0 + (hi0 - lo0) / 2]; - // loop through the array until indices cross - while (lo <= hi) { - /* find the first element that is greater than or equal to - * the partition element starting from the left Index. - */ - while ((lo < hi0) && (tab[lo] < mid)) - ++lo; - /* find an element that is smaller than or equal to - * the partition element starting from the right Index. - */ - while ((hi > lo0) && (tab[hi] > mid)) - --hi; - // if the indexes have not crossed, swap - if (lo <= hi) { - swap(tab, lo, hi, result); - ++lo; - --hi; - } - } - /* If the right index has not reached the left side of array - * must now sort the left partition. - */ - if (lo0 < hi) - sort(tab, lo0, hi, result); - /* If the left index has not reached the right side of array - * must now sort the right partition. - */ - if (lo < hi0) - sort(tab, lo, hi0, result); - } - } - private static final void swap(int a[], int i, int j, int result[]) { - int T; - T = a[i]; - a[i] = a[j]; - a[j] = T; - T = result[j]; - result[j] = result[i]; - result[i] = T; - } + public int allLocalsCounter; public byte[] bCodeStream; public ClassFile classFile; // The current classfile it is associated to. @@ -139,31 +56,35 @@ public BranchLabel[] labels = new BranchLabel[LABELS_INCREMENT]; public int lastEntryPC; // last entry recorded public int lastAbruptCompletion; // position of last instruction which abrupts completion: goto/return/athrow + public int[] lineSeparatorPositions; // line number of the body start and the body end public int lineNumberStart; - public int lineNumberEnd; + public int lineNumberEnd; public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT]; public int maxFieldCount; - public int maxLocals; public AbstractMethodDeclaration methodDeclaration; public int[] pcToSourceMap = new int[24]; public int pcToSourceMapSize; public int position; // So when first set can be incremented public boolean preserveUnusedLocals; + public int stackDepth; // Use Ints to keep from using extra bc when adding + public int stackMax; // Use Ints to keep from using extra bc when adding public int startingClassFileOffset; // I need to keep the starting point inside the byte array - // target level to manage different code generation between different target levels protected long targetLevel; -public LocalVariableBinding[] visibleLocals = new LocalVariableBinding[LOCALS_INCREMENT]; -int visibleLocalsCount; -// to handle goto_w -public boolean wideMode = false; + public LocalVariableBinding[] visibleLocals = new LocalVariableBinding[LOCALS_INCREMENT]; + + int visibleLocalsCount; + + // to handle goto_w + public boolean wideMode = false; + public CodeStream(ClassFile givenClassFile) { this.targetLevel = givenClassFile.targetJDK; this.generateAttributes = givenClassFile.produceAttributes; @@ -171,8 +92,93 @@ this.lineSeparatorPositions = givenClassFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.getLineSeparatorPositions(); } } +/** + * This methods searches for an existing entry inside the pcToSourceMap table with a pc equals to @pc. + * If there is an existing entry it returns -1 (no insertion required). + * Otherwise it returns the index where the entry for the pc has to be inserted. + * This is based on the fact that the pcToSourceMap table is sorted according to the pc. + * + * @param pcToSourceMap the given pcToSourceMap array + * @param length the given length + * @param pc the given pc + * @return int + */ +public static int insertionIndex(int[] pcToSourceMap, int length, int pc) { + int g = 0; + int d = length - 2; + int m = 0; + while (g <= d) { + m = (g + d) / 2; + // we search only on even indexes + if ((m & 1) != 0) // faster than ((m % 2) != 0) + m--; + int currentPC = pcToSourceMap[m]; + if (pc < currentPC) { + d = m - 2; + } else + if (pc > currentPC) { + g = m + 2; + } else { + return -1; + } + } + if (pc < pcToSourceMap[m]) + return m; + return m + 2; +} +public static final void sort(int[] tab, int lo0, int hi0, int[] result) { + int lo = lo0; + int hi = hi0; + int mid; + if (hi0 > lo0) { + /* Arbitrarily establishing partition element as the midpoint of + * the array. + */ + mid = tab[lo0 + (hi0 - lo0) / 2]; + // loop through the array until indices cross + while (lo <= hi) { + /* find the first element that is greater than or equal to + * the partition element starting from the left Index. + */ + while ((lo < hi0) && (tab[lo] < mid)) + ++lo; + /* find an element that is smaller than or equal to + * the partition element starting from the right Index. + */ + while ((hi > lo0) && (tab[hi] > mid)) + --hi; + // if the indexes have not crossed, swap + if (lo <= hi) { + swap(tab, lo, hi, result); + ++lo; + --hi; + } + } + /* If the right index has not reached the left side of array + * must now sort the left partition. + */ + if (lo0 < hi) + sort(tab, lo0, hi, result); + /* If the left index has not reached the right side of array + * must now sort the right partition. + */ + if (lo < hi0) + sort(tab, lo, hi0, result); + } +} + + +private static final void swap(int a[], int i, int j, int result[]) { + int T; + T = a[i]; + a[i] = a[j]; + a[j] = T; + T = result[j]; + result[j] = result[i]; + result[i] = T; +} + public void aaload() { - if (DEBUG) System.out.println(this.position + "\t\taaload"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -181,8 +187,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aaload; } + public void aastore() { - if (DEBUG) System.out.println(this.position + "\t\taastore"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -191,8 +197,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aastore; } + public void aconst_null() { - if (DEBUG) System.out.println(this.position + "\t\taconst_null"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) { @@ -204,6 +210,7 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aconst_null; } + public void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) { // Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS @@ -231,11 +238,17 @@ } } } + public void addLabel(BranchLabel aLabel) { if (this.countLabels == this.labels.length) System.arraycopy(this.labels, 0, this.labels = new BranchLabel[this.countLabels + LABELS_INCREMENT], 0, this.countLabels); this.labels[this.countLabels++] = aLabel; } + +public void addVariable(LocalVariableBinding localBinding) { + /* do nothing */ +} + public void addVisibleLocalVariable(LocalVariableBinding localBinding) { if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP_TABLE @@ -247,11 +260,7 @@ this.visibleLocals[this.visibleLocalsCount++] = localBinding; } -public void addVariable(LocalVariableBinding localBinding) { - /* do nothing */ -} public void aload(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\taload:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -277,8 +286,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void aload_0() { - if (DEBUG) System.out.println(this.position + "\t\taload_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) { @@ -293,8 +302,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_0; } + public void aload_1() { - if (DEBUG) System.out.println(this.position + "\t\taload_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -308,8 +317,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_1; } + public void aload_2() { - if (DEBUG) System.out.println(this.position + "\t\taload_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -323,8 +332,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_2; } + public void aload_3() { - if (DEBUG) System.out.println(this.position + "\t\taload_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -338,8 +347,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_3; } + public void anewarray(TypeBinding typeBinding) { - if (DEBUG) System.out.println(this.position + "\t\tanewarray: " + typeBinding); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset + 2 >= this.bCodeStream.length) { resizeByteArray(); @@ -348,8 +357,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_anewarray; writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding)); } + public void areturn() { - if (DEBUG) System.out.println(this.position + "\t\tareturn"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; // the stackDepth should be equal to 0 @@ -360,6 +369,7 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_areturn; this.lastAbruptCompletion = this.position; } + public void arrayAt(int typeBindingID) { switch (typeBindingID) { case TypeIds.T_int : @@ -388,6 +398,7 @@ aaload(); } } + public void arrayAtPut(int elementTypeID, boolean valueRequired) { switch (elementTypeID) { case TypeIds.T_int : @@ -432,8 +443,8 @@ aastore(); } } + public void arraylength() { - if (DEBUG) System.out.println(this.position + "\t\tarraylength"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -441,8 +452,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_arraylength; } + public void astore(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tastore:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= iArg) { @@ -465,8 +476,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void astore_0() { - if (DEBUG) System.out.println(this.position + "\t\tastore_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals == 0) { @@ -478,8 +489,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_0; } + public void astore_1() { - if (DEBUG) System.out.println(this.position + "\t\tastore_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 1) { @@ -491,8 +502,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_1; } + public void astore_2() { - if (DEBUG) System.out.println(this.position + "\t\tastore_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 2) { @@ -504,8 +515,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_2; } + public void astore_3() { - if (DEBUG) System.out.println(this.position + "\t\tastore_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 3) { @@ -517,8 +528,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_3; } + public void athrow() { - if (DEBUG) System.out.println(this.position + "\t\tathrow"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -528,8 +539,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_athrow; this.lastAbruptCompletion = this.position; } + public void baload() { - if (DEBUG) System.out.println(this.position + "\t\tbaload"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -538,8 +549,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_baload; } + public void bastore() { - if (DEBUG) System.out.println(this.position + "\t\tbastore"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -548,8 +559,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_bastore; } + public void bipush(byte b) { - if (DEBUG) System.out.println(this.position + "\t\tbipush "+b); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -561,8 +572,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_bipush; this.bCodeStream[this.classFileOffset++] = b; } + public void caload() { - if (DEBUG) System.out.println(this.position + "\t\tcaload"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -571,8 +582,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_caload; } + public void castore() { - if (DEBUG) System.out.println(this.position + "\t\tcastore"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -581,6 +592,7 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_castore; } + public void checkcast(int baseId) { this.countLabels = 0; if (this.classFileOffset + 2 >= this.bCodeStream.length) { @@ -614,8 +626,8 @@ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangBooleanConstantPoolName)); } } + public void checkcast(TypeBinding typeBinding) { - if (DEBUG) System.out.println(this.position + "\t\tcheckcast:"+typeBinding.debugName()); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset + 2 >= this.bCodeStream.length) { resizeByteArray(); @@ -624,8 +636,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_checkcast; writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding)); } + public void d2f() { - if (DEBUG) System.out.println(this.position + "\t\td2f"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -634,8 +646,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2f; } + public void d2i() { - if (DEBUG) System.out.println(this.position + "\t\td2i"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -644,8 +656,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2i; } + public void d2l() { - if (DEBUG) System.out.println(this.position + "\t\td2l"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -653,8 +665,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2l; } + public void dadd() { - if (DEBUG) System.out.println(this.position + "\t\tdadd"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -663,8 +675,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dadd; } + public void daload() { - if (DEBUG) System.out.println(this.position + "\t\tdaload"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -672,8 +684,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_daload; } + public void dastore() { - if (DEBUG) System.out.println(this.position + "\t\tdastore"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 4; if (this.classFileOffset >= this.bCodeStream.length) { @@ -682,8 +694,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dastore; } + public void dcmpg() { - if (DEBUG) System.out.println(this.position + "\t\tdcmpg"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -692,8 +704,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dcmpg; } + public void dcmpl() { - if (DEBUG) System.out.println(this.position + "\t\tdcmpl"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -702,8 +714,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dcmpl; } + public void dconst_0() { - if (DEBUG) System.out.println(this.position + "\t\tdconst_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -714,8 +726,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dconst_0; } + public void dconst_1() { - if (DEBUG) System.out.println(this.position + "\t\tdconst_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -726,8 +738,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dconst_1; } + public void ddiv() { - if (DEBUG) System.out.println(this.position + "\t\tddiv"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -736,11 +748,12 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ddiv; } + public void decrStackSize(int offset) { this.stackDepth -= offset; } + public void dload(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tdload:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -766,8 +779,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void dload_0() { - if (DEBUG) System.out.println(this.position + "\t\tdload_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -781,8 +794,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_0; } + public void dload_1() { - if (DEBUG) System.out.println(this.position + "\t\tdload_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -796,8 +809,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_1; } + public void dload_2() { - if (DEBUG) System.out.println(this.position + "\t\tdload_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -811,8 +824,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_2; } + public void dload_3() { - if (DEBUG) System.out.println(this.position + "\t\tdload_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -826,8 +839,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_3; } + public void dmul() { - if (DEBUG) System.out.println(this.position + "\t\tdmul"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -836,8 +849,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dmul; } + public void dneg() { - if (DEBUG) System.out.println(this.position + "\t\tdneg"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -845,8 +858,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dneg; } + public void drem() { - if (DEBUG) System.out.println(this.position + "\t\tdrem"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -855,8 +868,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_drem; } + public void dreturn() { - if (DEBUG) System.out.println(this.position + "\t\tdreturn"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; // the stackDepth should be equal to 0 @@ -867,8 +880,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dreturn; this.lastAbruptCompletion = this.position; } + public void dstore(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tdstore:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals <= iArg + 1) { @@ -891,8 +904,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void dstore_0() { - if (DEBUG) System.out.println(this.position + "\t\tdstore_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 2) { @@ -904,8 +917,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_0; } + public void dstore_1() { - if (DEBUG) System.out.println(this.position + "\t\tdstore_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 3) { @@ -917,8 +930,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_1; } + public void dstore_2() { - if (DEBUG) System.out.println(this.position + "\t\tdstore_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 4) { @@ -930,8 +943,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_2; } + public void dstore_3() { - if (DEBUG) System.out.println(this.position + "\t\tdstore_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 5) { @@ -943,8 +956,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_3; } + public void dsub() { - if (DEBUG) System.out.println(this.position + "\t\tdsub"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -953,8 +966,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dsub; } + public void dup() { - if (DEBUG) System.out.println(this.position + "\t\tdup"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) { @@ -966,8 +979,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup; } + public void dup_x1() { - if (DEBUG) System.out.println(this.position + "\t\tdup_x1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -978,8 +991,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup_x1; } + public void dup_x2() { - if (DEBUG) System.out.println(this.position + "\t\tdup_x2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -990,8 +1003,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup_x2; } + public void dup2() { - if (DEBUG) System.out.println(this.position + "\t\tdup2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -1002,8 +1015,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2; } + public void dup2_x1() { - if (DEBUG) System.out.println(this.position + "\t\tdup2_x1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -1014,8 +1027,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2_x1; } + public void dup2_x2() { - if (DEBUG) System.out.println(this.position + "\t\tdup2_x2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -1026,9 +1039,9 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2_x2; } + public void exitUserScope(BlockScope currentScope) { // mark all the scope's locals as losing their definite assignment - if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP_TABLE | ClassFileConstants.ATTR_STACK_MAP)) == 0) @@ -1049,6 +1062,7 @@ this.visibleLocals[index--] = null; // this variable is no longer visible afterwards } } + public void exitUserScope(BlockScope currentScope, LocalVariableBinding binding) { // mark all the scope's locals as losing their definite assignment if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS @@ -1070,8 +1084,8 @@ this.visibleLocals[index--] = null; // this variable is no longer visible afterwards } } + public void f2d() { - if (DEBUG) System.out.println(this.position + "\t\tf2d"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -1082,8 +1096,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2d; } + public void f2i() { - if (DEBUG) System.out.println(this.position + "\t\tf2i"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -1091,8 +1105,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2i; } + public void f2l() { - if (DEBUG) System.out.println(this.position + "\t\tf2l"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -1103,8 +1117,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2l; } + public void fadd() { - if (DEBUG) System.out.println(this.position + "\t\tfadd"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1113,8 +1127,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fadd; } + public void faload() { - if (DEBUG) System.out.println(this.position + "\t\tfaload"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1123,8 +1137,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_faload; } + public void fastore() { - if (DEBUG) System.out.println(this.position + "\t\tfaload"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1133,8 +1147,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fastore; } + public void fcmpg() { - if (DEBUG) System.out.println(this.position + "\t\tfcmpg"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1143,8 +1157,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fcmpg; } + public void fcmpl() { - if (DEBUG) System.out.println(this.position + "\t\tfcmpl"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1153,8 +1167,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fcmpl; } + public void fconst_0() { - if (DEBUG) System.out.println(this.position + "\t\tfconst_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -1165,8 +1179,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_0; } + public void fconst_1() { - if (DEBUG) System.out.println(this.position + "\t\tfconst_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -1177,8 +1191,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_1; } + public void fconst_2() { - if (DEBUG) System.out.println(this.position + "\t\tfconst_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -1189,8 +1203,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_2; } + public void fdiv() { - if (DEBUG) System.out.println(this.position + "\t\tfdiv"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1199,8 +1213,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fdiv; } + public void fload(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tfload:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= iArg) { @@ -1225,8 +1239,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void fload_0() { - if (DEBUG) System.out.println(this.position + "\t\tfload_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals == 0) { @@ -1240,8 +1254,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_0; } + public void fload_1() { - if (DEBUG) System.out.println(this.position + "\t\tfload_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= 1) { @@ -1255,8 +1269,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_1; } + public void fload_2() { - if (DEBUG) System.out.println(this.position + "\t\tfload_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= 2) { @@ -1270,8 +1284,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_2; } + public void fload_3() { - if (DEBUG) System.out.println(this.position + "\t\tfload_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= 3) { @@ -1285,8 +1299,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_3; } + public void fmul() { - if (DEBUG) System.out.println(this.position + "\t\tfmul"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1295,8 +1309,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fmul; } + public void fneg() { - if (DEBUG) System.out.println(this.position + "\t\tfneg"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -1304,8 +1318,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fneg; } + public void frem() { - if (DEBUG) System.out.println(this.position + "\t\tfrem"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1314,8 +1328,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_frem; } + public void freturn() { - if (DEBUG) System.out.println(this.position + "\t\tfreturn"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; // the stackDepth should be equal to 0 @@ -1326,8 +1340,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_freturn; this.lastAbruptCompletion = this.position; } + public void fstore(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tfstore:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= iArg) { @@ -1350,8 +1364,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void fstore_0() { - if (DEBUG) System.out.println(this.position + "\t\tfstore_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals == 0) { @@ -1363,8 +1377,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_0; } + public void fstore_1() { - if (DEBUG) System.out.println(this.position + "\t\tfstore_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 1) { @@ -1376,8 +1390,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_1; } + public void fstore_2() { - if (DEBUG) System.out.println(this.position + "\t\tfstore_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 2) { @@ -1389,8 +1403,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_2; } + public void fstore_3() { - if (DEBUG) System.out.println(this.position + "\t\tfstore_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 3) { @@ -1404,7 +1418,6 @@ } public void fsub() { - if (DEBUG) System.out.println(this.position + "\t\tfsub"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -1413,28 +1426,27 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fsub; } + public void generateBoxingConversion(int unboxedTypeID) { switch (unboxedTypeID) { case TypeIds.T_byte : if (this.targetLevel >= ClassFileConstants.JDK1_5) { - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Byte.valueOf(byte)"); //$NON-NLS-1$ // invokestatic: Byte.valueOf(byte) invoke( Opcodes.OPC_invokestatic, - 1, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangByteConstantPoolName, ConstantPool.ValueOf, ConstantPool.byteByteSignature); } else { // new Byte( byte ) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Byte(byte)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x1(); swap(); invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangByteConstantPoolName, ConstantPool.Init, @@ -1444,23 +1456,21 @@ case TypeIds.T_short : if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) { // invokestatic: Short.valueOf(short) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Short.valueOf(short)"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 1, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangShortConstantPoolName, ConstantPool.ValueOf, ConstantPool.shortShortSignature); } else { // new Short(short) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Short(short)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x1(); swap(); invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangShortConstantPoolName, ConstantPool.Init, @@ -1470,23 +1480,21 @@ case TypeIds.T_char : if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) { // invokestatic: Character.valueOf(char) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Character.valueOf(char)"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 1, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangCharacterConstantPoolName, ConstantPool.ValueOf, ConstantPool.charCharacterSignature); } else { // new Char( char ) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Character(char)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x1(); swap(); invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangCharacterConstantPoolName, ConstantPool.Init, @@ -1496,23 +1504,21 @@ case TypeIds.T_int : if (this.targetLevel >= ClassFileConstants.JDK1_5) { // invokestatic: Integer.valueOf(int) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Integer.valueOf(int)"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 1, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangIntegerConstantPoolName, ConstantPool.ValueOf, ConstantPool.IntIntegerSignature); } else { // new Integer(int) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Integer(int)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x1(); swap(); invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangIntegerConstantPoolName, ConstantPool.Init, @@ -1522,24 +1528,22 @@ case TypeIds.T_long : if (this.targetLevel >= ClassFileConstants.JDK1_5) { // invokestatic: Long.valueOf(long) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Long.valueOf(long)"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 2, // argCount + 2, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangLongConstantPoolName, ConstantPool.ValueOf, ConstantPool.longLongSignature); } else { // new Long( long ) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Long(long)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x2(); dup_x2(); pop(); invoke( Opcodes.OPC_invokespecial, - 2, // argCount + 3, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangLongConstantPoolName, ConstantPool.Init, @@ -1549,23 +1553,21 @@ case TypeIds.T_float : if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) { // invokestatic: Float.valueOf(float) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Float.valueOf(float)"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 1, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangFloatConstantPoolName, ConstantPool.ValueOf, ConstantPool.floatFloatSignature); } else { // new Float(float) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Float(float)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x1(); swap(); invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangFloatConstantPoolName, ConstantPool.Init, @@ -1575,17 +1577,15 @@ case TypeIds.T_double : if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) { // invokestatic: Double.valueOf(double) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Double.valueOf(double)"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 2, // argCount + 3, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangDoubleConstantPoolName, ConstantPool.ValueOf, ConstantPool.doubleDoubleSignature); } else { // new Double( double ) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Double(double)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x2(); dup_x2(); @@ -1593,7 +1593,7 @@ invoke( Opcodes.OPC_invokespecial, - 2, // argCount + 3, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangDoubleConstantPoolName, ConstantPool.Init, @@ -1604,23 +1604,21 @@ case TypeIds.T_boolean : if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) { // invokestatic: Boolean.valueOf(boolean) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Boolean.valueOf(boolean)"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 1, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangBooleanConstantPoolName, ConstantPool.ValueOf, ConstantPool.booleanBooleanSignature); } else { // new Boolean(boolean) - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Boolean(boolean)"); //$NON-NLS-1$ newWrapperFor(unboxedTypeID); dup_x1(); swap(); invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangBooleanConstantPoolName, ConstantPool.Init, @@ -1628,6 +1626,7 @@ } } } + /** * Macro for building a class descriptor object */ @@ -1636,7 +1635,6 @@ getTYPE(accessedType.id); return; } - if (this.targetLevel >= ClassFileConstants.JDK1_5) { // generation using the new ldc_w bytecode this.ldc(accessedType); @@ -1716,6 +1714,7 @@ this.stackDepth = savedStackDepth; } } + /** * This method generates the code attribute bytecode */ @@ -1726,6 +1725,7 @@ invokeJavaLangErrorConstructor(); athrow(); } + public void generateConstant(Constant constant, int implicitConversionCode) { int targetTypeID = (implicitConversionCode & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4; if (targetTypeID == 0) targetTypeID = constant.typeID(); // use default constant type @@ -1762,6 +1762,7 @@ generateBoxingConversion(targetTypeID); } } + public void generateEmulatedReadAccessForField(FieldBinding fieldBinding) { generateEmulationForField(fieldBinding); // swap the field with the receiver @@ -1771,9 +1772,11 @@ this.checkcast(fieldBinding.type); } } + public void generateEmulatedWriteAccessForField(FieldBinding fieldBinding) { invokeJavaLangReflectFieldSetter(fieldBinding.type.id); } + public void generateEmulationForConstructor(Scope scope, MethodBinding methodBinding) { // leave a java.lang.reflect.Field object on the stack this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.')); @@ -1817,6 +1820,7 @@ iconst_1(); invokeAccessibleObjectSetAccessible(); } + public void generateEmulationForField(FieldBinding fieldBinding) { // leave a java.lang.reflect.Field object on the stack this.ldc(String.valueOf(fieldBinding.declaringClass.constantPoolName()).replace('/', '.')); @@ -1827,6 +1831,7 @@ iconst_1(); invokeAccessibleObjectSetAccessible(); } + public void generateEmulationForMethod(Scope scope, MethodBinding methodBinding) { // leave a java.lang.reflect.Field object on the stack this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.')); @@ -1871,6 +1876,7 @@ iconst_1(); invokeAccessibleObjectSetAccessible(); } + private void generateFieldAccess(byte opcode, int returnTypeSize, char[] declaringClass, char[] name, char[] signature) { this.countLabels = 0; switch(opcode) { @@ -1910,6 +1916,7 @@ this.bCodeStream[this.classFileOffset++] = opcode; writeUnsignedShort(this.constantPool.literalIndexForField(declaringClass, name, signature)); } + private void generateFieldAccess(byte opcode, int returnTypeSize, ReferenceBinding binding, char[] name, TypeBinding type) { if (binding.isNestedType()) { this.classFile.recordInnerClasses(binding); @@ -1920,6 +1927,7 @@ } this.generateFieldAccess(opcode, returnTypeSize, binding.constantPoolName(), name, type.signature()); } + /** * Generates the sequence of instructions which will perform the conversion of the expression * on the stack into a different type (e.g. long l = someInt; --> i2l must be inserted). @@ -2034,6 +2042,7 @@ generateBoxingConversion(typeId); } } + public void generateInlinedValue(boolean inlinedValue) { if (inlinedValue) iconst_1(); @@ -2104,6 +2113,7 @@ this.ldc(inlinedValue); } } + public void generateInlinedValue(double inlinedValue) { if (inlinedValue == 0.0) { if (Double.doubleToLongBits(inlinedValue) != 0L) @@ -2118,6 +2128,7 @@ } this.ldc2_w(inlinedValue); } + public void generateInlinedValue(float inlinedValue) { if (inlinedValue == 0.0f) { if (Float.floatToIntBits(inlinedValue) != 0) @@ -2136,6 +2147,7 @@ } this.ldc(inlinedValue); } + public void generateInlinedValue(int inlinedValue) { switch (inlinedValue) { case -1 : @@ -2171,6 +2183,7 @@ this.ldc(inlinedValue); } } + public void generateInlinedValue(long inlinedValue) { if (inlinedValue == 0) { lconst_0(); @@ -2182,6 +2195,7 @@ } this.ldc2_w(inlinedValue); } + public void generateInlinedValue(short inlinedValue) { switch (inlinedValue) { case -1 : @@ -2213,6 +2227,7 @@ sipush(inlinedValue); } } + public void generateOuterAccess(Object[] mappingSequence, ASTNode invocationSite, Binding target, Scope scope) { if (mappingSequence == null) { if (target instanceof LocalVariableBinding) { @@ -2245,12 +2260,12 @@ FieldBinding fieldBinding = (FieldBinding) mappingSequence[i]; getfield(fieldBinding); } else { - invokestatic((MethodBinding) mappingSequence[i]); + invoke(Opcodes.OPC_invokestatic, (MethodBinding) mappingSequence[i], null /* default declaringClass */); } } } -public void generateReturnBytecode(Expression expression) { +public void generateReturnBytecode(Expression expression) { if (expression == null) { return_(); } else { @@ -2279,6 +2294,7 @@ } } } + /** * The equivalent code performs a string conversion: * @@ -2308,13 +2324,12 @@ this.recordPositionsFrom(pc, oper2.sourceStart); invokeStringConcatenationToString(); } + /** * @param accessBinding the access method binding to generate */ public void generateSyntheticBodyForConstructorAccess(SyntheticMethodBinding accessBinding) { - initializeMaxLocals(accessBinding); - MethodBinding constructorBinding = accessBinding.targetMethod; TypeBinding[] parameters = constructorBinding.parameters; int length = parameters.length; @@ -2359,9 +2374,10 @@ resolvedPosition++; } } - invokespecial(constructorBinding); + invoke(Opcodes.OPC_invokespecial, constructorBinding, null /* default declaringClass */); return_(); } + //static X valueOf(String name) { // return (X) Enum.valueOf(X.class, name); //} @@ -2374,6 +2390,7 @@ this.checkcast(declaringClass); areturn(); } + //static X[] values() { // X[] values; // int length; @@ -2404,6 +2421,7 @@ aload_2(); areturn(); } + public void generateSyntheticBodyForFieldReadAccess(SyntheticMethodBinding accessBinding) { initializeMaxLocals(accessBinding); FieldBinding fieldBinding = accessBinding.targetReadField; @@ -2437,6 +2455,7 @@ areturn(); } } + public void generateSyntheticBodyForFieldWriteAccess(SyntheticMethodBinding accessBinding) { initializeMaxLocals(accessBinding); FieldBinding fieldBinding = accessBinding.targetWriteField; @@ -2450,8 +2469,8 @@ } return_(); } -public void generateSyntheticBodyForMethodAccess(SyntheticMethodBinding accessMethod) { +public void generateSyntheticBodyForMethodAccess(SyntheticMethodBinding accessMethod) { initializeMaxLocals(accessMethod); MethodBinding targetMethod = accessMethod.targetMethod; TypeBinding[] parameters = targetMethod.parameters; @@ -2482,18 +2501,18 @@ resolvedPosition++; } if (targetMethod.isStatic()) - invokestatic(targetMethod); + invoke(Opcodes.OPC_invokestatic, targetMethod, null /* default declaringClass */); else { if (targetMethod.isConstructor() || targetMethod.isPrivate() // qualified super "X.super.foo()" targets methods from superclass || accessMethod.purpose == SyntheticMethodBinding.SuperMethodAccess){ - invokespecial(targetMethod); + invoke(Opcodes.OPC_invokespecial, targetMethod, null /* default declaringClass */); } else { if (targetMethod.declaringClass.isInterface()) { // interface or annotation type - invokeinterface(targetMethod); + invoke(Opcodes.OPC_invokeinterface, targetMethod, null /* default declaringClass */); } else { - invokevirtual(targetMethod); + invoke(Opcodes.OPC_invokevirtual, targetMethod, accessMethod.declaringClass); } } } @@ -2526,12 +2545,12 @@ areturn(); } } + public void generateSyntheticBodyForSwitchTable(SyntheticMethodBinding methodBinding) { ClassScope scope = ((SourceTypeBinding)methodBinding.declaringClass).scope; initializeMaxLocals(methodBinding); final BranchLabel nullLabel = new BranchLabel(this); FieldBinding syntheticFieldBinding = methodBinding.targetReadField; - getstatic(syntheticFieldBinding); dup(); ifnull(nullLabel); @@ -2576,16 +2595,12 @@ areturn(); removeVariable(localVariableBinding); } + /** * Code responsible to generate the suitable code to supply values for the synthetic enclosing * instance arguments of a constructor invocation of a nested type. */ -public void generateSyntheticEnclosingInstanceValues( - BlockScope currentScope, - ReferenceBinding targetType, - Expression enclosingInstance, - ASTNode invocationSite) { - +public void generateSyntheticEnclosingInstanceValues(BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, ASTNode invocationSite) { // supplying enclosing instance for the anonymous type's superclass ReferenceBinding checkedTargetType = targetType.isAnonymousType() ? (ReferenceBinding)targetType.superclass().erasure() : targetType; boolean hasExtraEnclosingInstance = enclosingInstance != null; @@ -2641,13 +2656,13 @@ } } } + /** * Code responsible to generate the suitable code to supply values for the synthetic outer local * variable arguments of a constructor invocation of a nested type. * (bug 26122) - synthetic values for outer locals must be passed after user arguments, e.g. new X(i = 1){} */ public void generateSyntheticOuterArgumentValues(BlockScope currentScope, ReferenceBinding targetType, ASTNode invocationSite) { - // generate the synthetic outer arguments then SyntheticArgumentBinding syntheticArguments[]; if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) { @@ -2658,13 +2673,14 @@ } } } + public void generateUnboxingConversion(int unboxedTypeID) { switch (unboxedTypeID) { case TypeIds.T_byte : // invokevirtual: byteValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangByteConstantPoolName, ConstantPool.BYTEVALUE_BYTE_METHOD_NAME, @@ -2674,7 +2690,7 @@ // invokevirtual: shortValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangShortConstantPoolName, ConstantPool.SHORTVALUE_SHORT_METHOD_NAME, @@ -2684,7 +2700,7 @@ // invokevirtual: charValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangCharacterConstantPoolName, ConstantPool.CHARVALUE_CHARACTER_METHOD_NAME, @@ -2694,7 +2710,7 @@ // invokevirtual: intValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangIntegerConstantPoolName, ConstantPool.INTVALUE_INTEGER_METHOD_NAME, @@ -2704,7 +2720,7 @@ // invokevirtual: longValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 2, // return type size ConstantPool.JavaLangLongConstantPoolName, ConstantPool.LONGVALUE_LONG_METHOD_NAME, @@ -2714,7 +2730,7 @@ // invokevirtual: floatValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangFloatConstantPoolName, ConstantPool.FLOATVALUE_FLOAT_METHOD_NAME, @@ -2724,7 +2740,7 @@ // invokevirtual: doubleValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 2, // return type size ConstantPool.JavaLangDoubleConstantPoolName, ConstantPool.DOUBLEVALUE_DOUBLE_METHOD_NAME, @@ -2734,13 +2750,14 @@ // invokevirtual: booleanValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangBooleanConstantPoolName, ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_NAME, ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE); } } + /* * Wide conditional branch compare, improved by swapping comparison opcode * ifeq WideTarget @@ -2760,13 +2777,14 @@ goto_w(wideTarget); intermediate.place(); } + public void getBaseTypeValue(int baseTypeID) { switch (baseTypeID) { case TypeIds.T_byte : // invokevirtual: byteValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangByteConstantPoolName, ConstantPool.BYTEVALUE_BYTE_METHOD_NAME, @@ -2776,7 +2794,7 @@ // invokevirtual: shortValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangShortConstantPoolName, ConstantPool.SHORTVALUE_SHORT_METHOD_NAME, @@ -2786,7 +2804,7 @@ // invokevirtual: charValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangCharacterConstantPoolName, ConstantPool.CHARVALUE_CHARACTER_METHOD_NAME, @@ -2796,7 +2814,7 @@ // invokevirtual: intValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangIntegerConstantPoolName, ConstantPool.INTVALUE_INTEGER_METHOD_NAME, @@ -2806,7 +2824,7 @@ // invokevirtual: longValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 2, // return type size ConstantPool.JavaLangLongConstantPoolName, ConstantPool.LONGVALUE_LONG_METHOD_NAME, @@ -2816,7 +2834,7 @@ // invokevirtual: floatValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangFloatConstantPoolName, ConstantPool.FLOATVALUE_FLOAT_METHOD_NAME, @@ -2826,7 +2844,7 @@ // invokevirtual: doubleValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 2, // return type size ConstantPool.JavaLangDoubleConstantPoolName, ConstantPool.DOUBLEVALUE_DOUBLE_METHOD_NAME, @@ -2836,20 +2854,21 @@ // invokevirtual: booleanValue() invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangBooleanConstantPoolName, ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_NAME, ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE); } } + final public byte[] getContents() { byte[] contents; System.arraycopy(this.bCodeStream, 0, contents = new byte[this.position], 0, this.position); return contents; } + public void getfield(FieldBinding fieldBinding) { - if (DEBUG) System.out.println(this.position + "\t\tgetfield:"+fieldBinding); //$NON-NLS-1$ int returnTypeSize = 1; if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) { returnTypeSize = 2; @@ -2861,11 +2880,12 @@ fieldBinding.name, fieldBinding.type); } + protected int getPosition() { return this.position; } + public void getstatic(FieldBinding fieldBinding) { - if (DEBUG) System.out.println(this.position + "\t\tgetstatic:"+fieldBinding); //$NON-NLS-1$ int returnTypeSize = 1; if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) { returnTypeSize = 2; @@ -2877,12 +2897,12 @@ fieldBinding.name, fieldBinding.type); } + public void getTYPE(int baseTypeID) { this.countLabels = 0; switch (baseTypeID) { case TypeIds.T_byte : // getstatic: java.lang.Byte.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Byte.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2892,7 +2912,6 @@ break; case TypeIds.T_short : // getstatic: java.lang.Short.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Short.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2902,7 +2921,6 @@ break; case TypeIds.T_char : // getstatic: java.lang.Character.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Character.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2912,7 +2930,6 @@ break; case TypeIds.T_int : // getstatic: java.lang.Integer.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Integer.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2922,7 +2939,6 @@ break; case TypeIds.T_long : // getstatic: java.lang.Long.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Long.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2932,7 +2948,6 @@ break; case TypeIds.T_float : // getstatic: java.lang.Float.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Float.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2942,7 +2957,6 @@ break; case TypeIds.T_double : // getstatic: java.lang.Double.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Double.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2952,7 +2966,6 @@ break; case TypeIds.T_boolean : // getstatic: java.lang.Boolean.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Boolean.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2962,7 +2975,6 @@ break; case TypeIds.T_void : // getstatic: java.lang.Void.TYPE - if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Void.TYPE"); //$NON-NLS-1$ generateFieldAccess( Opcodes.OPC_getstatic, 1, @@ -2972,6 +2984,7 @@ break; } } + /** * We didn't call it goto, because there is a conflit with the goto keyword */ @@ -2980,20 +2993,10 @@ goto_w(label); return; } - if (DEBUG) System.out.println(this.position + "\t\tgoto:"+label); //$NON-NLS-1$ if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } boolean chained = inlineForwardReferencesFromLabelsTargeting(label, this.position); - if (DEBUG && chained) { - if (DEBUG) { - if (this.lastAbruptCompletion == this.position) { - System.out.println("\t\t\t\t");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } else { - System.out.println("\t\t\t\t");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } - } - } /* Possible optimization for code such as: public Object foo() { @@ -3027,8 +3030,8 @@ label.branch(); this.lastAbruptCompletion = this.position; } + public void goto_w(BranchLabel label) { - if (DEBUG) System.out.println(this.position + "\t\tgotow:"+label); //$NON-NLS-1$ if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); } @@ -3037,8 +3040,8 @@ label.branchWide(); this.lastAbruptCompletion = this.position; } + public void i2b() { - if (DEBUG) System.out.println(this.position + "\t\ti2b"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -3046,8 +3049,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2b; } + public void i2c() { - if (DEBUG) System.out.println(this.position + "\t\ti2c"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -3055,8 +3058,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2c; } + public void i2d() { - if (DEBUG) System.out.println(this.position + "\t\ti2d"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3067,8 +3070,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2d; } + public void i2f() { - if (DEBUG) System.out.println(this.position + "\t\ti2f"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -3076,8 +3079,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2f; } + public void i2l() { - if (DEBUG) System.out.println(this.position + "\t\ti2l"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3088,8 +3091,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2l; } + public void i2s() { - if (DEBUG) System.out.println(this.position + "\t\ti2s"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -3097,8 +3100,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2s; } + public void iadd() { - if (DEBUG) System.out.println(this.position + "\t\tiadd"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -3107,8 +3110,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iadd; } + public void iaload() { - if (DEBUG) System.out.println(this.position + "\t\tiaload"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -3117,8 +3120,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iaload; } + public void iand() { - if (DEBUG) System.out.println(this.position + "\t\tiand"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -3127,8 +3130,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iand; } + public void iastore() { - if (DEBUG) System.out.println(this.position + "\t\tiastore"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -3137,8 +3140,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iastore; } + public void iconst_0() { - if (DEBUG) System.out.println(this.position + "\t\ticonst_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3149,8 +3152,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_0; } + public void iconst_1() { - if (DEBUG) System.out.println(this.position + "\t\ticonst_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3161,8 +3164,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_1; } + public void iconst_2() { - if (DEBUG) System.out.println(this.position + "\t\ticonst_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3174,7 +3177,6 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_2; } public void iconst_3() { - if (DEBUG) System.out.println(this.position + "\t\ticonst_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3185,8 +3187,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_3; } + public void iconst_4() { - if (DEBUG) System.out.println(this.position + "\t\ticonst_4"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3197,8 +3199,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_4; } + public void iconst_5() { - if (DEBUG) System.out.println(this.position + "\t\ticonst_5"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3209,8 +3211,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_5; } + public void iconst_m1() { - if (DEBUG) System.out.println(this.position + "\t\ticonst_m1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -3221,8 +3223,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_m1; } + public void idiv() { - if (DEBUG) System.out.println(this.position + "\t\tidiv"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -3231,8 +3233,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_idiv; } + public void if_acmpeq(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_acmpeq:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth-=2; if (this.wideMode) { @@ -3246,8 +3248,8 @@ lbl.branch(); } } + public void if_acmpne(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_acmpne:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth-=2; if (this.wideMode) { @@ -3261,8 +3263,8 @@ lbl.branch(); } } + public void if_icmpeq(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_cmpeq:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.wideMode) { @@ -3276,8 +3278,8 @@ lbl.branch(); } } + public void if_icmpge(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_icmpge:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.wideMode) { @@ -3291,8 +3293,8 @@ lbl.branch(); } } + public void if_icmpgt(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_icmpgt:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.wideMode) { @@ -3306,8 +3308,8 @@ lbl.branch(); } } + public void if_icmple(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_icmple:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.wideMode) { @@ -3321,8 +3323,8 @@ lbl.branch(); } } + public void if_icmplt(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_icmplt:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.wideMode) { @@ -3336,8 +3338,8 @@ lbl.branch(); } } + public void if_icmpne(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tif_icmpne:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.wideMode) { @@ -3351,8 +3353,8 @@ lbl.branch(); } } + public void ifeq(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tifeq:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3366,8 +3368,8 @@ lbl.branch(); } } + public void ifge(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tifge:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3381,8 +3383,8 @@ lbl.branch(); } } + public void ifgt(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tifgt:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3396,8 +3398,8 @@ lbl.branch(); } } + public void ifle(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tifle:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3411,8 +3413,8 @@ lbl.branch(); } } + public void iflt(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tiflt:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3426,8 +3428,8 @@ lbl.branch(); } } + public void ifne(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tifne:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3441,8 +3443,8 @@ lbl.branch(); } } + public void ifnonnull(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tifnonnull:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3456,8 +3458,8 @@ lbl.branch(); } } + public void ifnull(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tifnull:"+lbl); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.wideMode) { @@ -3471,8 +3473,8 @@ lbl.branch(); } } + final public void iinc(int index, int value) { - if (DEBUG) System.out.println(this.position + "\t\tiinc:"+index+","+value); //$NON-NLS-1$ //$NON-NLS-2$ this.countLabels = 0; if ((index > 255) || (value < -128 || value > 127)) { // have to widen if (this.classFileOffset + 3 >= this.bCodeStream.length) { @@ -3493,8 +3495,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) value; } } + public void iload(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tiload:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= iArg) { @@ -3519,8 +3521,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void iload_0() { - if (DEBUG) System.out.println(this.position + "\t\tiload_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= 0) { @@ -3534,8 +3536,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_0; } + public void iload_1() { - if (DEBUG) System.out.println(this.position + "\t\tiload_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= 1) { @@ -3549,8 +3551,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_1; } + public void iload_2() { - if (DEBUG) System.out.println(this.position + "\t\tiload_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= 2) { @@ -3564,8 +3566,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_2; } + public void iload_3() { - if (DEBUG) System.out.println(this.position + "\t\tiload_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.maxLocals <= 3) { @@ -3579,8 +3581,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_3; } + public void imul() { - if (DEBUG) System.out.println(this.position + "\t\timul"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -3589,6 +3591,7 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_imul; } + public int indexOfSameLineEntrySincePC(int pc, int line) { for (int index = pc, max = this.pcToSourceMapSize; index < max; index+=2) { if (this.pcToSourceMap[index+1] == line) @@ -3596,8 +3599,8 @@ } return -1; } + public void ineg() { - if (DEBUG) System.out.println(this.position + "\t\tineg"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -3605,30 +3608,7 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ineg; } -/* - * Some placed labels might be branching to a goto bytecode which we can optimize better. - */ -public boolean inlineForwardReferencesFromLabelsTargeting(BranchLabel targetLabel, int gotoLocation) { - if (targetLabel.delegate != null) return false; // already inlined - int chaining = L_UNKNOWN; - for (int i = this.countLabels - 1; i >= 0; i--) { - BranchLabel currentLabel = this.labels[i]; - if (currentLabel.position != gotoLocation) break; - if (currentLabel == targetLabel) { - chaining |= L_CANNOT_OPTIMIZE; // recursive - continue; - } - if (currentLabel.isStandardLabel()) { - if (currentLabel.delegate != null) continue; // ignore since already inlined - targetLabel.becomeDelegateFor(currentLabel); - chaining |= L_OPTIMIZABLE; // optimizable, providing no vetoing - continue; - } - // case label - chaining |= L_CANNOT_OPTIMIZE; - } - return (chaining & (L_OPTIMIZABLE|L_CANNOT_OPTIMIZE)) == L_OPTIMIZABLE; // check was some standards, and no case/recursive -} + public void init(ClassFile targetClassFile) { this.classFile = targetClassFile; this.constantPool = targetClassFile.constantPool; @@ -3671,16 +3651,15 @@ this.maxLocals = 0; this.position = 0; } + /** * @param methodBinding the given method binding to initialize the max locals */ public void initializeMaxLocals(MethodBinding methodBinding) { - if (methodBinding == null) { this.maxLocals = 0; return; } - this.maxLocals = methodBinding.isStatic() ? 0 : 1; // take into account enum constructor synthetic name+ordinal @@ -3721,73 +3700,186 @@ } } } + /** - * We didn't call it instanceof because there is a conflit with the - * instanceof keyword + * Some placed labels might be branching to a goto bytecode which we can optimize better. */ -public void instance_of(TypeBinding typeBinding) { - if (DEBUG) System.out.println(this.position + "\t\tinstance_of:"+typeBinding); //$NON-NLS-1$ - this.countLabels = 0; - if (this.classFileOffset + 2 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position++; - this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_instanceof; - writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding)); +public boolean inlineForwardReferencesFromLabelsTargeting(BranchLabel targetLabel, int gotoLocation) { + if (targetLabel.delegate != null) return false; // already inlined + int chaining = L_UNKNOWN; + for (int i = this.countLabels - 1; i >= 0; i--) { + BranchLabel currentLabel = this.labels[i]; + if (currentLabel.position != gotoLocation) break; + if (currentLabel == targetLabel) { + chaining |= L_CANNOT_OPTIMIZE; // recursive + continue; + } + if (currentLabel.isStandardLabel()) { + if (currentLabel.delegate != null) continue; // ignore since already inlined + targetLabel.becomeDelegateFor(currentLabel); + chaining |= L_OPTIMIZABLE; // optimizable, providing no vetoing + continue; + } + // case label + chaining |= L_CANNOT_OPTIMIZE; + } + return (chaining & (L_OPTIMIZABLE|L_CANNOT_OPTIMIZE)) == L_OPTIMIZABLE; // check was some standards, and no case/recursive } -protected void invoke(int opcode, int argsSize, int returnTypeSize, char[] declaringClass, char[] selector, char[] signature) { + +/** + * We didn't call it instanceof because there is a conflit with the + * instanceof keyword + */ +public void instance_of(TypeBinding typeBinding) { this.countLabels = 0; - int argCount = argsSize; - switch(opcode) { - case Opcodes.OPC_invokeinterface : - if (this.classFileOffset + 4 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position +=3; - this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokeinterface; - writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, true)); - argCount++; - this.bCodeStream[this.classFileOffset++] = (byte) argCount; - this.bCodeStream[this.classFileOffset++] = 0; - break; - case Opcodes.OPC_invokevirtual : - case Opcodes.OPC_invokespecial : - if (this.classFileOffset + 2 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position++; - this.bCodeStream[this.classFileOffset++] = (byte) opcode; - writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, false)); - argCount++; - break; - case Opcodes.OPC_invokestatic : - if (this.classFileOffset + 2 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position++; - this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokestatic; - writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, false)); + if (this.classFileOffset + 2 >= this.bCodeStream.length) { + resizeByteArray(); } - this.stackDepth += returnTypeSize - argCount; + this.position++; + this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_instanceof; + writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding)); +} + +public void invoke(byte opcode, MethodBinding methodBinding, TypeBinding declaringClass) { + if (declaringClass == null) declaringClass = methodBinding.declaringClass; + if (declaringClass.isNestedType()) { + this.classFile.recordInnerClasses(declaringClass); + } + // compute receiverAndArgsSize + int receiverAndArgsSize; + switch(opcode) { + case Opcodes.OPC_invokestatic : + receiverAndArgsSize = 0; // no receiver + break; + case Opcodes.OPC_invokeinterface : + case Opcodes.OPC_invokevirtual : + receiverAndArgsSize = 1; // receiver + break; + case Opcodes.OPC_invokespecial : + receiverAndArgsSize = 1; // receiver + if (methodBinding.isConstructor()) { + if (declaringClass.isNestedType()) { + ReferenceBinding nestedType = (ReferenceBinding) declaringClass; + // enclosing instances + TypeBinding[] syntheticArgumentTypes = nestedType.syntheticEnclosingInstanceTypes(); + if (syntheticArgumentTypes != null) { + for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) { + switch (syntheticArgumentTypes[i].id) { + case TypeIds.T_double : + case TypeIds.T_long : + receiverAndArgsSize += 2; + break; + default: + receiverAndArgsSize++; + break; + } + } + } + // outer local variables + SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables(); + if (syntheticArguments != null) { + for (int i = 0, max = syntheticArguments.length; i < max; i++) { + switch (syntheticArguments[i].id) { + case TypeIds.T_double : + case TypeIds.T_long : + receiverAndArgsSize += 2; + break; + default: + receiverAndArgsSize++; + break; + } + } + } + } + if (declaringClass.isEnum()) { + // adding String (name) and int (ordinal) + receiverAndArgsSize += 2; + } + } + break; + default : + return; // should not occur + + } + for (int i = methodBinding.parameters.length - 1; i >= 0; i--) { + switch (methodBinding.parameters[i].id) { + case TypeIds.T_double : + case TypeIds.T_long : + receiverAndArgsSize += 2; + break; + default : + receiverAndArgsSize ++; + break; + } + } + // compute return type size + int returnTypeSize; + switch (methodBinding.returnType.id) { + case TypeIds.T_double : + case TypeIds.T_long : + returnTypeSize = 2; + break; + case TypeIds.T_void : + returnTypeSize = 0; + break; + default : + returnTypeSize = 1; + break; + } + invoke( + opcode, + receiverAndArgsSize, + returnTypeSize, + declaringClass.constantPoolName(), + methodBinding.selector, + methodBinding.signature(this.classFile)); +} + +protected void invoke(byte opcode, int receiverAndArgsSize, int returnTypeSize, char[] declaringClass, char[] selector, char[] signature) { + this.countLabels = 0; + if (opcode == Opcodes.OPC_invokeinterface) { + // invokeinterface + if (this.classFileOffset + 4 >= this.bCodeStream.length) { + resizeByteArray(); + } + this.position +=3; + this.bCodeStream[this.classFileOffset++] = opcode; + writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, true)); + this.bCodeStream[this.classFileOffset++] = (byte) receiverAndArgsSize; + this.bCodeStream[this.classFileOffset++] = 0; + } else { + // invokespecial + // invokestatic + // invokevirtual + if (this.classFileOffset + 2 >= this.bCodeStream.length) { + resizeByteArray(); + } + this.position++; + this.bCodeStream[this.classFileOffset++] = opcode; + writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, false)); + } + this.stackDepth += returnTypeSize - receiverAndArgsSize; if (this.stackDepth > this.stackMax) { this.stackMax = this.stackDepth; } } + protected void invokeAccessibleObjectSetAccessible() { // invokevirtual: java.lang.reflect.AccessibleObject.setAccessible(Z)V; invoke( Opcodes.OPC_invokevirtual, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JAVALANGREFLECTACCESSIBLEOBJECT_CONSTANTPOOLNAME, ConstantPool.SETACCESSIBLE_NAME, ConstantPool.SETACCESSIBLE_SIGNATURE); } + protected void invokeArrayNewInstance() { // invokestatic: java.lang.reflect.Array.newInstance(Ljava.lang.Class;int[])Ljava.lang.Object; invoke( Opcodes.OPC_invokestatic, - 2, // argCount + 2, // receiverAndArgsSize 1, // return type size ConstantPool.JAVALANGREFLECTARRAY_CONSTANTPOOLNAME, ConstantPool.NewInstance, @@ -3795,212 +3887,208 @@ } public void invokeClassForName() { // invokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class; - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class;"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 1, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangClassConstantPoolName, ConstantPool.ForName, ConstantPool.ForNameSignature); } + protected void invokeClassGetDeclaredConstructor() { // invokevirtual: java.lang.Class getDeclaredConstructor([Ljava.lang.Class)Ljava.lang.reflect.Constructor; invoke( Opcodes.OPC_invokevirtual, - 1, // argCount + 2, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangClassConstantPoolName, ConstantPool.GETDECLAREDCONSTRUCTOR_NAME, ConstantPool.GETDECLAREDCONSTRUCTOR_SIGNATURE); } + protected void invokeClassGetDeclaredField() { // invokevirtual: java.lang.Class.getDeclaredField(Ljava.lang.String)Ljava.lang.reflect.Field; invoke( Opcodes.OPC_invokevirtual, - 1, // argCount + 2, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangClassConstantPoolName, ConstantPool.GETDECLAREDFIELD_NAME, ConstantPool.GETDECLAREDFIELD_SIGNATURE); } + protected void invokeClassGetDeclaredMethod() { // invokevirtual: java.lang.Class getDeclaredMethod(Ljava.lang.String, [Ljava.lang.Class)Ljava.lang.reflect.Method; invoke( Opcodes.OPC_invokevirtual, - 2, // argCount + 3, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangClassConstantPoolName, ConstantPool.GETDECLAREDMETHOD_NAME, ConstantPool.GETDECLAREDMETHOD_SIGNATURE); } + public void invokeEnumOrdinal(char[] enumTypeConstantPoolName) { // invokevirtual: .ordinal() - if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: "+new String(enumTypeConstantPoolName)+".ordinal()"); //$NON-NLS-1$ //$NON-NLS-2$ invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size enumTypeConstantPoolName, ConstantPool.Ordinal, ConstantPool.OrdinalSignature); } -public void invokeinterface(MethodBinding methodBinding) { - if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: " + methodBinding); //$NON-NLS-1$ - this.countLabels = 0; - // initialized to 1 to take into account this immediately - int argCount = 1; - int id; - if (this.classFileOffset + 4 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position += 3; - this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokeinterface; - writeUnsignedShort( - this.constantPool.literalIndexForMethod( - methodBinding.constantPoolDeclaringClass(), - methodBinding.selector, - methodBinding.signature(this.classFile), - true)); - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) - argCount += 2; - else - argCount += 1; - this.bCodeStream[this.classFileOffset++] = (byte) argCount; - // Generate a 0 into the byte array. Like the array is already fill with 0, we just need to increment - // the number of bytes. - this.bCodeStream[this.classFileOffset++] = 0; - if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long)) { - this.stackDepth += (2 - argCount); - } else { - if (id == TypeIds.T_void) { - this.stackDepth -= argCount; - } else { - this.stackDepth += (1 - argCount); - } - } - if (this.stackDepth > this.stackMax) { - this.stackMax = this.stackDepth; - } + +public void invokeIterableIterator(TypeBinding iterableReceiverType) { + // invokevirtual/interface: .iterator() + if (iterableReceiverType.isNestedType()) { + this.classFile.recordInnerClasses(iterableReceiverType); + } + invoke( + iterableReceiverType.isInterface() ? Opcodes.OPC_invokeinterface : Opcodes.OPC_invokevirtual, + 1, // receiverAndArgsSize + 1, // returnTypeSize + iterableReceiverType.constantPoolName(), + ConstantPool.ITERATOR_NAME, + ConstantPool.ITERATOR_SIGNATURE); } + public void invokeJavaLangAssertionErrorConstructor(int typeBindingID) { // invokespecial: java.lang.AssertionError.(typeBindingID)V - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.AssertionError.(typeBindingID)V"); //$NON-NLS-1$ - int argCount = 1; - char[] signature = null; + int receiverAndArgsSize; + char[] signature; switch (typeBindingID) { case TypeIds.T_int : case TypeIds.T_byte : case TypeIds.T_short : signature = ConstantPool.IntConstrSignature; + receiverAndArgsSize = 2; break; case TypeIds.T_long : signature = ConstantPool.LongConstrSignature; - argCount = 2; + receiverAndArgsSize = 3; break; case TypeIds.T_float : signature = ConstantPool.FloatConstrSignature; + receiverAndArgsSize = 2; break; case TypeIds.T_double : signature = ConstantPool.DoubleConstrSignature; - argCount = 2; + receiverAndArgsSize = 3; break; case TypeIds.T_char : signature = ConstantPool.CharConstrSignature; + receiverAndArgsSize = 2; break; case TypeIds.T_boolean : signature = ConstantPool.BooleanConstrSignature; + receiverAndArgsSize = 2; break; case TypeIds.T_JavaLangObject : case TypeIds.T_JavaLangString : case TypeIds.T_null : signature = ConstantPool.ObjectConstrSignature; + receiverAndArgsSize = 2; break; + default: + return; // should not occur } invoke( Opcodes.OPC_invokespecial, - argCount, // argCount + receiverAndArgsSize, 0, // return type size ConstantPool.JavaLangAssertionErrorConstantPoolName, ConstantPool.Init, signature); } + public void invokeJavaLangAssertionErrorDefaultConstructor() { // invokespecial: java.lang.AssertionError.()V - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.AssertionError.()V"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokespecial, - 0, // argCount + 1, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangAssertionErrorConstantPoolName, ConstantPool.Init, ConstantPool.DefaultConstructorSignature); } + public void invokeJavaLangClassDesiredAssertionStatus() { // invokevirtual: java.lang.Class.desiredAssertionStatus()Z; - if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.Class.desiredAssertionStatus()Z;"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangClassConstantPoolName, ConstantPool.DesiredAssertionStatus, ConstantPool.DesiredAssertionStatusSignature); } + public void invokeJavaLangEnumvalueOf(ReferenceBinding binding) { // invokestatic: java.lang.Enum.valueOf(Class,String) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic: java.lang.Enum.valueOf(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 2, // argCount + 2, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangEnumConstantPoolName, ConstantPool.ValueOf, ConstantPool.ValueOfStringClassSignature); } + public void invokeJavaLangEnumValues(TypeBinding enumBinding, ArrayBinding arrayBinding) { char[] signature = "()".toCharArray(); //$NON-NLS-1$ signature = CharOperation.concat(signature, arrayBinding.constantPoolName()); - invoke(Opcodes.OPC_invokestatic, 0, 1, enumBinding.constantPoolName(), TypeConstants.VALUES, signature); + invoke( + Opcodes.OPC_invokestatic, + 0, // receiverAndArgsSize + 1, // return type size + enumBinding.constantPoolName(), + TypeConstants.VALUES, + signature); } + public void invokeJavaLangErrorConstructor() { // invokespecial: java.lang.Error(Ljava.lang.String;)V - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.Error(Ljava.lang.String;)V"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangErrorConstantPoolName, ConstantPool.Init, ConstantPool.StringConstructorSignature); } + public void invokeJavaLangReflectConstructorNewInstance() { // invokevirtual: java.lang.reflect.Constructor.newInstance([Ljava.lang.Object;)Ljava.lang.Object; invoke( Opcodes.OPC_invokevirtual, - 1, // argCount + 2, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangReflectConstructorConstantPoolName, ConstantPool.NewInstance, ConstantPool.JavaLangReflectConstructorNewInstanceSignature); } + protected void invokeJavaLangReflectFieldGetter(int typeID) { - int returnTypeSize = 1; - char[] signature = null; - char[] selector = null; + char[] selector; + char[] signature; + int returnTypeSize; switch (typeID) { case TypeIds.T_int : selector = ConstantPool.GET_INT_METHOD_NAME; signature = ConstantPool.GET_INT_METHOD_SIGNATURE; + returnTypeSize = 1; break; case TypeIds.T_byte : selector = ConstantPool.GET_BYTE_METHOD_NAME; signature = ConstantPool.GET_BYTE_METHOD_SIGNATURE; + returnTypeSize = 1; break; case TypeIds.T_short : selector = ConstantPool.GET_SHORT_METHOD_NAME; signature = ConstantPool.GET_SHORT_METHOD_SIGNATURE; + returnTypeSize = 1; break; case TypeIds.T_long : selector = ConstantPool.GET_LONG_METHOD_NAME; @@ -4010,6 +4098,7 @@ case TypeIds.T_float : selector = ConstantPool.GET_FLOAT_METHOD_NAME; signature = ConstantPool.GET_FLOAT_METHOD_SIGNATURE; + returnTypeSize = 1; break; case TypeIds.T_double : selector = ConstantPool.GET_DOUBLE_METHOD_NAME; @@ -4019,240 +4108,149 @@ case TypeIds.T_char : selector = ConstantPool.GET_CHAR_METHOD_NAME; signature = ConstantPool.GET_CHAR_METHOD_SIGNATURE; + returnTypeSize = 1; break; case TypeIds.T_boolean : selector = ConstantPool.GET_BOOLEAN_METHOD_NAME; signature = ConstantPool.GET_BOOLEAN_METHOD_SIGNATURE; + returnTypeSize = 1; break; default : selector = ConstantPool.GET_OBJECT_METHOD_NAME; signature = ConstantPool.GET_OBJECT_METHOD_SIGNATURE; + returnTypeSize = 1; break; } invoke( Opcodes.OPC_invokevirtual, - 1, // argCount + 2, // receiverAndArgsSize returnTypeSize, // return type size ConstantPool.JAVALANGREFLECTFIELD_CONSTANTPOOLNAME, selector, signature); } + protected void invokeJavaLangReflectFieldSetter(int typeID) { - int argCount = 2; - char[] signature = null; - char[] selector = null; + char[] selector; + char[] signature; + int receiverAndArgsSize; switch (typeID) { case TypeIds.T_int : selector = ConstantPool.SET_INT_METHOD_NAME; signature = ConstantPool.SET_INT_METHOD_SIGNATURE; + receiverAndArgsSize = 3; break; case TypeIds.T_byte : selector = ConstantPool.SET_BYTE_METHOD_NAME; signature = ConstantPool.SET_BYTE_METHOD_SIGNATURE; + receiverAndArgsSize = 3; break; case TypeIds.T_short : selector = ConstantPool.SET_SHORT_METHOD_NAME; signature = ConstantPool.SET_SHORT_METHOD_SIGNATURE; + receiverAndArgsSize = 3; break; case TypeIds.T_long : selector = ConstantPool.SET_LONG_METHOD_NAME; signature = ConstantPool.SET_LONG_METHOD_SIGNATURE; - argCount = 3; + receiverAndArgsSize = 4; break; case TypeIds.T_float : selector = ConstantPool.SET_FLOAT_METHOD_NAME; signature = ConstantPool.SET_FLOAT_METHOD_SIGNATURE; + receiverAndArgsSize = 3; break; case TypeIds.T_double : selector = ConstantPool.SET_DOUBLE_METHOD_NAME; signature = ConstantPool.SET_DOUBLE_METHOD_SIGNATURE; - argCount = 3; + receiverAndArgsSize = 4; break; case TypeIds.T_char : selector = ConstantPool.SET_CHAR_METHOD_NAME; signature = ConstantPool.SET_CHAR_METHOD_SIGNATURE; + receiverAndArgsSize = 3; break; case TypeIds.T_boolean : selector = ConstantPool.SET_BOOLEAN_METHOD_NAME; signature = ConstantPool.SET_BOOLEAN_METHOD_SIGNATURE; + receiverAndArgsSize = 3; break; default : selector = ConstantPool.SET_OBJECT_METHOD_NAME; signature = ConstantPool.SET_OBJECT_METHOD_SIGNATURE; + receiverAndArgsSize = 3; break; } invoke( Opcodes.OPC_invokevirtual, - argCount, // argCount + receiverAndArgsSize, 0, // return type size ConstantPool.JAVALANGREFLECTFIELD_CONSTANTPOOLNAME, selector, signature); } + public void invokeJavaLangReflectMethodInvoke() { // invokevirtual: java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object; invoke( Opcodes.OPC_invokevirtual, - 2, // argCount + 3, // receiverAndArgsSize 1, // return type size ConstantPool.JAVALANGREFLECTMETHOD_CONSTANTPOOLNAME, ConstantPool.INVOKE_METHOD_METHOD_NAME, ConstantPool.INVOKE_METHOD_METHOD_SIGNATURE); } + public void invokeJavaUtilIteratorHasNext() { // invokeinterface java.util.Iterator.hasNext()Z - if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: java.util.Iterator.hasNext()Z"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokeinterface, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaUtilIteratorConstantPoolName, ConstantPool.HasNext, ConstantPool.HasNextSignature); } + public void invokeJavaUtilIteratorNext() { // invokeinterface java.util.Iterator.next()java.lang.Object - if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: java.util.Iterator.next()java.lang.Object"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokeinterface, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaUtilIteratorConstantPoolName, ConstantPool.Next, ConstantPool.NextSignature); } + public void invokeNoClassDefFoundErrorStringConstructor() { // invokespecial: java.lang.NoClassDefFoundError.(Ljava.lang.String;)V - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.NoClassDefFoundError.(Ljava.lang.String;)V"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangNoClassDefFoundErrorConstantPoolName, ConstantPool.Init, ConstantPool.StringConstructorSignature); } + public void invokeObjectGetClass() { // invokevirtual: java.lang.Object.getClass()Ljava.lang.Class; - if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.Object.getClass()Ljava.lang.Class;"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangObjectConstantPoolName, ConstantPool.GetClass, ConstantPool.GetClassSignature); } -public void invokespecial(MethodBinding methodBinding) { - if (DEBUG) System.out.println(this.position + "\t\tinvokespecial:"+methodBinding); //$NON-NLS-1$ - this.countLabels = 0; - // initialized to 1 to take into account this immediately - int argCount = 1; - int id; - if (this.classFileOffset + 2 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position++; - this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokespecial; - writeUnsignedShort( - this.constantPool.literalIndexForMethod( - methodBinding.constantPoolDeclaringClass(), - methodBinding.selector, - methodBinding.signature(this.classFile), - false)); - if (methodBinding.isConstructor()) { - final ReferenceBinding declaringClass = methodBinding.declaringClass; - if (declaringClass.isNestedType()) { - // enclosing instances - TypeBinding[] syntheticArgumentTypes = declaringClass.syntheticEnclosingInstanceTypes(); - if (syntheticArgumentTypes != null) { - for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) { - if (((id = syntheticArgumentTypes[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) { - argCount += 2; - } else { - argCount++; - } - } - } - // outer local variables - SyntheticArgumentBinding[] syntheticArguments = declaringClass.syntheticOuterLocalVariables(); - if (syntheticArguments != null) { - for (int i = 0, max = syntheticArguments.length; i < max; i++) { - if (((id = syntheticArguments[i].type.id) == TypeIds.T_double) || (id == TypeIds.T_long)) { - argCount += 2; - } else { - argCount++; - } - } - } - } - if (declaringClass.isEnum()) { - // adding String and int - argCount += 2; - } - } - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) - argCount += 2; - else - argCount++; - if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long)) - this.stackDepth += (2 - argCount); - else - if (id == TypeIds.T_void) - this.stackDepth -= argCount; - else - this.stackDepth += (1 - argCount); - if (this.stackDepth > this.stackMax) - this.stackMax = this.stackDepth; -} -public void invokestatic(MethodBinding methodBinding) { - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic:"+methodBinding); //$NON-NLS-1$ - // initialized to 0 to take into account that there is no this for - // a static method - this.countLabels = 0; - int argCount = 0; - int id; - if (this.classFileOffset + 2 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position++; - this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokestatic; - writeUnsignedShort( - this.constantPool.literalIndexForMethod( - methodBinding.constantPoolDeclaringClass(), - methodBinding.selector, - methodBinding.signature(this.classFile), - false)); - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) - argCount += 2; - else - argCount += 1; - if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long)) - this.stackDepth += (2 - argCount); - else - if (id == TypeIds.T_void) - this.stackDepth -= argCount; - else - this.stackDepth += (1 - argCount); - if (this.stackDepth > this.stackMax) - this.stackMax = this.stackDepth; -} + /** * The equivalent code performs a string conversion of the TOS * @param typeID int */ public void invokeStringConcatenationAppendForType(int typeID) { - if (DEBUG) { - if (this.targetLevel >= ClassFileConstants.JDK1_5) { - System.out.println(this.position + "\t\tinvokevirtual: java.lang.StringBuilder.append(...)"); //$NON-NLS-1$ - } else { - System.out.println(this.position + "\t\tinvokevirtual: java.lang.StringBuffer.append(...)"); //$NON-NLS-1$ - } - } - int argCount = 1; - int returnType = 1; + int receiverAndArgsSize; char[] declaringClass = null; char[] selector = ConstantPool.Append; char[] signature = null; @@ -4267,6 +4265,7 @@ declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; signature = ConstantPool.StringBufferAppendIntSignature; } + receiverAndArgsSize = 2; break; case TypeIds.T_long : if (this.targetLevel >= ClassFileConstants.JDK1_5) { @@ -4276,7 +4275,7 @@ declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; signature = ConstantPool.StringBufferAppendLongSignature; } - argCount = 2; + receiverAndArgsSize = 3; break; case TypeIds.T_float : if (this.targetLevel >= ClassFileConstants.JDK1_5) { @@ -4286,6 +4285,7 @@ declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; signature = ConstantPool.StringBufferAppendFloatSignature; } + receiverAndArgsSize = 2; break; case TypeIds.T_double : if (this.targetLevel >= ClassFileConstants.JDK1_5) { @@ -4295,7 +4295,7 @@ declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; signature = ConstantPool.StringBufferAppendDoubleSignature; } - argCount = 2; + receiverAndArgsSize = 3; break; case TypeIds.T_char : if (this.targetLevel >= ClassFileConstants.JDK1_5) { @@ -4305,6 +4305,7 @@ declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; signature = ConstantPool.StringBufferAppendCharSignature; } + receiverAndArgsSize = 2; break; case TypeIds.T_boolean : if (this.targetLevel >= ClassFileConstants.JDK1_5) { @@ -4314,207 +4315,180 @@ declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; signature = ConstantPool.StringBufferAppendBooleanSignature; } + receiverAndArgsSize = 2; break; - case TypeIds.T_undefined : - case TypeIds.T_JavaLangObject : - case TypeIds.T_null : + case TypeIds.T_JavaLangString : if (this.targetLevel >= ClassFileConstants.JDK1_5) { declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName; - signature = ConstantPool.StringBuilderAppendObjectSignature; + signature = ConstantPool.StringBuilderAppendStringSignature; } else { declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; - signature = ConstantPool.StringBufferAppendObjectSignature; + signature = ConstantPool.StringBufferAppendStringSignature; } + receiverAndArgsSize = 2; break; - case TypeIds.T_JavaLangString : + default : if (this.targetLevel >= ClassFileConstants.JDK1_5) { declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName; - signature = ConstantPool.StringBuilderAppendStringSignature; + signature = ConstantPool.StringBuilderAppendObjectSignature; } else { declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; - signature = ConstantPool.StringBufferAppendStringSignature; + signature = ConstantPool.StringBufferAppendObjectSignature; } + receiverAndArgsSize = 2; break; } invoke( Opcodes.OPC_invokevirtual, - argCount, // argCount - returnType, // return type size + receiverAndArgsSize, + 1, // return type size declaringClass, selector, signature); } + public void invokeStringConcatenationDefaultConstructor() { // invokespecial: java.lang.StringBuffer.()V - if (DEBUG) { - if (this.targetLevel >= ClassFileConstants.JDK1_5) { - System.out.println(this.position + "\t\tinvokespecial: java.lang.StringBuilder.()V"); //$NON-NLS-1$ - } else { - System.out.println(this.position + "\t\tinvokespecial: java.lang.StringBuffer.()V"); //$NON-NLS-1$ - } - } - char[] declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; - if (this.targetLevel >= ClassFileConstants.JDK1_5) { + // or invokespecial: java.lang.StringBuilder.()V + char[] declaringClass; + if (this.targetLevel < ClassFileConstants.JDK1_5) { + declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; + } else { declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName; } invoke( Opcodes.OPC_invokespecial, - 0, // argCount + 1, // receiverAndArgsSize 0, // return type size declaringClass, ConstantPool.Init, ConstantPool.DefaultConstructorSignature); } + public void invokeStringConcatenationStringConstructor() { - if (DEBUG) { - if (this.targetLevel >= ClassFileConstants.JDK1_5) { - System.out.println(this.position + "\t\tjava.lang.StringBuilder.(Ljava.lang.String;)V"); //$NON-NLS-1$ - } else { - System.out.println(this.position + "\t\tjava.lang.StringBuffer.(Ljava.lang.String;)V"); //$NON-NLS-1$ - } - } - char[] declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; - if (this.targetLevel >= ClassFileConstants.JDK1_5) { + // invokespecial: java.lang.StringBuffer.(java.lang.String)V + // or invokespecial: java.lang.StringBuilder.(java.lang.String)V + char[] declaringClass; + if (this.targetLevel < ClassFileConstants.JDK1_5) { + // invokespecial: java.lang.StringBuffer.()V + declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; + } else { + // invokespecial: java.lang.StringStringBuilder.(java.langString)V declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName; } invoke( Opcodes.OPC_invokespecial, - 1, // argCount + 2, // receiverAndArgsSize 0, // return type size declaringClass, ConstantPool.Init, ConstantPool.StringConstructorSignature); } + public void invokeStringConcatenationToString() { - if (DEBUG) { - if (this.targetLevel >= ClassFileConstants.JDK1_5) { - System.out.println(this.position + "\t\tinvokevirtual: StringBuilder.toString()Ljava.lang.String;"); //$NON-NLS-1$ - } else { - System.out.println(this.position + "\t\tinvokevirtual: StringBuffer.toString()Ljava.lang.String;"); //$NON-NLS-1$ - } - } - char[] declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; - if (this.targetLevel >= ClassFileConstants.JDK1_5) { + // invokespecial: java.lang.StringBuffer.toString()java.lang.String + // or invokespecial: java.lang.StringBuilder.toString()java.lang.String + char[] declaringClass; + if (this.targetLevel < ClassFileConstants.JDK1_5) { + // invokespecial: java.lang.StringBuffer.()V + declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName; + } else { + // invokespecial: java.lang.StringStringBuilder.(java.langString)V declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName; - } + } invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size declaringClass, ConstantPool.ToString, ConstantPool.ToStringSignature); } + public void invokeStringIntern() { // invokevirtual: java.lang.String.intern() - if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.String.intern()"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangStringConstantPoolName, ConstantPool.Intern, ConstantPool.InternSignature); } + public void invokeStringValueOf(int typeID) { // invokestatic: java.lang.String.valueOf(argumentType) - if (DEBUG) System.out.println(this.position + "\t\tinvokestatic: java.lang.String.valueOf(...)"); //$NON-NLS-1$ - int argCount = 1; - char[] signature = null; + char[] signature; + int receiverAndArgsSize; switch (typeID) { case TypeIds.T_int : case TypeIds.T_byte : case TypeIds.T_short : signature = ConstantPool.ValueOfIntSignature; + receiverAndArgsSize = 1; break; case TypeIds.T_long : signature = ConstantPool.ValueOfLongSignature; - argCount = 2; + receiverAndArgsSize = 2; break; case TypeIds.T_float : signature = ConstantPool.ValueOfFloatSignature; + receiverAndArgsSize = 1; break; case TypeIds.T_double : signature = ConstantPool.ValueOfDoubleSignature; - argCount = 2; + receiverAndArgsSize = 2; break; case TypeIds.T_char : signature = ConstantPool.ValueOfCharSignature; + receiverAndArgsSize = 1; break; case TypeIds.T_boolean : signature = ConstantPool.ValueOfBooleanSignature; + receiverAndArgsSize = 1; break; case TypeIds.T_JavaLangObject : case TypeIds.T_JavaLangString : case TypeIds.T_null : case TypeIds.T_undefined : signature = ConstantPool.ValueOfObjectSignature; + receiverAndArgsSize = 1; break; + default : + return; // should not occur } invoke( Opcodes.OPC_invokestatic, - argCount, // argCount + receiverAndArgsSize, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangStringConstantPoolName, ConstantPool.ValueOf, signature); } + public void invokeSystemArraycopy() { // invokestatic #21 - if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokestatic, - 5, // argCount + 5, // receiverAndArgsSize 0, // return type size ConstantPool.JavaLangSystemConstantPoolName, ConstantPool.ArrayCopy, ConstantPool.ArrayCopySignature); } + public void invokeThrowableGetMessage() { // invokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String; - if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String;"); //$NON-NLS-1$ invoke( Opcodes.OPC_invokevirtual, - 0, // argCount + 1, // receiverAndArgsSize 1, // return type size ConstantPool.JavaLangThrowableConstantPoolName, ConstantPool.GetMessage, ConstantPool.GetMessageSignature); } -public void invokevirtual(MethodBinding methodBinding) { - if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual:"+methodBinding); //$NON-NLS-1$ - this.countLabels = 0; - // initialized to 1 to take into account this immediately - int argCount = 1; - int id; - if (this.classFileOffset + 2 >= this.bCodeStream.length) { - resizeByteArray(); - } - this.position++; - this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokevirtual; - writeUnsignedShort( - this.constantPool.literalIndexForMethod( - methodBinding.constantPoolDeclaringClass(), - methodBinding.selector, - methodBinding.signature(this.classFile), - false)); - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) - argCount += 2; - else - argCount++; - if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long)) - this.stackDepth += (2 - argCount); - else - if (id == TypeIds.T_void) - this.stackDepth -= argCount; - else - this.stackDepth += (1 - argCount); - if (this.stackDepth > this.stackMax) - this.stackMax = this.stackDepth; -} + public void ior() { - if (DEBUG) System.out.println(this.position + "\t\tior"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4523,8 +4497,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ior; } + public void irem() { - if (DEBUG) System.out.println(this.position + "\t\tirem"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4533,8 +4507,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_irem; } + public void ireturn() { - if (DEBUG) System.out.println(this.position + "\t\tireturn"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; // the stackDepth should be equal to 0 @@ -4545,6 +4519,7 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ireturn; this.lastAbruptCompletion = this.position; } + public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) { // Mirror of UnconditionalFlowInfo.isDefinitelyAssigned(..) if ((local.tagBits & TagBits.IsArgument) != 0) { @@ -4567,8 +4542,8 @@ return false; // if not enough room in vector, then not initialized return ((extraInits[vectorIndex]) & (1L << (localPosition % UnconditionalFlowInfo.BitCacheSize))) != 0; } + public void ishl() { - if (DEBUG) System.out.println(this.position + "\t\tishl"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4577,8 +4552,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ishl; } + public void ishr() { - if (DEBUG) System.out.println(this.position + "\t\tishr"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4587,8 +4562,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ishr; } + public void istore(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tistore:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= iArg) { @@ -4611,8 +4586,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void istore_0() { - if (DEBUG) System.out.println(this.position + "\t\tistore_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals == 0) { @@ -4624,8 +4599,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_0; } + public void istore_1() { - if (DEBUG) System.out.println(this.position + "\t\tistore_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 1) { @@ -4637,8 +4612,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_1; } + public void istore_2() { - if (DEBUG) System.out.println(this.position + "\t\tistore_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 2) { @@ -4650,8 +4625,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_2; } + public void istore_3() { - if (DEBUG) System.out.println(this.position + "\t\tistore_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.maxLocals <= 3) { @@ -4663,8 +4638,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_3; } + public void isub() { - if (DEBUG) System.out.println(this.position + "\t\tisub"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4673,8 +4648,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_isub; } + public void iushr() { - if (DEBUG) System.out.println(this.position + "\t\tiushr"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4683,8 +4658,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iushr; } + public void ixor() { - if (DEBUG) System.out.println(this.position + "\t\tixor"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4693,12 +4668,12 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ixor; } + final public void jsr(BranchLabel lbl) { if (this.wideMode) { jsr_w(lbl); return; } - if (DEBUG) System.out.println(this.position + "\t\tjsr"+lbl); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -4707,8 +4682,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr; lbl.branch(); } + final public void jsr_w(BranchLabel lbl) { - if (DEBUG) System.out.println(this.position + "\t\tjsr_w"+lbl); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -4717,8 +4692,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr_w; lbl.branchWide(); } + public void l2d() { - if (DEBUG) System.out.println(this.position + "\t\tl2d"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -4726,8 +4701,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2d; } + public void l2f() { - if (DEBUG) System.out.println(this.position + "\t\tl2f"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4736,8 +4711,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2f; } + public void l2i() { - if (DEBUG) System.out.println(this.position + "\t\tl2i"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4746,8 +4721,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2i; } + public void ladd() { - if (DEBUG) System.out.println(this.position + "\t\tladd"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4756,8 +4731,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ladd; } + public void laload() { - if (DEBUG) System.out.println(this.position + "\t\tlaload"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -4765,8 +4740,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_laload; } + public void land() { - if (DEBUG) System.out.println(this.position + "\t\tland"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4775,8 +4750,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_land; } + public void lastore() { - if (DEBUG) System.out.println(this.position + "\t\tlastore"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 4; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4785,8 +4760,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lastore; } + public void lcmp() { - if (DEBUG) System.out.println(this.position + "\t\tlcmp"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -4795,8 +4770,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lcmp; } + public void lconst_0() { - if (DEBUG) System.out.println(this.position + "\t\tlconst_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -4807,8 +4782,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lconst_0; } + public void lconst_1() { - if (DEBUG) System.out.println(this.position + "\t\tlconst_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.stackDepth > this.stackMax) @@ -4819,6 +4794,7 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lconst_1; } + public void ldc(float constant) { this.countLabels = 0; int index = this.constantPool.literalIndex(constant); @@ -4826,7 +4802,6 @@ if (this.stackDepth > this.stackMax) this.stackMax = this.stackDepth; if (index > 255) { - if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+constant); //$NON-NLS-1$ // Generate a ldc_w if (this.classFileOffset + 2 >= this.bCodeStream.length) { resizeByteArray(); @@ -4835,7 +4810,6 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w; writeUnsignedShort(index); } else { - if (DEBUG) System.out.println(this.position + "\t\tldc:"+constant); //$NON-NLS-1$ // Generate a ldc if (this.classFileOffset + 1 >= this.bCodeStream.length) { resizeByteArray(); @@ -4845,6 +4819,7 @@ this.bCodeStream[this.classFileOffset++] = (byte) index; } } + public void ldc(int constant) { this.countLabels = 0; int index = this.constantPool.literalIndex(constant); @@ -4852,7 +4827,6 @@ if (this.stackDepth > this.stackMax) this.stackMax = this.stackDepth; if (index > 255) { - if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+constant); //$NON-NLS-1$ // Generate a ldc_w if (this.classFileOffset + 2 >= this.bCodeStream.length) { resizeByteArray(); @@ -4861,7 +4835,6 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w; writeUnsignedShort(index); } else { - if (DEBUG) System.out.println(this.position + "\t\tldc:"+constant); //$NON-NLS-1$ // Generate a ldc if (this.classFileOffset + 1 >= this.bCodeStream.length) { resizeByteArray(); @@ -4871,6 +4844,7 @@ this.bCodeStream[this.classFileOffset++] = (byte) index; } } + public void ldc(String constant) { this.countLabels = 0; int currentCodeStreamPosition = this.position; @@ -4969,6 +4943,7 @@ invokeStringIntern(); } } + public void ldc(TypeBinding typeBinding) { this.countLabels = 0; int index = this.constantPool.literalIndexForType(typeBinding); @@ -4976,7 +4951,6 @@ if (this.stackDepth > this.stackMax) this.stackMax = this.stackDepth; if (index > 255) { - if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+ typeBinding); //$NON-NLS-1$ // Generate a ldc_w if (this.classFileOffset + 2 >= this.bCodeStream.length) { resizeByteArray(); @@ -4985,7 +4959,6 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w; writeUnsignedShort(index); } else { - if (DEBUG) System.out.println(this.position + "\t\tldw:"+ typeBinding); //$NON-NLS-1$ // Generate a ldc if (this.classFileOffset + 1 >= this.bCodeStream.length) { resizeByteArray(); @@ -4995,8 +4968,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) index; } } + public void ldc2_w(double constant) { - if (DEBUG) System.out.println(this.position + "\t\tldc2_w:"+constant); //$NON-NLS-1$ this.countLabels = 0; int index = this.constantPool.literalIndex(constant); this.stackDepth += 2; @@ -5010,8 +4983,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc2_w; writeUnsignedShort(index); } + public void ldc2_w(long constant) { - if (DEBUG) System.out.println(this.position + "\t\tldc2_w:"+constant); //$NON-NLS-1$ this.countLabels = 0; int index = this.constantPool.literalIndex(constant); this.stackDepth += 2; @@ -5025,6 +4998,7 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc2_w; writeUnsignedShort(index); } + public void ldcForIndex(int index, char[] constant) { this.stackDepth++; if (this.stackDepth > this.stackMax) { @@ -5032,7 +5006,6 @@ } if (index > 255) { // Generate a ldc_w - if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+ new String(constant)); //$NON-NLS-1$ if (this.classFileOffset + 2 >= this.bCodeStream.length) { resizeByteArray(); } @@ -5041,7 +5014,6 @@ writeUnsignedShort(index); } else { // Generate a ldc - if (DEBUG) System.out.println(this.position + "\t\tldc:"+ new String(constant)); //$NON-NLS-1$ if (this.classFileOffset + 1 >= this.bCodeStream.length) { resizeByteArray(); } @@ -5050,8 +5022,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) index; } } + public void ldiv() { - if (DEBUG) System.out.println(this.position + "\t\tldiv"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5060,8 +5032,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldiv; } + public void lload(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tlload:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.maxLocals <= iArg + 1) { @@ -5086,8 +5058,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void lload_0() { - if (DEBUG) System.out.println(this.position + "\t\tlload_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.maxLocals < 2) { @@ -5101,8 +5073,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_0; } + public void lload_1() { - if (DEBUG) System.out.println(this.position + "\t\tlload_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.maxLocals < 3) { @@ -5116,8 +5088,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_1; } + public void lload_2() { - if (DEBUG) System.out.println(this.position + "\t\tlload_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.maxLocals < 4) { @@ -5131,8 +5103,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_2; } + public void lload_3() { - if (DEBUG) System.out.println(this.position + "\t\tlload_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth += 2; if (this.maxLocals < 5) { @@ -5146,8 +5118,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_3; } + public void lmul() { - if (DEBUG) System.out.println(this.position + "\t\tlmul"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5156,8 +5128,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lmul; } + public void lneg() { - if (DEBUG) System.out.println(this.position + "\t\tlneg"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -5165,9 +5137,11 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lneg; } + public final void load(LocalVariableBinding localBinding) { load(localBinding.type, localBinding.resolvedPosition); } + public final void load(TypeBinding typeBinding, int resolvedPosition) { this.countLabels = 0; // Using dedicated int bytecode @@ -5270,8 +5244,8 @@ } } } + public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { - if (DEBUG) System.out.println(this.position + "\t\tlookupswitch"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; int length = keys.length; @@ -5299,8 +5273,8 @@ casesLabel[sortedIndexes[i]].branch(); } } + public void lor() { - if (DEBUG) System.out.println(this.position + "\t\tlor"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5309,8 +5283,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lor; } + public void lrem() { - if (DEBUG) System.out.println(this.position + "\t\tlrem"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5319,8 +5293,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lrem; } + public void lreturn() { - if (DEBUG) System.out.println(this.position + "\t\tlreturn"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; // the stackDepth should be equal to 0 @@ -5331,8 +5305,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lreturn; this.lastAbruptCompletion = this.position; } + public void lshl() { - if (DEBUG) System.out.println(this.position + "\t\tlshl"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5341,8 +5315,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lshl; } + public void lshr() { - if (DEBUG) System.out.println(this.position + "\t\tlshr"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5351,8 +5325,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lshr; } + public void lstore(int iArg) { - if (DEBUG) System.out.println(this.position + "\t\tlstore:"+iArg); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals <= iArg + 1) { @@ -5375,8 +5349,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) iArg; } } + public void lstore_0() { - if (DEBUG) System.out.println(this.position + "\t\tlstore_0"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 2) { @@ -5388,8 +5362,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_0; } + public void lstore_1() { - if (DEBUG) System.out.println(this.position + "\t\tlstore_1"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 3) { @@ -5401,8 +5375,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_1; } + public void lstore_2() { - if (DEBUG) System.out.println(this.position + "\t\tlstore_2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 4) { @@ -5414,8 +5388,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_2; } + public void lstore_3() { - if (DEBUG) System.out.println(this.position + "\t\tlstore_3"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.maxLocals < 5) { @@ -5427,8 +5401,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_3; } + public void lsub() { - if (DEBUG) System.out.println(this.position + "\t\tlsub"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5437,8 +5411,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lsub; } + public void lushr() { - if (DEBUG) System.out.println(this.position + "\t\tlushr"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5447,8 +5421,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lushr; } + public void lxor() { - if (DEBUG) System.out.println(this.position + "\t\tlxor"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5457,8 +5431,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lxor; } + public void monitorenter() { - if (DEBUG) System.out.println(this.position + "\t\tmonitorenter"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5467,8 +5441,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_monitorenter; } + public void monitorexit() { - if (DEBUG) System.out.println(this.position + "\t\tmonitorexit"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5477,8 +5451,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_monitorexit; } + public void multianewarray(TypeBinding typeBinding, int dimensions) { - if (DEBUG) System.out.println(this.position + "\t\tmultinewarray:"+typeBinding+","+dimensions); //$NON-NLS-1$ //$NON-NLS-2$ this.countLabels = 0; this.stackDepth += (1 - dimensions); if (this.classFileOffset + 3 >= this.bCodeStream.length) { @@ -5489,9 +5463,9 @@ writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding)); this.bCodeStream[this.classFileOffset++] = (byte) dimensions; } + // We didn't call it new, because there is a conflit with the new keyword public void new_(TypeBinding typeBinding) { - if (DEBUG) System.out.println(this.position + "\t\tnew:"+typeBinding.debugName()); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -5503,8 +5477,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new; writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding)); } + public void newarray(int array_Type) { - if (DEBUG) System.out.println(this.position + "\t\tnewarray:"+array_Type); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset + 1 >= this.bCodeStream.length) { resizeByteArray(); @@ -5513,6 +5487,7 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_newarray; this.bCodeStream[this.classFileOffset++] = (byte) array_Type; } + public void newArray(ArrayBinding arrayBinding) { TypeBinding component = arrayBinding.elementsType(); switch (component.id) { @@ -5544,9 +5519,9 @@ anewarray(component); } } + public void newJavaLangAssertionError() { // new: java.lang.AssertionError - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.AssertionError"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -5558,9 +5533,9 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new; writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangAssertionErrorConstantPoolName)); } + public void newJavaLangError() { // new: java.lang.Error - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Error"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -5572,9 +5547,9 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new; writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangErrorConstantPoolName)); } + public void newNoClassDefFoundError() { // new: java.lang.NoClassDefFoundError - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.NoClassDefFoundError"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -5586,16 +5561,10 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new; writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangNoClassDefFoundErrorConstantPoolName)); } + public void newStringContatenation() { // new: java.lang.StringBuffer // new: java.lang.StringBuilder - if (DEBUG) { - if (this.targetLevel >= ClassFileConstants.JDK1_5) { - System.out.println(this.position + "\t\tnew: java.lang.StringBuilder"); //$NON-NLS-1$ - } else { - System.out.println(this.position + "\t\tnew: java.lang.StringBuffer"); //$NON-NLS-1$ - } - } this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) { @@ -5612,6 +5581,7 @@ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangStringBufferConstantPoolName)); } } + public void newWrapperFor(int typeID) { this.countLabels = 0; this.stackDepth++; @@ -5624,44 +5594,35 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new; switch (typeID) { case TypeIds.T_int : // new: java.lang.Integer - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Integer"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangIntegerConstantPoolName)); break; case TypeIds.T_boolean : // new: java.lang.Boolean - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Boolean"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangBooleanConstantPoolName)); break; case TypeIds.T_byte : // new: java.lang.Byte - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Byte"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangByteConstantPoolName)); break; case TypeIds.T_char : // new: java.lang.Character - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Character"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangCharacterConstantPoolName)); break; case TypeIds.T_float : // new: java.lang.Float - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Float"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangFloatConstantPoolName)); break; case TypeIds.T_double : // new: java.lang.Double - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Double"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangDoubleConstantPoolName)); break; case TypeIds.T_short : // new: java.lang.Short - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Short"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangShortConstantPoolName)); break; case TypeIds.T_long : // new: java.lang.Long - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Long"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangLongConstantPoolName)); break; case TypeIds.T_void : // new: java.lang.Void - if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Void"); //$NON-NLS-1$ writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangVoidConstantPoolName)); } } + public void nop() { - if (DEBUG) System.out.println(this.position + "\t\tnop"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -5669,6 +5630,7 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_nop; } + public void optimizeBranch(int oldPosition, BranchLabel lbl) { for (int i = 0; i < this.countLabels; i++) { BranchLabel label = this.labels[i]; @@ -5691,8 +5653,8 @@ } } } + public void pop() { - if (DEBUG) System.out.println(this.position + "\t\tpop"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5701,8 +5663,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_pop; } + public void pop2() { - if (DEBUG) System.out.println(this.position + "\t\tpop2"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 2; if (this.classFileOffset >= this.bCodeStream.length) { @@ -5711,17 +5673,19 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_pop2; } -public void pushOnStack(TypeBinding binding) { - if (++this.stackDepth > this.stackMax) - this.stackMax = this.stackDepth; -} + public void pushExceptionOnStack(TypeBinding binding) { this.stackDepth = 1; if (this.stackDepth > this.stackMax) this.stackMax = this.stackDepth; } + +public void pushOnStack(TypeBinding binding) { + if (++this.stackDepth > this.stackMax) + this.stackMax = this.stackDepth; +} + public void putfield(FieldBinding fieldBinding) { - if (DEBUG) System.out.println(this.position + "\t\tputfield:"+fieldBinding); //$NON-NLS-1$ int returnTypeSize = 1; if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) { returnTypeSize = 2; @@ -5733,8 +5697,8 @@ fieldBinding.name, fieldBinding.type); } + public void putstatic(FieldBinding fieldBinding) { - if (DEBUG) System.out.println(this.position + "\t\tputstatic:"+fieldBinding); //$NON-NLS-1$ int returnTypeSize = 1; if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) { returnTypeSize = 2; @@ -5746,6 +5710,7 @@ fieldBinding.name, fieldBinding.type); } + public void record(LocalVariableBinding local) { if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP_TABLE @@ -5763,17 +5728,17 @@ public void recordExpressionType(TypeBinding typeBinding) { // nothing to do } + public void recordPositionsFrom(int startPC, int sourcePos) { this.recordPositionsFrom(startPC, sourcePos, false); } -public void recordPositionsFrom(int startPC, int sourcePos, boolean widen) { +public void recordPositionsFrom(int startPC, int sourcePos, boolean widen) { /* Record positions in the table, only if nothing has * already been recorded. Since we output them on the way * up (children first for more specific info) * The pcToSourceMap table is always sorted. */ - if ((this.generateAttributes & ClassFileConstants.ATTR_LINES) == 0 || sourcePos == 0 || (startPC == this.position && !widen)) @@ -6099,6 +6064,7 @@ this.lastEntryPC = this.position; } } + /** * @param anExceptionLabel org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel */ @@ -6111,6 +6077,7 @@ // no need to resize. So just add the new exception label this.exceptionLabels[this.exceptionLabelsCounter++] = anExceptionLabel; } + public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) { // given some flow info, make sure we did not loose some variables initialization // if this happens, then we must update their pc entries to reflect it in debug attributes @@ -6125,6 +6092,7 @@ } } } + /** * Remove all entries in pcToSourceMap table that are beyond this.position */ @@ -6148,6 +6116,7 @@ } } } + /** * @param referenceMethod org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration * @param targetClassFile org.eclipse.jdt.internal.compiler.codegen.ClassFile @@ -6180,6 +6149,7 @@ this.preserveUnusedLocals = referenceMethod.scope.compilerOptions().preserveAllLocalVariables; initializeMaxLocals(referenceMethod.binding); } + public void reset(ClassFile givenClassFile) { this.targetLevel = givenClassFile.targetJDK; int produceAttributes = givenClassFile.produceAttributes; @@ -6190,6 +6160,7 @@ this.lineSeparatorPositions = null; } } + /** * @param targetClassFile The given classfile to reset the code stream */ @@ -6197,6 +6168,11 @@ init(targetClassFile); initializeMaxLocals(null); } + +public void resetInWideMode() { + this.wideMode = true; +} + private final void resizeByteArray() { int length = this.bCodeStream.length; int requiredSize = length + length; @@ -6206,8 +6182,8 @@ } System.arraycopy(this.bCodeStream, 0, this.bCodeStream = new byte[requiredSize], 0, length); } + final public void ret(int index) { - if (DEBUG) System.out.println(this.position + "\t\tret:"+index); //$NON-NLS-1$ this.countLabels = 0; if (index > 255) { // Widen if (this.classFileOffset + 3 >= this.bCodeStream.length) { @@ -6226,8 +6202,8 @@ this.bCodeStream[this.classFileOffset++] = (byte) index; } } + public void return_() { - if (DEBUG) System.out.println(this.position + "\t\treturn"); //$NON-NLS-1$ this.countLabels = 0; // the stackDepth should be equal to 0 if (this.classFileOffset >= this.bCodeStream.length) { @@ -6237,8 +6213,8 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_return; this.lastAbruptCompletion = this.position; } + public void saload() { - if (DEBUG) System.out.println(this.position + "\t\tsaload"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; if (this.classFileOffset >= this.bCodeStream.length) { @@ -6247,8 +6223,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_saload; } + public void sastore() { - if (DEBUG) System.out.println(this.position + "\t\tsastore"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth -= 3; if (this.classFileOffset >= this.bCodeStream.length) { @@ -6257,6 +6233,7 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_sastore; } + /** * @param operatorConstant int * @param type_ID int @@ -6380,7 +6357,6 @@ } public void sipush(int s) { - if (DEBUG) System.out.println(this.position + "\t\tsipush:"+s); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth++; if (this.stackDepth > this.stackMax) @@ -6392,6 +6368,7 @@ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_sipush; writeSignedShort(s); } + public void store(LocalVariableBinding localBinding, boolean valueRequired) { int localPosition = localBinding.resolvedPosition; // Using dedicated int bytecode @@ -6505,8 +6482,8 @@ } } } + public void swap() { - if (DEBUG) System.out.println(this.position + "\t\tswap"); //$NON-NLS-1$ this.countLabels = 0; if (this.classFileOffset >= this.bCodeStream.length) { resizeByteArray(); @@ -6514,8 +6491,8 @@ this.position++; this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_swap; } + public void tableswitch(CaseLabel defaultLabel, int low, int high, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { - if (DEBUG) System.out.println(this.position + "\t\ttableswitch"); //$NON-NLS-1$ this.countLabels = 0; this.stackDepth--; int length = casesLabel.length; @@ -6555,10 +6532,12 @@ i++; } } + public void throwAnyException(LocalVariableBinding anyExceptionVariable) { this.load(anyExceptionVariable); athrow(); } + public String toString() { StringBuffer buffer = new StringBuffer("( position:"); //$NON-NLS-1$ buffer.append(this.position); @@ -6571,6 +6550,7 @@ buffer.append(")"); //$NON-NLS-1$ return buffer.toString(); } + /** * Note: it will walk the locals table and extend the end range for all matching ones, no matter if * visible or not. @@ -6609,6 +6589,7 @@ } } } + protected void writePosition(BranchLabel label) { int offset = label.position - this.position + 1; if (Math.abs(offset) > 0x7FFF && !this.wideMode) { @@ -6620,6 +6601,7 @@ this.writePosition(label, forwardRefs[i]); } } + protected void writePosition(BranchLabel label, int forwardReference) { final int offset = label.position - forwardReference + 1; if (Math.abs(offset) > 0x7FFF && !this.wideMode) { @@ -6635,6 +6617,7 @@ this.writeSignedShort(forwardReference, offset); } } + /** * Write a signed 16 bits value into the byte array * @param value the signed short @@ -6648,6 +6631,7 @@ this.bCodeStream[this.classFileOffset++] = (byte) (value >> 8); this.bCodeStream[this.classFileOffset++] = (byte) value; } + private final void writeSignedShort(int pos, int value) { int currentOffset = this.startingClassFileOffset + pos; if (currentOffset + 1 >= this.bCodeStream.length) { @@ -6656,6 +6640,7 @@ this.bCodeStream[currentOffset] = (byte) (value >> 8); this.bCodeStream[currentOffset + 1] = (byte) value; } + protected final void writeSignedWord(int value) { // we keep the resize in here because it is used outside the code stream if (this.classFileOffset + 3 >= this.bCodeStream.length) { @@ -6667,6 +6652,7 @@ this.bCodeStream[this.classFileOffset++] = (byte) ((value & 0xFF00) >> 8); this.bCodeStream[this.classFileOffset++] = (byte) (value & 0xFF); } + protected void writeSignedWord(int pos, int value) { int currentOffset = this.startingClassFileOffset + pos; if (currentOffset + 3 >= this.bCodeStream.length) { @@ -6677,6 +6663,7 @@ this.bCodeStream[currentOffset++] = (byte) ((value & 0xFF00) >> 8); this.bCodeStream[currentOffset++] = (byte) (value & 0xFF); } + /** * Write a unsigned 16 bits value into the byte array * @param value the unsigned short @@ -6687,6 +6674,7 @@ this.bCodeStream[this.classFileOffset++] = (byte) (value >>> 8); this.bCodeStream[this.classFileOffset++] = (byte) value; } + protected void writeWidePosition(BranchLabel label) { int labelPos = label.position; int offset = labelPos - this.position + 1; @@ -6698,7 +6686,4 @@ this.writeSignedWord(forward, offset); } } -public void resetInWideMode() { - this.wideMode = true; -} } Index: compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java,v retrieving revision 1.19 diff -u -r1.19 ExceptionLabel.java --- compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java 27 Jun 2008 16:04:03 -0000 1.19 +++ compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java 16 Sep 2008 13:07:37 -0000 @@ -27,7 +27,6 @@ public void place() { // register the handler inside the codeStream then normal place this.codeStream.registerExceptionHandler(this); - if (CodeStream.DEBUG) System.out.println("\t\t\t\t [new field value][owner][new field value] if (valueRequired) { @@ -57,7 +57,7 @@ if (syntheticWriteAccessor == null) { codeStream.putfield(fieldBinding); } else { - codeStream.invokestatic(syntheticWriteAccessor); + codeStream.invoke(Opcodes.OPC_invokestatic, syntheticWriteAccessor, null /* default declaringClass */); } } codeStream.recordPositionsFrom(pc, this.sourceStart); Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v retrieving revision 1.109 diff -u -r1.109 SingleNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 12 Sep 2008 13:28:53 -0000 1.109 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 16 Sep 2008 13:07:36 -0000 @@ -14,6 +14,7 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -377,7 +378,7 @@ if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) { codeStream.getstatic(fieldBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */); } } else { if (!valueRequired @@ -399,7 +400,7 @@ if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) { codeStream.getfield(fieldBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */); } } break; @@ -474,7 +475,7 @@ if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) { codeStream.getstatic(fieldBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */); } } else { if ((this.bits & ASTNode.DepthMASK) != 0) { @@ -488,7 +489,7 @@ if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) { codeStream.getfield(fieldBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */); } } break; @@ -587,7 +588,7 @@ if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) { codeStream.getstatic(fieldBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */); } } else { if ((this.bits & ASTNode.DepthMASK) != 0) { @@ -601,7 +602,7 @@ if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) { codeStream.getfield(fieldBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */); } } TypeBinding operandType; Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v retrieving revision 1.89 diff -u -r1.89 QualifiedAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 27 Jun 2008 16:03:56 -0000 1.89 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 16 Sep 2008 13:07:36 -0000 @@ -13,6 +13,7 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.Constant; @@ -138,7 +139,7 @@ // invoke constructor if (this.syntheticAccessor == null) { - codeStream.invokespecial(this.codegenBinding); + codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */); } else { // synthetic accessor got some extra arguments appended to its signature, which need values for (int i = 0, @@ -147,7 +148,7 @@ i++) { codeStream.aconst_null(); } - codeStream.invokespecial(this.syntheticAccessor); + codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */); } if (valueRequired) { codeStream.generateImplicitConversion(this.implicitConversion); Index: compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java,v retrieving revision 1.73 diff -u -r1.73 SwitchStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 27 Jun 2008 16:03:54 -0000 1.73 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 16 Sep 2008 13:07:36 -0000 @@ -156,7 +156,7 @@ if (resolvedType.isEnum()) { if (needSwitch) { // go through the translation table - codeStream.invokestatic(this.synthetic); + codeStream.invoke(Opcodes.OPC_invokestatic, this.synthetic, null /* default declaringClass */); this.expression.generateCode(currentScope, codeStream, true); // get enum constant ordinal() codeStream.invokeEnumOrdinal(resolvedType.constantPoolName()); Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v retrieving revision 1.74 diff -u -r1.74 AllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 27 Jun 2008 16:03:55 -0000 1.74 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 16 Sep 2008 13:07:35 -0000 @@ -115,7 +115,7 @@ } // invoke constructor if (this.syntheticAccessor == null) { - codeStream.invokespecial(this.codegenBinding); + codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */); } else { // synthetic accessor got some extra arguments appended to its signature, which need values for (int i = 0, @@ -124,7 +124,7 @@ i++) { codeStream.aconst_null(); } - codeStream.invokespecial(this.syntheticAccessor); + codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */); } if (valueRequired) { codeStream.generateImplicitConversion(this.implicitConversion); Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java,v retrieving revision 1.51 diff -u -r1.51 ForeachStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 28 Aug 2008 18:58:23 -0000 1.51 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 16 Sep 2008 13:07:36 -0000 @@ -12,8 +12,8 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; -import org.eclipse.jdt.internal.compiler.codegen.CodeStream; import org.eclipse.jdt.internal.compiler.codegen.BranchLabel; +import org.eclipse.jdt.internal.compiler.codegen.CodeStream; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext; @@ -23,7 +23,6 @@ import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; -import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; @@ -62,7 +61,7 @@ int postCollectionInitStateIndex = -1; int mergedInitStateIndex = -1; - + public ForeachStatement( LocalDeclaration elementVariable, int start) { @@ -212,19 +211,7 @@ case GENERIC_ITERABLE : this.collection.generateCode(this.scope, codeStream, true); // declaringClass.iterator(); - MethodBinding iteratorMethodBinding = - new MethodBinding( - ClassFileConstants.AccPublic, - "iterator".toCharArray(),//$NON-NLS-1$ - this.scope.getJavaUtilIterator(), - Binding.NO_PARAMETERS, - Binding.NO_EXCEPTIONS, - (ReferenceBinding) this.iteratorReceiverType.erasure()); - if (this.iteratorReceiverType.isInterface()) { - codeStream.invokeinterface(iteratorMethodBinding); - } else { - codeStream.invokevirtual(iteratorMethodBinding); - } + codeStream.invokeIterableIterator(this.iteratorReceiverType); codeStream.store(this.indexVariable, false); codeStream.addVariable(this.indexVariable); break; Index: compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java,v retrieving revision 1.65 diff -u -r1.65 ExplicitConstructorCall.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 27 Jun 2008 16:03:55 -0000 1.65 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 16 Sep 2008 13:07:35 -0000 @@ -13,6 +13,7 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.lookup.Binding; @@ -148,9 +149,9 @@ i++) { codeStream.aconst_null(); } - codeStream.invokespecial(this.syntheticAccessor); + codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */); } else { - codeStream.invokespecial(this.codegenBinding); + codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */); } codeStream.recordPositionsFrom(pc, this.sourceStart); } finally { Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v retrieving revision 1.119 diff -u -r1.119 FieldReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 26 Aug 2008 14:35:24 -0000 1.119 +++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 16 Sep 2008 13:07:35 -0000 @@ -14,6 +14,7 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -233,7 +234,7 @@ codeStream.getfield(this.codegenBinding); } } else { - codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */); } // required cast must occur even if no value is required if (this.genericCast != null) codeStream.checkcast(this.genericCast); @@ -262,7 +263,7 @@ if (accessor == null) { codeStream.getstatic(this.codegenBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } switch (this.codegenBinding.type.id) { case T_long : @@ -295,14 +296,14 @@ if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) { codeStream.getstatic(this.codegenBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */); } } else { codeStream.dup(); if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) { codeStream.getfield(this.codegenBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */); } } int operationTypeID; @@ -346,14 +347,14 @@ if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) { codeStream.getstatic(this.codegenBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */); } } else { codeStream.dup(); if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) { codeStream.getfield(this.codegenBinding); } else { - codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */); } } TypeBinding operandType; Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v retrieving revision 1.132 diff -u -r1.132 MessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 3 Sep 2008 12:01:53 -0000 1.132 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 16 Sep 2008 13:07:36 -0000 @@ -15,6 +15,7 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -34,7 +35,6 @@ import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.TagBits; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; -import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; @@ -96,12 +96,10 @@ ? compileTimeType // unboxing: checkcast before conversion : runtimeTimeType; this.valueCast = originalType.genericCast(targetType); - } else if (this.actualReceiverType.isArrayType() - && runtimeTimeType.id != TypeIds.T_JavaLangObject - && this.binding.parameters == Binding.NO_PARAMETERS - && scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5 - && CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) { - // from 1.5 compliant mode on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast + } else if (this.binding == scope.environment().arrayClone + && runtimeTimeType.id != TypeIds.T_JavaLangObject + && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { + // from 1.5 source level on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast this.valueCast = runtimeTimeType; } if (this.valueCast instanceof ReferenceBinding) { @@ -148,23 +146,23 @@ } // generate arguments generateArguments(this.binding, this.arguments, currentScope, codeStream); + // actual message invocation if (this.syntheticAccessor == null){ + TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope); if (isStatic){ - codeStream.invokestatic(this.codegenBinding); + codeStream.invoke(Opcodes.OPC_invokestatic, this.codegenBinding, constantPoolDeclaringClass); + } else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){ + codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, constantPoolDeclaringClass); } else { - if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){ - codeStream.invokespecial(this.codegenBinding); + if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type + codeStream.invoke(Opcodes.OPC_invokeinterface, this.codegenBinding, constantPoolDeclaringClass); } else { - if (this.codegenBinding.declaringClass.isInterface()) { // interface or annotation type - codeStream.invokeinterface(this.codegenBinding); - } else { - codeStream.invokevirtual(this.codegenBinding); - } + codeStream.invoke(Opcodes.OPC_invokevirtual, this.codegenBinding, constantPoolDeclaringClass); } } } else { - codeStream.invokestatic(this.syntheticAccessor); + codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessor, null /* default declaringClass */); } // required cast must occur even if no value is required if (this.valueCast != null) codeStream.checkcast(this.valueCast); @@ -188,7 +186,6 @@ } codeStream.recordPositionsFrom(pc, (int)(this.nameSourcePosition >>> 32)); // highlight selector } - /** * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments() */ @@ -196,6 +193,34 @@ return this.genericTypeArguments; } +protected TypeBinding getConstantPoolDeclaringClass(BlockScope currentScope) { + // constantpool declaringClass + TypeBinding constantPoolDeclaringClass = this.codegenBinding.declaringClass; + // Post 1.4.0 target, array clone() invocations are qualified with array type + // This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding) + if (this.codegenBinding == currentScope.environment().arrayClone) { + CompilerOptions options = currentScope.compilerOptions(); + if (options.sourceLevel > ClassFileConstants.JDK1_4 ) { + constantPoolDeclaringClass = this.actualReceiverType.erasure(); + } + } else { + // if the binding declaring class is not visible, need special action + // for runtime compatibility on 1.2 VMs : change the declaring class of the binding + // NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type + // and not from Object or implicit static method call. + if (constantPoolDeclaringClass != this.actualReceiverType && this.receiverGenericCast == null && !this.actualReceiverType.isArrayType()) { + CompilerOptions options = currentScope.compilerOptions(); + if ((options.targetJDK >= ClassFileConstants.JDK1_2 + && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && this.codegenBinding.isStatic())) + && this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods + || !this.binding.declaringClass.canBeSeenBy(currentScope)) { + constantPoolDeclaringClass = this.actualReceiverType.erasure(); + } + } + } + return constantPoolDeclaringClass; +} + public boolean isSuperAccess() { return this.receiver.isSuper(); } @@ -239,26 +264,6 @@ return; } } - - // if the binding declaring class is not visible, need special action - // for runtime compatibility on 1.2 VMs : change the declaring class of the binding - // NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type - // and not from Object or implicit static method call. - if (this.binding.declaringClass != this.actualReceiverType - && this.receiverGenericCast == null - && !this.actualReceiverType.isArrayType()) { - CompilerOptions options = currentScope.compilerOptions(); - if ((options.targetJDK >= ClassFileConstants.JDK1_2 - && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && this.codegenBinding.isStatic())) - && this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods - || !this.binding.declaringClass.canBeSeenBy(currentScope)) { - - this.codegenBinding = currentScope.enclosingSourceType().getUpdatedMethodBinding( - this.codegenBinding, (ReferenceBinding) this.actualReceiverType.erasure()); - } - // Post 1.4.0 target, array clone() invocations are qualified with array type - // This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding) - } } public int nullStatus(FlowInfo flowInfo) { return FlowInfo.UNKNOWN; @@ -507,11 +512,8 @@ if (isMethodUseDeprecated(this.binding, scope, true)) scope.problemReporter().deprecatedMethod(this.binding, this); - // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) - if (this.actualReceiverType.isArrayType() - && this.binding.parameters == Binding.NO_PARAMETERS - && compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5 - && CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) { + // from 1.5 source level on, array#clone() returns the array type (but binding still shows Object) + if (this.binding == scope.environment().arrayClone && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_5) { this.resolvedType = this.actualReceiverType; } else { TypeBinding returnType = this.binding.returnType; Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v retrieving revision 1.130 diff -u -r1.130 QualifiedNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 12 Sep 2008 13:28:53 -0000 1.130 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 16 Sep 2008 13:07:36 -0000 @@ -14,6 +14,7 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -401,7 +402,7 @@ codeStream.getfield(lastFieldBinding); } } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast); if (valueRequired) { @@ -452,14 +453,14 @@ if (accessor == null) { codeStream.getstatic(lastFieldBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } } else { codeStream.dup(); if (accessor == null) { codeStream.getfield(lastFieldBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } } // the last field access is a write access @@ -501,14 +502,14 @@ if (accessor == null) { codeStream.getstatic(lastFieldBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } } else { codeStream.dup(); if (accessor == null) { codeStream.getfield(lastFieldBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } } TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length); @@ -628,7 +629,7 @@ codeStream.getfield(lastFieldBinding); } } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } if (lastGenericCast != null) codeStream.checkcast(lastGenericCast); if (!needValue) codeStream.pop(); @@ -641,7 +642,7 @@ if (accessor == null) { codeStream.getstatic(lastFieldBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } codeStream.pop(); } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java,v retrieving revision 1.33 diff -u -r1.33 CodeSnippetReturnStatement.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java 27 Jun 2008 16:04:06 -0000 1.33 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java 16 Sep 2008 13:07:39 -0000 @@ -14,6 +14,7 @@ import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; import org.eclipse.jdt.internal.compiler.ast.TryStatement; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.Constant; @@ -83,7 +84,7 @@ } // generate the invoke virtual to "setResult(Object,Class)" - codeStream.invokevirtual(this.setResultMethod); + codeStream.invoke(Opcodes.OPC_invokevirtual, this.setResultMethod, null /* default declaringClass */); } /** * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments() Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java,v retrieving revision 1.56 diff -u -r1.56 CodeSnippetQualifiedNameReference.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java 27 Jun 2008 16:04:07 -0000 1.56 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java 16 Sep 2008 13:07:39 -0000 @@ -17,6 +17,7 @@ import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.impl.Constant; @@ -222,14 +223,14 @@ if (accessor == null) { codeStream.getstatic(lastFieldBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } } else { codeStream.dup(); if (accessor == null) { codeStream.getfield(lastFieldBinding); } else { - codeStream.invokestatic(accessor); + codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); } } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java,v retrieving revision 1.56 diff -u -r1.56 CodeSnippetMessageSend.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 27 Jun 2008 16:04:06 -0000 1.56 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 16 Sep 2008 13:07:39 -0000 @@ -17,6 +17,7 @@ import org.eclipse.jdt.internal.compiler.ast.NameReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.impl.Constant; @@ -32,7 +33,7 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; -public class CodeSnippetMessageSend extends MessageSend implements ProblemReasons, EvaluationConstants { +public class CodeSnippetMessageSend extends MessageSend { EvaluationContext evaluationContext; FieldBinding delegateThis; /** @@ -78,17 +79,16 @@ // generate arguments generateArguments(this.binding, this.arguments, currentScope, codeStream); // actual message invocation + TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope); if (isStatic) { - codeStream.invokestatic(this.codegenBinding); + codeStream.invoke(Opcodes.OPC_invokestatic, this.codegenBinding, constantPoolDeclaringClass); + } else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){ + codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, constantPoolDeclaringClass); } else { - if (this.receiver.isSuper()) { - codeStream.invokespecial(this.codegenBinding); + if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type + codeStream.invoke(Opcodes.OPC_invokeinterface, this.codegenBinding, constantPoolDeclaringClass); } else { - if (this.codegenBinding.declaringClass.isInterface()) { - codeStream.invokeinterface(this.codegenBinding); - } else { - codeStream.invokevirtual(this.codegenBinding); - } + codeStream.invoke(Opcodes.OPC_invokevirtual, this.codegenBinding, constantPoolDeclaringClass); } } } else { @@ -273,9 +273,9 @@ : scope.getMethod(this.actualReceiverType, this.selector, argumentTypes, this); if (!this.binding.isValidBinding()) { if (this.binding instanceof ProblemMethodBinding - && ((ProblemMethodBinding) this.binding).problemId() == NotVisible) { + && ((ProblemMethodBinding) this.binding).problemId() == ProblemReasons.NotVisible) { if (this.evaluationContext.declaringTypeName != null) { - this.delegateThis = scope.getField(scope.enclosingSourceType(), DELEGATE_THIS, this); + this.delegateThis = scope.getField(scope.enclosingSourceType(), EvaluationConstants.DELEGATE_THIS, this); if (this.delegateThis == null){ // if not found then internal error, field should have been found this.constant = Constant.NotAConstant; scope.problemReporter().invalidMethod(this, this.binding); Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java,v retrieving revision 1.38 diff -u -r1.38 CodeSnippetAllocationExpression.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java 27 Jun 2008 16:04:06 -0000 1.38 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java 16 Sep 2008 13:07:39 -0000 @@ -14,6 +14,7 @@ import org.eclipse.jdt.internal.compiler.ast.CastExpression; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.Constant; import org.eclipse.jdt.internal.compiler.lookup.Binding; @@ -73,7 +74,7 @@ this); } // invoke constructor - codeStream.invokespecial(this.codegenBinding); + codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */); } else { // private emulation using reflect codeStream.generateEmulationForConstructor(currentScope, this.codegenBinding); Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java,v retrieving revision 1.52 diff -u -r1.52 CodeSnippetScope.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 27 Jun 2008 16:04:07 -0000 1.52 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 16 Sep 2008 13:07:39 -0000 @@ -271,7 +271,7 @@ if (!((ReferenceBinding)leafType).canBeSeenBy(this)) { return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible); } - if (CharOperation.equals(fieldName, LENGTH)) + if (CharOperation.equals(fieldName, TypeConstants.LENGTH)) return ArrayBinding.ArrayLength; return null; } @@ -371,8 +371,8 @@ MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null); if (methodBinding != null) { // handle the method clone() specially... cannot be protected or throw exceptions - if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, CLONE)) - return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, CLONE, methodBinding.returnType, argumentTypes, null, object); + if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE)) + return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object); if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) return methodBinding; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java,v retrieving revision 1.103 diff -u -r1.103 MethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 12 Sep 2008 15:54:13 -0000 1.103 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 16 Sep 2008 13:07:38 -0000 @@ -391,14 +391,6 @@ return uniqueKey; } -/* - * Answer the declaring class to use in the constant pool - * may not be a reference binding (see subtypes) - */ -public TypeBinding constantPoolDeclaringClass() { - return this.declaringClass; -} - /* Answer the receiver's constant pool name. * * for constructors Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java,v retrieving revision 1.119 diff -u -r1.119 CompilationUnitScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 27 Jun 2008 16:04:02 -0000 1.119 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 16 Sep 2008 13:07:37 -0000 @@ -154,7 +154,7 @@ int numberOfImports = numberOfStatements + 1; for (int i = 0; i < numberOfStatements; i++) { ImportReference importReference = this.referenceContext.imports[i]; - if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(JAVA_LANG, importReference.tokens) && !importReference.isStatic()) { + if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens) && !importReference.isStatic()) { numberOfImports--; break; } @@ -313,7 +313,7 @@ int numberOfImports = numberOfStatements + 1; for (int i = 0; i < numberOfStatements; i++) { ImportReference importReference = this.referenceContext.imports[i]; - if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(JAVA_LANG, importReference.tokens) && !importReference.isStatic()) { + if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens) && !importReference.isStatic()) { numberOfImports--; break; } @@ -569,21 +569,21 @@ // initialize the default imports if necessary... share the default java.lang.* import if (this.environment.defaultImports != null) return this.environment.defaultImports; - Binding importBinding = this.environment.getTopLevelPackage(JAVA); + Binding importBinding = this.environment.getTopLevelPackage(TypeConstants.JAVA); if (importBinding != null) - importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]); + importBinding = ((PackageBinding) importBinding).getTypeOrPackage(TypeConstants.JAVA_LANG[1]); if (importBinding == null || !importBinding.isValidBinding()) { // create a proxy for the missing BinaryType problemReporter().isClassPathCorrect( - JAVA_LANG_OBJECT, + TypeConstants.JAVA_LANG_OBJECT, this.referenceContext, this.environment.missingClassFileLocation); - BinaryTypeBinding missingObject = this.environment.createMissingType(null, JAVA_LANG_OBJECT); + BinaryTypeBinding missingObject = this.environment.createMissingType(null, TypeConstants.JAVA_LANG_OBJECT); importBinding = missingObject.fPackage; } - return this.environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)}; + return this.environment.defaultImports = new ImportBinding[] {new ImportBinding(TypeConstants.JAVA_LANG, true, importBinding, null)}; } // NOT Public API public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java =================================================================== RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java 27 Jun 2008 16:04:02 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jdt.internal.compiler.lookup; - -public class UpdatedMethodBinding extends MethodBinding { - - public TypeBinding updatedDeclaringClass; - - public UpdatedMethodBinding(TypeBinding updatedDeclaringClass, int modifiers, char[] selector, TypeBinding returnType, TypeBinding[] args, ReferenceBinding[] exceptions, ReferenceBinding declaringClass) { - super(modifiers, selector, returnType, args, exceptions, declaringClass); - this.updatedDeclaringClass = updatedDeclaringClass; - } - - public TypeBinding constantPoolDeclaringClass() { - return this.updatedDeclaringClass; - } -} Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v retrieving revision 1.159 diff -u -r1.159 SourceTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 27 Jun 2008 16:04:02 -0000 1.159 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 16 Sep 2008 13:07:39 -0000 @@ -44,6 +44,7 @@ private final static int METHOD_EMUL = 0; private final static int FIELD_EMUL = 1; private final static int CLASS_LITERAL_EMUL = 2; + /** @deprecated */ private final static int RECEIVER_TYPE_EMUL = 3; private final static int MAX_SYNTHETICS = 4; @@ -1064,6 +1065,7 @@ public ReferenceBinding[] memberTypes() { return this.memberTypes; } +/** @deprecated */ public FieldBinding getUpdatedFieldBinding(FieldBinding targetField, ReferenceBinding newDeclaringClass) { if (this.synthetics == null) this.synthetics = new HashMap[MAX_SYNTHETICS]; @@ -1082,6 +1084,7 @@ } return updatedField; } +/** @deprecated */ public MethodBinding getUpdatedMethodBinding(MethodBinding targetMethod, ReferenceBinding newDeclaringClass) { if (this.synthetics == null) this.synthetics = new HashMap[MAX_SYNTHETICS]; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.340 diff -u -r1.340 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 9 Sep 2008 18:40:55 -0000 1.340 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 16 Sep 2008 13:07:39 -0000 @@ -23,7 +23,7 @@ import org.eclipse.jdt.internal.compiler.util.ObjectVector; import org.eclipse.jdt.internal.compiler.util.SimpleSet; -public abstract class Scope implements TypeConstants, TypeIds { +public abstract class Scope { /* Scope kinds */ public final static int BLOCK_SCOPE = 1; @@ -781,7 +781,7 @@ // special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) { if (argumentTypes == Binding.NO_PARAMETERS - && CharOperation.equals(selector, GETCLASS) + && CharOperation.equals(selector, TypeConstants.GETCLASS) && exactMethod.returnType.isParameterizedType()/*1.5*/) { return ParameterizedMethodBinding.instantiateGetClass(receiverType, exactMethod, this); } @@ -832,7 +832,7 @@ if (leafType instanceof ReferenceBinding) if (!((ReferenceBinding) leafType).canBeSeenBy(this)) return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible); - if (CharOperation.equals(fieldName, LENGTH)) { + if (CharOperation.equals(fieldName, TypeConstants.LENGTH)) { if ((leafType.tagBits & TagBits.HasMissingType) != 0) { return new ProblemFieldBinding(ArrayBinding.ArrayLength, null, fieldName, ProblemReasons.NotFound); } @@ -1314,19 +1314,12 @@ if (argumentTypes == Binding.NO_PARAMETERS) { switch (selector[0]) { case 'c': - if (CharOperation.equals(selector, CLONE)) { - return new UpdatedMethodBinding( - compilerOptions().targetJDK >= ClassFileConstants.JDK1_4 ? (TypeBinding)receiverType : (TypeBinding)object, // remember its array type for codegen purpose on target>=1.4.0 - (methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, - CLONE, - methodBinding.returnType, - argumentTypes, - null, - object); + if (CharOperation.equals(selector, TypeConstants.CLONE)) { + return environment().computeArrayClone(methodBinding); } break; case 'g': - if (CharOperation.equals(selector, GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { + if (CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); } break; @@ -1854,7 +1847,7 @@ } // special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) if (argumentTypes == Binding.NO_PARAMETERS - && CharOperation.equals(selector, GETCLASS) + && CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); } @@ -2014,65 +2007,65 @@ public final ReferenceBinding getJavaIoSerializable() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_IO_SERIALIZABLE); - return unitScope.environment.getResolvedType(JAVA_IO_SERIALIZABLE, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_IO_SERIALIZABLE); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_IO_SERIALIZABLE, this); } public final ReferenceBinding getJavaLangAnnotationAnnotation() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_ANNOTATION_ANNOTATION); - return unitScope.environment.getResolvedType(JAVA_LANG_ANNOTATION_ANNOTATION, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION, this); } public final ReferenceBinding getJavaLangAssertionError() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_ASSERTIONERROR); - return unitScope.environment.getResolvedType(JAVA_LANG_ASSERTIONERROR, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ASSERTIONERROR); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ASSERTIONERROR, this); } public final ReferenceBinding getJavaLangClass() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_CLASS); - return unitScope.environment.getResolvedType(JAVA_LANG_CLASS, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLASS); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLASS, this); } public final ReferenceBinding getJavaLangCloneable() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_CLONEABLE); - return unitScope.environment.getResolvedType(JAVA_LANG_CLONEABLE, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLONEABLE); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLONEABLE, this); } public final ReferenceBinding getJavaLangEnum() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_ENUM); - return unitScope.environment.getResolvedType(JAVA_LANG_ENUM, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ENUM); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ENUM, this); } public final ReferenceBinding getJavaLangIterable() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_ITERABLE); - return unitScope.environment.getResolvedType(JAVA_LANG_ITERABLE, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ITERABLE); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ITERABLE, this); } public final ReferenceBinding getJavaLangObject() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_OBJECT); - return unitScope.environment.getResolvedType(JAVA_LANG_OBJECT, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_OBJECT); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, this); } public final ReferenceBinding getJavaLangString() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_STRING); - return unitScope.environment.getResolvedType(JAVA_LANG_STRING, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_STRING); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_STRING, this); } public final ReferenceBinding getJavaLangThrowable() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_LANG_THROWABLE); - return unitScope.environment.getResolvedType(JAVA_LANG_THROWABLE, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_THROWABLE); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_THROWABLE, this); } public final ReferenceBinding getJavaUtilIterator() { CompilationUnitScope unitScope = compilationUnitScope(); - unitScope.recordQualifiedReference(JAVA_UTIL_ITERATOR); - return unitScope.environment.getResolvedType(JAVA_UTIL_ITERATOR, this); + unitScope.recordQualifiedReference(TypeConstants.JAVA_UTIL_ITERATOR); + return unitScope.environment.getResolvedType(TypeConstants.JAVA_UTIL_ITERATOR, this); } /* Answer the type binding corresponding to the typeName argument, relative to the enclosingType. @@ -2114,7 +2107,7 @@ // special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) if (argumentTypes == Binding.NO_PARAMETERS - && CharOperation.equals(selector, GETCLASS) + && CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); } @@ -3038,8 +3031,8 @@ case 0 : return TypeBinding.VOID; case 1 : return mecs[0]; case 2 : - if ((commonDim == 0 ? mecs[1].id : mecs[1].leafComponentType().id) == T_JavaLangObject) return mecs[0]; - if ((commonDim == 0 ? mecs[0].id : mecs[0].leafComponentType().id) == T_JavaLangObject) return mecs[1]; + if ((commonDim == 0 ? mecs[1].id : mecs[1].leafComponentType().id) == TypeIds.T_JavaLangObject) return mecs[0]; + if ((commonDim == 0 ? mecs[0].id : mecs[0].leafComponentType().id) == TypeIds.T_JavaLangObject) return mecs[1]; } TypeBinding[] otherBounds = new TypeBinding[count - 1]; int rank = 0; @@ -3118,7 +3111,7 @@ if (dim > 0) { leafType = typeToVisit.leafComponentType(); switch(leafType.id) { - case T_JavaLangObject: + case TypeIds.T_JavaLangObject: if (dim > 1) { // Object[][] supertype is Object[] TypeBinding elementType = ((ArrayBinding)typeToVisit).elementsType(); if (!typesToVisit.contains(elementType)) { @@ -3128,14 +3121,14 @@ continue; } //$FALL-THROUGH$ - case T_byte: - case T_short: - case T_char: - case T_boolean: - case T_int: - case T_long: - case T_float: - case T_double: + case TypeIds.T_byte: + case TypeIds.T_short: + case TypeIds.T_char: + case TypeIds.T_boolean: + case TypeIds.T_int: + case TypeIds.T_long: + case TypeIds.T_float: + case TypeIds.T_double: TypeBinding superType = getJavaIoSerializable(); if (!typesToVisit.contains(superType)) { typesToVisit.add(superType); @@ -3254,7 +3247,7 @@ TypeBinding erasedSuperType = erasedSuperTypes[j]; if (erasedSuperType == null) continue nextSuperType; TypeBinding match; - if (erasedSuperType == otherType || erasedSuperType.id == T_JavaLangObject && otherType.isInterface()) { + if (erasedSuperType == otherType || erasedSuperType.id == TypeIds.T_JavaLangObject && otherType.isInterface()) { match = erasedSuperType; } else { if (erasedSuperType.isArrayType()) { @@ -3302,14 +3295,14 @@ TypeBinding otherType = erasedSuperTypes[j]; if (otherType == null) continue nextOtherType; if (erasedSuperType instanceof ReferenceBinding) { - if (otherType.id == T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface + if (otherType.id == TypeIds.T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) { erasedSuperTypes[j] = null; // discard non minimal supertype remaining--; } } else if (erasedSuperType.isArrayType()) { if (otherType.isArrayType() // keep Object[...] for an interface array (same dimensions) - && otherType.leafComponentType().id == T_JavaLangObject + && otherType.leafComponentType().id == TypeIds.T_JavaLangObject && otherType.dimensions() == erasedSuperType.dimensions() && erasedSuperType.leafComponentType().isInterface()) continue nextOtherType; if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java,v retrieving revision 1.98 diff -u -r1.98 LookupEnvironment.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 27 Jun 2008 16:04:02 -0000 1.98 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 16 Sep 2008 13:07:38 -0000 @@ -62,6 +62,8 @@ private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4]; private MethodVerifier verifier; + public MethodBinding arrayClone; + final static int BUILD_FIELDS_AND_METHODS = 4; final static int BUILD_TYPE_HIERARCHY = 1; final static int CHECK_AND_SET_IMPORTS = 2; @@ -251,7 +253,19 @@ parsedUnit.scope.buildFieldsAndMethods(); this.unitBeingCompleted = null; } - +public MethodBinding computeArrayClone(MethodBinding objectClone) { + if (this.arrayClone == null) { + this.arrayClone = new MethodBinding( + (objectClone.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, + TypeConstants.CLONE, + objectClone.returnType, + Binding.NO_PARAMETERS, + Binding.NO_EXCEPTIONS, // no exception for array specific method + (ReferenceBinding)objectClone.returnType); + } + return this.arrayClone; + +} public TypeBinding computeBoxingType(TypeBinding type) { TypeBinding boxedType; switch (type.id) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java,v retrieving revision 1.21 diff -u -r1.21 NestedTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java 27 Jun 2008 16:04:02 -0000 1.21 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java 16 Sep 2008 13:07:38 -0000 @@ -111,7 +111,6 @@ * Compute the resolved positions for all the synthetic arguments */ final public void computeSyntheticArgumentSlotSizes() { - int slotSize = 0; // insert enclosing instances first, followed by the outerLocals int enclosingInstancesCount = this.enclosingInstances == null ? 0 : this.enclosingInstances.length; @@ -147,16 +146,13 @@ /* Answer the receiver's enclosing type... null if the receiver is a top level type. */ public ReferenceBinding enclosingType() { - return this.enclosingType; } /* Answer the synthetic argument for or null if one does not exist. */ public SyntheticArgumentBinding getSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) { - if (this.outerLocalVariables == null) return null; // is null if no outer local variables are known - for (int i = this.outerLocalVariables.length; --i >= 0;) if (this.outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable) return this.outerLocalVariables[i]; @@ -170,7 +166,6 @@ public ReferenceBinding[] syntheticEnclosingInstanceTypes() { if (this.enclosingInstances == null) return null; - int length = this.enclosingInstances.length; ReferenceBinding types[] = new ReferenceBinding[length]; for (int i = 0; i < length; i++) @@ -194,9 +189,7 @@ /* Answer the synthetic argument for or null if one does not exist. */ public SyntheticArgumentBinding getSyntheticArgument(ReferenceBinding targetEnclosingType, boolean onlyExactMatch) { - if (this.enclosingInstances == null) return null; // is null if no enclosing instances are known - // exact match for (int i = this.enclosingInstances.length; --i >= 0;) if (this.enclosingInstances[i].type == targetEnclosingType) #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java,v retrieving revision 1.25 diff -u -r1.25 ArrayTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java 27 Jun 2008 16:04:45 -0000 1.25 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java 16 Sep 2008 13:07:42 -0000 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; import java.io.File; +import java.util.Map; import junit.framework.Test; @@ -393,4 +394,154 @@ "argument cannot be resolved\n" + "----------\n"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 +// Check return type of array#clone() +public void test014() throws Exception { + Map optionsMap = getCompilerOptions(); + CompilerOptions options = new CompilerOptions(optionsMap); + if (options.complianceLevel > ClassFileConstants.JDK1_4) { + // check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level) + optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); + } + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(long[] longs) throws Exception {\n" + + " long[] other = longs.clone();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " long[] other = longs.clone();\n" + + " ^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Object to long[]\n" + + "----------\n", + null, + true, + optionsMap); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation +//Check return type of array#clone() +public void test015() throws Exception { + if ( new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_5) { + return; + } + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(long[] longs) throws Exception {\n" + + " long[] other = longs.clone();\n" + + " }\n" + + "}\n", + }, + ""); +} +//https:bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation +//Check constant pool declaring class of array#clone() +public void test016() throws Exception { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(long[] longs) throws Exception {\n" + + " Object other = longs.clone();\n" + + " }\n" + + "}\n", + }, + ""); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator +"X.class")); + String actualOutput = + disassembler.disassemble( + classFileBytes, + "\n", + ClassFileBytesDisassembler.DETAILED); + + String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel <= ClassFileConstants.JDK1_4 + ? " // Method descriptor #15 ([J)V\n" + + " // Stack: 1, Locals: 3\n" + + " void foo(long[] longs) throws java.lang.Exception;\n" + + " 0 aload_1 [longs]\n" + + " 1 invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + + " 4 astore_2 [other]\n" + + " 5 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 3]\n" + + " [pc: 5, line: 4]\n" + : " // Method descriptor #15 ([J)V\n" + + " // Stack: 1, Locals: 3\n" + + " void foo(long[] longs) throws java.lang.Exception;\n" + + " 0 aload_1 [longs]\n" + + " 1 invokevirtual long[].clone() : java.lang.Object [19]\n" + + " 4 astore_2 [other]\n" + + " 5 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 3]\n" + + " [pc: 5, line: 4]\n"; + + int index = actualOutput.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(actualOutput, 3)); + } + if (index == -1) { + assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput); + } + return; +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation +//Check constant pool declaring class of array#clone() +public void test017() throws Exception { + Map optionsMap = getCompilerOptions(); + CompilerOptions options = new CompilerOptions(optionsMap); + if (options.complianceLevel > ClassFileConstants.JDK1_4) { + // check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level) + optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); + } + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(long[] longs) throws Exception {\n" + + " Object other = longs.clone();\n" + + " }\n" + + "}\n", + }, + "", + null, + true, + null, + optionsMap, + null); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator +"X.class")); + String actualOutput = + disassembler.disassemble( + classFileBytes, + "\n", + ClassFileBytesDisassembler.DETAILED); + + String expectedOutput = + " // Method descriptor #15 ([J)V\n" + + " // Stack: 1, Locals: 3\n" + + " void foo(long[] longs) throws java.lang.Exception;\n" + + " 0 aload_1 [longs]\n" + + " 1 invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + + " 4 astore_2 [other]\n" + + " 5 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 3]\n" + + " [pc: 5, line: 4]\n"; + + int index = actualOutput.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(actualOutput, 3)); + } + if (index == -1) { + assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput); + } +} } Index: src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java,v retrieving revision 1.101 diff -u -r1.101 Compliance_1_4.java --- src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java 27 Jun 2008 16:04:44 -0000 1.101 +++ src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java 16 Sep 2008 13:07:43 -0000 @@ -1423,8 +1423,9 @@ "\n", ClassFileBytesDisassembler.DETAILED); - String expectedOutput = - " 1 invokevirtual java.lang.String[].clone() : java.lang.Object [16]\n"; + String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel <= ClassFileConstants.JDK1_4 + ? " 1 invokevirtual java.lang.Object.clone() : java.lang.Object [16]\n" + : " 1 invokevirtual java.lang.String[].clone() : java.lang.Object [16]\n"; int index = actualOutput.indexOf(expectedOutput); if (index == -1 || expectedOutput.length() == 0) {