### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java,v retrieving revision 1.16 diff -u -r1.16 AttributeNamesConstants.java --- compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java 28 Mar 2006 20:31:16 -0000 1.16 +++ compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java 11 May 2007 15:29:07 -0000 @@ -30,4 +30,5 @@ final char[] RuntimeVisibleParameterAnnotationsName = "RuntimeVisibleParameterAnnotations".toCharArray(); //$NON-NLS-1$ final char[] StackMapTableName = "StackMapTable".toCharArray(); //$NON-NLS-1$ final char[] InconsistentHierarchy = "InconsistentHierarchy".toCharArray(); //$NON-NLS-1$ + final char[] VarargsName = "Varargs".toCharArray(); //$NON-NLS-1$ } Index: model/org/eclipse/jdt/internal/core/util/Disassembler.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java,v retrieving revision 1.87 diff -u -r1.87 Disassembler.java --- model/org/eclipse/jdt/internal/core/util/Disassembler.java 27 Apr 2007 00:47:41 -0000 1.87 +++ model/org/eclipse/jdt/internal/core/util/Disassembler.java 11 May 2007 15:29:07 -0000 @@ -17,6 +17,7 @@ import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.util.*; +import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; /** @@ -560,7 +561,7 @@ buffer.append(Messages.disassembler_space); } CharOperation.replace(methodDescriptor, '/', '.'); - final boolean isVarArgs = (accessFlags & IModifierConstants.ACC_VARARGS) != 0; + final boolean isVarArgs = isVarArgs(methodInfo); if (methodInfo.isConstructor()) { if (checkMode(mode, WORKING_COPY) && signatureAttribute != null) { final char[] signature = signatureAttribute.getSignature(); @@ -619,7 +620,7 @@ if (returnType.length == 1) { switch(returnType[0]) { case 'V' : - writeNewLine(buffer, lineSeparator, tabNumber); + writeNewLine(buffer, lineSeparator, tabNumber); break; case 'I' : case 'B' : @@ -630,19 +631,19 @@ case 'C' : writeNewLine(buffer, lineSeparator, tabNumber + 1); buffer.append("return 0;"); //$NON-NLS-1$ - writeNewLine(buffer, lineSeparator, tabNumber); + writeNewLine(buffer, lineSeparator, tabNumber); break; default : // boolean writeNewLine(buffer, lineSeparator, tabNumber + 1); buffer.append("return false;"); //$NON-NLS-1$ - writeNewLine(buffer, lineSeparator, tabNumber); + writeNewLine(buffer, lineSeparator, tabNumber); } } else { // object writeNewLine(buffer, lineSeparator, tabNumber + 1); buffer.append("return null;"); //$NON-NLS-1$ - writeNewLine(buffer, lineSeparator, tabNumber); + writeNewLine(buffer, lineSeparator, tabNumber); } buffer.append('}'); } else { @@ -980,6 +981,12 @@ return CharOperation.equals(TypeConstants.JAVA_LANG_OBJECT, CharOperation.splitOn('.', className)); } + private boolean isVarArgs(IMethodInfo methodInfo) { + int accessFlags = methodInfo.getAccessFlags(); + if ((accessFlags & IModifierConstants.ACC_VARARGS) != 0) return true; + // check the presence of the unspecified Varargs attribute + return Util.getAttribute(methodInfo, AttributeNamesConstants.VarargsName) != null; + } private void disassemble(ICodeAttribute codeAttribute, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) { writeNewLine(buffer, lineSeparator, tabNumber - 1); DefaultBytecodeVisitor visitor = new DefaultBytecodeVisitor(codeAttribute, buffer, lineSeparator, tabNumber, mode); Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java,v retrieving revision 1.46 diff -u -r1.46 MethodInfo.java --- compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java 29 Mar 2007 13:17:16 -0000 1.46 +++ compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java 11 May 2007 15:29:07 -0000 @@ -369,6 +369,9 @@ if (CharOperation.equals(attributeName, AttributeNamesConstants.AnnotationDefaultName)) this.accessFlags |= ClassFileConstants.AccAnnotationDefault; break; + case 'V' : + if (CharOperation.equals(attributeName, AttributeNamesConstants.VarargsName)) + this.accessFlags |= ClassFileConstants.AccVarargs; } } readOffset += (6 + u4At(readOffset + 2)); Index: compiler/org/eclipse/jdt/internal/compiler/ClassFile.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java,v retrieving revision 1.148 diff -u -r1.148 ClassFile.java --- compiler/org/eclipse/jdt/internal/compiler/ClassFile.java 10 Apr 2007 19:03:10 -0000 1.148 +++ compiler/org/eclipse/jdt/internal/compiler/ClassFile.java 11 May 2007 15:29:07 -0000 @@ -5347,23 +5347,46 @@ attributeNumber++; } - if (this.targetJDK < ClassFileConstants.JDK1_5 && methodBinding.isSynthetic()) { - // Synthetic attribute - // Check that there is enough space to write the deprecated attribute - if (contentsOffset + 6 >= this.contents.length) { - resizeContents(6); - } - int syntheticAttributeNameIndex = - constantPool.literalIndex(AttributeNamesConstants.SyntheticName); - contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8); - contents[contentsOffset++] = (byte) syntheticAttributeNameIndex; - // the length of a synthetic attribute is equals to 0 - contents[contentsOffset++] = 0; - contents[contentsOffset++] = 0; - contents[contentsOffset++] = 0; - contents[contentsOffset++] = 0; - - attributeNumber++; + if (this.targetJDK < ClassFileConstants.JDK1_5) { + if (methodBinding.isSynthetic()) { + // Synthetic attribute + // Check that there is enough space to write the deprecated attribute + if (contentsOffset + 6 >= this.contents.length) { + resizeContents(6); + } + int syntheticAttributeNameIndex = + constantPool.literalIndex(AttributeNamesConstants.SyntheticName); + contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8); + contents[contentsOffset++] = (byte) syntheticAttributeNameIndex; + // the length of a synthetic attribute is equals to 0 + contents[contentsOffset++] = 0; + contents[contentsOffset++] = 0; + contents[contentsOffset++] = 0; + contents[contentsOffset++] = 0; + + attributeNumber++; + } + if (methodBinding.isVarargs()) { + /* + * handle of the target jsr14 for varargs in the source + * Varargs attribute + * Check that there is enough space to write the deprecated attribute + */ + if (contentsOffset + 6 >= this.contents.length) { + resizeContents(6); + } + int varargsAttributeNameIndex = + constantPool.literalIndex(AttributeNamesConstants.VarargsName); + contents[contentsOffset++] = (byte) (varargsAttributeNameIndex >> 8); + contents[contentsOffset++] = (byte) varargsAttributeNameIndex; + // the length of a varargs attribute is equals to 0 + contents[contentsOffset++] = 0; + contents[contentsOffset++] = 0; + contents[contentsOffset++] = 0; + contents[contentsOffset++] = 0; + + attributeNumber++; + } } // add signature attribute char[] genericSignature = methodBinding.genericSignature(); @@ -5439,8 +5462,9 @@ resizeContents(10); } if (targetJDK < ClassFileConstants.JDK1_5) { - // pre 1.5, synthetic was an attribute, not a modifier - accessFlags &= ~ClassFileConstants.AccSynthetic; + // pre 1.5, synthetic is an attribute, not a modifier + // pre 1.5, varargs is an attribute, not a modifier (-target jsr14 mode) + accessFlags &= ~(ClassFileConstants.AccSynthetic | ClassFileConstants.AccVarargs); } if ((methodBinding.tagBits & TagBits.ClearPrivateModifier) != 0) { accessFlags &= ~ClassFileConstants.AccPrivate;