diff options
author | Andrew Clement | 2013-08-25 11:59:26 +0000 |
---|---|---|
committer | ssankaran | 2013-08-25 11:59:26 +0000 |
commit | e965722f47023ae407b487744865b93f56cfe7d1 (patch) | |
tree | 4af8bcb9a29a628edbbde77487d5cc3676e18705 | |
parent | 83e7ec555369f29d4b78a3a829caf1776dce39db (diff) | |
download | eclipse.jdt.core-e965722f47023ae407b487744865b93f56cfe7d1.tar.gz eclipse.jdt.core-e965722f47023ae407b487744865b93f56cfe7d1.tar.xz eclipse.jdt.core-e965722f47023ae407b487744865b93f56cfe7d1.zip |
Fixed Bug 409250 - [1.8][compiler] Various loose ends in 308 code
generation.
Signed-off-by: Andrew Clement <aclement@gopivotal.com>
10 files changed, 50 insertions, 23 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java index b82f850fa5..5d8e4a3b39 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java @@ -15,6 +15,8 @@ * bug 395002 - Self bound generic class doesn't resolve bounds properly for wildcards for certain parametrisation. * bug 331649 - [compiler][null] consider null annotations for fields * bug 400761 - [compiler][null] null may be return as boolean without a diagnostic + * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -225,6 +227,17 @@ public void resolve(MethodScope initializationScope) { initializationScope.lastVisibleFieldID = this.binding.id; resolveAnnotations(initializationScope, this.annotations, this.binding); + // Check if this declaration should now have the type annotations bit set + if (this.annotations != null) { + for (int i = 0, max = this.annotations.length; i < max; i++) { + TypeBinding resolvedAnnotationType = this.annotations[i].resolvedType; + if (resolvedAnnotationType != null && (resolvedAnnotationType.getAnnotationTagBits() & TagBits.AnnotationForTypeUse) != 0) { + this.bits |= ASTNode.HasTypeAnnotations; + break; + } + } + } + // check @Deprecated annotation presence if ((this.binding.getAnnotationTagBits() & TagBits.AnnotationDeprecated) == 0 && (this.binding.modifiers & ClassFileConstants.AccDeprecated) != 0 diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java index 4da91f5457..83b9209210 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java @@ -27,6 +27,8 @@ * bug 400761 - [compiler][null] null may be return as boolean without a diagnostic * Jesper S Moller - Contributions for * Bug 378674 - "The method can be declared as static" is wrong + * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -279,6 +281,16 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl } // only resolve annotation at the end, for constant to be positioned before (96991) resolveAnnotations(scope, this.annotations, this.binding); + // Check if this declaration should now have the type annotations bit set + if (this.annotations != null) { + for (int i = 0, max = this.annotations.length; i < max; i++) { + TypeBinding resolvedAnnotationType = this.annotations[i].resolvedType; + if (resolvedAnnotationType != null && (resolvedAnnotationType.getAnnotationTagBits() & TagBits.AnnotationForTypeUse) != 0) { + this.bits |= ASTNode.HasTypeAnnotations; + break; + } + } + } scope.validateNullAnnotation(this.binding.tagBits, this.type, this.annotations); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java index 2108adeeca..653dc280b5 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java @@ -27,6 +27,7 @@ * Bug 415291 - [1.8][null] differentiate type incompatibilities due to null annotations * Andy Clement - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -301,7 +302,7 @@ public void generateArguments(MethodBinding binding, Expression[] arguments, Blo // called with (argLength - lastIndex) elements : foo(1, 2) or foo(1, 2, 3, 4) // need to gen elements into an array, then gen each remaining element into created array codeStream.generateInlinedValue(argLength - varArgIndex); - codeStream.newArray(null, codeGenVarArgsType); // create a mono-dimensional array + codeStream.newArray(codeGenVarArgsType); // create a mono-dimensional array for (int i = varArgIndex; i < argLength; i++) { codeStream.dup(); codeStream.generateInlinedValue(i - varArgIndex); @@ -320,7 +321,7 @@ public void generateArguments(MethodBinding binding, Expression[] arguments, Blo // right number but not directly compatible or too many arguments - wrap extra into array // need to gen elements into an array, then gen each remaining element into created array codeStream.generateInlinedValue(1); - codeStream.newArray(null, codeGenVarArgsType); // create a mono-dimensional array + codeStream.newArray(codeGenVarArgsType); // create a mono-dimensional array codeStream.dup(); codeStream.generateInlinedValue(0); arguments[varArgIndex].generateCode(currentScope, codeStream, true); @@ -330,7 +331,7 @@ public void generateArguments(MethodBinding binding, Expression[] arguments, Blo // scenario: foo(1) --> foo(1, new int[0]) // generate code for an empty array of parameterType codeStream.generateInlinedValue(0); - codeStream.newArray(null, codeGenVarArgsType); // create a mono-dimensional array + codeStream.newArray(codeGenVarArgsType); // create a mono-dimensional array } } else if (arguments != null) { // standard generation for method arguments for (int i = 0, max = arguments.length; i < max; i++) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java index 1422f74db4..a3146ab082 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java @@ -20,6 +20,7 @@ * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) * Bug 409247 - [1.8][compiler] Verify error with code allocating multidimensional array * Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.compiler.codegen; @@ -1874,7 +1875,7 @@ public void generateEmulationForConstructor(Scope scope, MethodBinding methodBin invokeClassForName(); int paramLength = methodBinding.parameters.length; this.generateInlinedValue(paramLength); - newArray(null, scope.createArrayType(scope.getType(TypeConstants.JAVA_LANG_CLASS, 3), 1)); + newArray(scope.createArrayType(scope.getType(TypeConstants.JAVA_LANG_CLASS, 3), 1)); if (paramLength > 0) { dup(); for (int i = 0; i < paramLength; i++) { @@ -1930,7 +1931,7 @@ public void generateEmulationForMethod(Scope scope, MethodBinding methodBinding) this.ldc(String.valueOf(methodBinding.selector)); int paramLength = methodBinding.parameters.length; this.generateInlinedValue(paramLength); - newArray(null, scope.createArrayType(scope.getType(TypeConstants.JAVA_LANG_CLASS, 3), 1)); + newArray(scope.createArrayType(scope.getType(TypeConstants.JAVA_LANG_CLASS, 3), 1)); if (paramLength > 0) { dup(); for (int i = 0; i < paramLength; i++) { @@ -2530,7 +2531,7 @@ public void generateSyntheticBodyForEnumValues(SyntheticMethodBinding methodBind arraylength(); dup(); istore_1(); - newArray(null, (ArrayBinding) enumArray); + newArray((ArrayBinding) enumArray); dup(); astore_2(); iconst_0(); @@ -5756,10 +5757,6 @@ public void newarray(int array_Type) { } public void newArray(ArrayBinding arrayBinding) { - this.newArray(null, arrayBinding); -} - -public void newArray(TypeReference typeReference, ArrayBinding arrayBinding) { this.newArray(null, null, arrayBinding); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java index 9d2e842813..bc66e5b481 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java @@ -15,6 +15,7 @@ * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) * Bug 409247 - [1.8][compiler] Verify error with code allocating multidimensional array * Bug 409517 - [1.8][compiler] Type annotation problems on more elaborate array references + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.compiler.codegen; @@ -98,7 +99,7 @@ public class TypeAnnotationCodeStream extends StackMapFrameCodeStream { : AnnotationTargetTypeConstants.METHOD_INVOCATION_TYPE_ARGUMENT; for (int i = 0, max = typeArguments.length; i < max; i++) { TypeReference typeArgument = typeArguments[i]; - if ((typeArgument.bits & ASTNode.HasTypeAnnotations) != 0) { // TODO can check this at a higher level? + if ((typeArgument.bits & ASTNode.HasTypeAnnotations) != 0) { addAnnotationContext(typeArgument, this.position, i, targetType); } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java index 82ba6fa5f3..4796584fe8 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java @@ -26,6 +26,7 @@ * bug 393192 - Incomplete type hierarchy with > 10 annotations * Andy Clement - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.compiler.parser; @@ -3522,7 +3523,6 @@ protected void consumeEnterVariable() { declaration.annotations = new Annotation[length], 0, length); - declaration.bits |= ASTNode.HasTypeAnnotations; } type = getTypeReference(typeDim = this.intStack[this.intPtr--]); // type dimension if (declaration.declarationSourceStart == -1) { @@ -3544,7 +3544,6 @@ protected void consumeEnterVariable() { declaration.annotations = new Annotation[length], 0, length); - declaration.bits |= ASTNode.HasTypeAnnotations; } // Store javadoc only on first declaration as it is the same for all ones FieldDeclaration fieldDeclaration = (FieldDeclaration) declaration; @@ -3562,7 +3561,6 @@ protected void consumeEnterVariable() { if (annotations != null) { final int annotationsLength = annotations.length; System.arraycopy(annotations, 0, declaration.annotations = new Annotation[annotationsLength], 0, annotationsLength); - declaration.bits |= ASTNode.HasTypeAnnotations; } } @@ -3575,7 +3573,7 @@ protected void consumeEnterVariable() { Annotation[][] annotationsOnDimensions = type.getAnnotationsOnDimensions(); if (annotationsOnDimensions != null || annotationsOnExtendedDimensions != null) { annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(typeDim, annotationsOnDimensions, extendedDimension, annotationsOnExtendedDimensions); - declaration.bits |= (type.bits & ASTNode.HasTypeAnnotations); +// declaration.bits |= (type.bits & ASTNode.HasTypeAnnotations); } declaration.type = copyDims(type, dimension, annotationsOnAllDimensions); } diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java index bce4744895..7eea9b69ce 100644 --- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java +++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java @@ -14,6 +14,7 @@ * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) * Bug 409245 - [1.8][compiler] Type annotations dropped when call is routed through a synthetic bridge method + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.eval; @@ -92,7 +93,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolea if (this.arguments != null) { int argsLength = this.arguments.length; codeStream.generateInlinedValue(argsLength); - codeStream.newArray(null, currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); + codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); codeStream.dup(); for (int i = 0; i < argsLength; i++) { codeStream.generateInlinedValue(i); @@ -108,7 +109,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolea } } else { codeStream.generateInlinedValue(0); - codeStream.newArray(null, currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); + codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); } codeStream.invokeJavaLangReflectConstructorNewInstance(); codeStream.checkcast(allocatedType); diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java index 97075622b1..039a89427d 100644 --- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java +++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java @@ -13,6 +13,7 @@ * IBM Corporation - initial API and implementation * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 409245 - [1.8][compiler] Type annotations dropped when call is routed through a synthetic bridge method + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.eval; @@ -117,7 +118,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean if (this.arguments != null) { int argsLength = this.arguments.length; codeStream.generateInlinedValue(argsLength); - codeStream.newArray(null, currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); + codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); codeStream.dup(); for (int i = 0; i < argsLength; i++) { codeStream.generateInlinedValue(i); @@ -133,7 +134,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean } } else { codeStream.generateInlinedValue(0); - codeStream.newArray(null, currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); + codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); } codeStream.invokeJavaLangReflectMethodInvoke(); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExtendedAnnotation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExtendedAnnotation.java index 76edd25a12..882675a465 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExtendedAnnotation.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExtendedAnnotation.java @@ -13,6 +13,7 @@ * IBM Corporation - initial API and implementation * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.core.util; @@ -73,7 +74,7 @@ public interface IExtendedAnnotation extends IAnnotation { * Answer back the local variable reference info table length of this entry as specified in * the JVM specifications. * - * <p>This is defined only for annotations related a local variable.</p> + * <p>This is defined only for annotations related to a local variable.</p> * * @return the local variable reference info table length of this entry as specified in * the JVM specifications @@ -84,7 +85,7 @@ public interface IExtendedAnnotation extends IAnnotation { * Answer back the local variable reference info table of this entry as specified in * the JVM specifications. Answer an empty array if none. * - * <p>This is defined only for annotations related a local variable.</p> + * <p>This is defined only for annotations related to a local variable.</p> * * @return the local variable reference info table of this entry as specified in * the JVM specifications. Answer an empty array if none diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java index aa6187b402..d5f0606ab4 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java @@ -14,6 +14,7 @@ * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) * Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator + * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ package org.eclipse.jdt.internal.core.util; @@ -59,6 +60,7 @@ public class ExtendedAnnotation extends ClassFileStruct implements IExtendedAnno private static final IAnnotationComponent[] NO_ENTRIES = new IAnnotationComponent[0]; private final static int[][] NO_TYPEPATH = new int[0][0]; + private final static ILocalVariableReferenceInfo[] NO_LOCAL_VARIABLE_TABLE_ENTRIES = new ILocalVariableReferenceInfo[0]; private int targetType; private int annotationTypeIndex; @@ -74,7 +76,7 @@ public class ExtendedAnnotation extends ClassFileStruct implements IExtendedAnno private int typeParameterBoundIndex; private int parameterIndex; private int exceptionTableIndex; - private ILocalVariableReferenceInfo[] localVariableTable; + private ILocalVariableReferenceInfo[] localVariableTable = NO_LOCAL_VARIABLE_TABLE_ENTRIES; /** * Constructor for ExtendedAnnotation, builds an annotation from the supplied bytestream. @@ -271,7 +273,7 @@ public class ExtendedAnnotation extends ClassFileStruct implements IExtendedAnno } public int getLocalVariableRefenceInfoLength() { - return this.localVariableTable != null ? this.localVariableTable.length : 0; + return this.localVariableTable.length; } public ILocalVariableReferenceInfo[] getLocalVariableTable() { |