diff options
author | Stephan Herrmann | 2015-02-14 21:37:15 +0000 |
---|---|---|
committer | Stephan Herrmann | 2015-02-14 21:37:15 +0000 |
commit | 53b3b921e9223b7e824d3a984db2edcecebf7168 (patch) | |
tree | e66bb7787fb9bb35bfd5b4a27e3a2de0072c1b06 /org.eclipse.jdt.core/compiler | |
parent | ea9d5efb7fbf74057de7abad3cdd0f9219a30eda (diff) | |
download | org.eclipse.objectteams-53b3b921e9223b7e824d3a984db2edcecebf7168.tar.gz org.eclipse.objectteams-53b3b921e9223b7e824d3a984db2edcecebf7168.tar.xz org.eclipse.objectteams-53b3b921e9223b7e824d3a984db2edcecebf7168.zip |
Update jdt.core to a9567e58ade978b67e4f2db4ee5fe35bc3c0d3fe
- new formatter not yet adjusted for OT/J
Diffstat (limited to 'org.eclipse.jdt.core/compiler')
13 files changed, 151 insertions, 35 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java index ee68d3f9d..df0ad2fa8 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -70,6 +70,44 @@ public static final char[] append(char[] array, char suffix) { } /** + * Answers a new array with appending the sub-array at the end of the array. + * <br> + * <br> + * For example:<br> + * <ol> + * <li><pre> + * array = { 'a', 'b' } + * suffix = { 'c', 'd' } + * => result = { 'a', 'b' , 'c' , d' } + * </pre> + * </li> + * <li><pre> + * array = null + * suffix = { 'c' } + * => result = { 'c' } + * </pre></li> + * </ol> + * + * @param target the array that is concatenated with the suffix array. + * @param suffix the array that will be concatenated to the target + * @return the new array + * @throws NullPointerException if the target array is null + * @since 3.11 + */ +public static final char[] append(char[] target, char[] suffix) { + if(suffix == null || suffix.length == 0) + return target; + int targetLength = target.length; + int subLength = suffix.length; + int newTargetLength = targetLength + subLength; + if (newTargetLength > targetLength) { + System.arraycopy(target, 0, target = new char[newTargetLength], 0, targetLength); + } + System.arraycopy(suffix, 0, target, targetLength, subLength); + return target; +} + +/** * Append the given sub-array to the target array starting at the given index in the target array. * The start of the sub-array is inclusive, the end is exclusive. * Answers a new target array if it needs to grow, otherwise answers the same target array. diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java index da4e27833..686cfa2d2 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java @@ -2488,9 +2488,8 @@ public class ClassFile implements TypeConstants, TypeIds { try { generateElementValue(singleMemberAnnotation.memberValue, methodBinding.returnType, memberValuePairOffset); if (this.contentsOffset == memberValuePairOffset) { - // ignore annotation value - this.contents[this.contentsOffset++] = 0; - this.contents[this.contentsOffset++] = 0; + // completely remove the annotation as its value is invalid + this.contentsOffset = startingContentsOffset; } } catch(ClassCastException e) { this.contentsOffset = startingContentsOffset; @@ -3692,6 +3691,14 @@ public class ClassFile implements TypeConstants, TypeIds { } } + private boolean jdk16packageInfoAnnotation(final long annotationMask, final long targetMask) { + if (this.targetJDK <= ClassFileConstants.JDK1_6 && + targetMask == TagBits.AnnotationForPackage && annotationMask != 0 && + (annotationMask & TagBits.AnnotationForPackage) == 0) { + return true; + } + return false; + } /** * @param annotations * @param targetMask allowed targets @@ -3706,7 +3713,9 @@ public class ClassFile implements TypeConstants, TypeIds { Annotation annotation; if ((annotation = annotations[i].getPersistibleAnnotation()) == null) continue; // already packaged into container. long annotationMask = annotation.resolvedType != null ? annotation.resolvedType.getAnnotationTagBits() & TagBits.AnnotationTargetMASK : 0; - if (annotationMask != 0 && (annotationMask & targetMask) == 0) continue; + if (annotationMask != 0 && (annotationMask & targetMask) == 0) { + if (!jdk16packageInfoAnnotation(annotationMask, targetMask)) continue; + } if (annotation.isRuntimeInvisible() || annotation.isRuntimeTypeInvisible()) { invisibleAnnotationsCounter++; } else if (annotation.isRuntimeVisible() || annotation.isRuntimeTypeVisible()) { @@ -3737,7 +3746,9 @@ public class ClassFile implements TypeConstants, TypeIds { Annotation annotation; if ((annotation = annotations[i].getPersistibleAnnotation()) == null) continue; // already packaged into container. long annotationMask = annotation.resolvedType != null ? annotation.resolvedType.getAnnotationTagBits() & TagBits.AnnotationTargetMASK : 0; - if (annotationMask != 0 && (annotationMask & targetMask) == 0) continue; + if (annotationMask != 0 && (annotationMask & targetMask) == 0) { + if (!jdk16packageInfoAnnotation(annotationMask, targetMask)) continue; + } if (annotation.isRuntimeInvisible() || annotation.isRuntimeTypeInvisible()) { int currentAnnotationOffset = this.contentsOffset; generateAnnotation(annotation, currentAnnotationOffset); @@ -3787,7 +3798,9 @@ public class ClassFile implements TypeConstants, TypeIds { Annotation annotation; if ((annotation = annotations[i].getPersistibleAnnotation()) == null) continue; // already packaged into container. long annotationMask = annotation.resolvedType != null ? annotation.resolvedType.getAnnotationTagBits() & TagBits.AnnotationTargetMASK : 0; - if (annotationMask != 0 && (annotationMask & targetMask) == 0) continue; + if (annotationMask != 0 && (annotationMask & targetMask) == 0) { + if (!jdk16packageInfoAnnotation(annotationMask, targetMask)) continue; + } if (annotation.isRuntimeVisible() || annotation.isRuntimeTypeVisible()) { visibleAnnotationsCounter--; int currentAnnotationOffset = this.contentsOffset; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java index 11b48c8d1..cc8bae713 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java @@ -1016,6 +1016,11 @@ public abstract class Annotation extends Expression { case Binding.PACKAGE : if ((metaTagBits & TagBits.AnnotationForPackage) != 0) return true; + else if (scope.compilerOptions().sourceLevel <= ClassFileConstants.JDK1_6) { + SourceTypeBinding sourceType = (SourceTypeBinding) annotation.recipient; + if (CharOperation.equals(sourceType.sourceName, TypeConstants.PACKAGE_INFO_NAME)) + return true; + } break; case Binding.TYPE_USE : if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) { 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 ca3462fc6..b1b474a22 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -16,6 +16,7 @@ * Bug 427438 - [1.8][compiler] NPE at org.eclipse.jdt.internal.compiler.ast.ConditionalExpression.generateCode(ConditionalExpression.java:280) * Bug 429403 - [1.8][null] null mismatch from type arguments is not reported at field initializer * Bug 453483 - [compiler][null][loop] Improve null analysis for loops + * Bug 458396 - NPE in CodeStream.invoke() * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation *******************************************************************************/ @@ -107,7 +108,7 @@ public FlowInfo analyseCode(MethodScope initializationScope, FlowContext flowCon if (this.binding != null && this.binding.isValidBinding() && this.binding.isStatic() - && this.binding.constant() == Constant.NotAConstant + && this.binding.constant(initializationScope) == Constant.NotAConstant && this.binding.declaringClass.isNestedType() //{ObjectTeams: no problem with static fields in roles ;-) && !this.binding.declaringClass.isRole() @@ -387,7 +388,7 @@ public void resolve(MethodScope initializationScope) { } finally { initializationScope.initializedField = previousField; initializationScope.lastVisibleFieldID = previousFieldID; - if (this.binding.constant() == null) + if (this.binding.constant(initializationScope) == null) this.binding.setConstant(Constant.NotAConstant); } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java index c091a1e4e..aa2d37e2b 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -15,6 +15,7 @@ * bug 383368 - [compiler][null] syntactic null analysis for field references * Bug 412203 - [compiler] Internal compiler error: java.lang.IllegalArgumentException: info cannot be null * Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec) + * Bug 458396 - NPE in CodeStream.invoke() * Jesper S Moller - Contributions for * Bug 378674 - "The method can be declared as static" is wrong *******************************************************************************/ @@ -573,7 +574,7 @@ public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo f FieldBinding codegenBinding = this.binding.original(); if (this.binding.isPrivate()) { if ((TypeBinding.notEquals(currentScope.enclosingSourceType(), codegenBinding.declaringClass)) - && this.binding.constant() == Constant.NotAConstant) { + && this.binding.constant(currentScope) == Constant.NotAConstant) { if (this.syntheticAccessors == null) this.syntheticAccessors = new MethodBinding[2]; this.syntheticAccessors[isReadAccess ? FieldReference.READ : FieldReference.WRITE] = @@ -802,7 +803,7 @@ public TypeBinding resolveType(BlockScope scope) { scope.problemReporter().deprecatedField(fieldBinding, this); } boolean isImplicitThisRcv = this.receiver.isImplicitThis(); - this.constant = isImplicitThisRcv ? fieldBinding.constant() : Constant.NotAConstant; + this.constant = isImplicitThisRcv ? fieldBinding.constant(scope) : Constant.NotAConstant; if (fieldBinding.isStatic()) { // static field accessed through receiver? legal but unoptimal (optional warning) if (!(isImplicitThisRcv diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java index 1c25bb995..04b93a476 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -16,6 +16,7 @@ * bug 368546 - [compiler][resource] Avoid remaining false positives found when compiling the Eclipse SDK * bug 345305 - [compiler][null] Compiler misidentifies a case of "variable can only be null" * Bug 414380 - [compiler][internal] QualifiedNameReference#indexOfFirstFieldBinding does not point to the first field + * Bug 458396 - NPE in CodeStream.invoke() * Jesper S Moller - Contributions for * bug 382721 - [1.8][compiler] Effectively final variables needs special treatment * bug 331649 - [compiler][null] consider null annotations for fields @@ -764,7 +765,7 @@ public TypeBinding getOtherFieldBindings(BlockScope scope) { TypeBinding type = ((VariableBinding) this.binding).type; int index = this.indexOfFirstFieldBinding; if (index == length) { // restrictiveFlag == FIELD - this.constant = ((FieldBinding) this.binding).constant(); + this.constant = ((FieldBinding) this.binding).constant(scope); // perform capture conversion if read access return (type != null && (this.bits & ASTNode.IsStrictlyAssigned) == 0) ? type.capture(scope, this.sourceStart, this.sourceEnd) @@ -776,7 +777,7 @@ public TypeBinding getOtherFieldBindings(BlockScope scope) { this.otherDepths = new int[otherBindingsLength]; // fill the first constant (the one of the binding) - this.constant = ((VariableBinding) this.binding).constant(); + this.constant = ((VariableBinding) this.binding).constant(scope); // save first depth, since will be updated by visibility checks of other bindings int firstDepth = (this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT; // iteration on each field @@ -808,7 +809,7 @@ public TypeBinding getOtherFieldBindings(BlockScope scope) { } // constant propagation can only be performed as long as the previous one is a constant too. if (this.constant != Constant.NotAConstant) { - this.constant = field.constant(); + this.constant = field.constant(scope); } if (field.isStatic()) { @@ -825,7 +826,7 @@ public TypeBinding getOtherFieldBindings(BlockScope scope) { } // check if accessing enum static field in initializer if ((TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body - && field.constant() == Constant.NotAConstant + && field.constant(scope) == Constant.NotAConstant && !methodScope.isStatic && methodScope.isInsideInitializerOrConstructor()) { scope.problemReporter().enumStaticFieldUsedDuringInitialization(field, this); @@ -1012,7 +1013,7 @@ public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, Fl public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FieldBinding fieldBinding, int index, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) return; // index == 0 denotes the first fieldBinding, index > 0 denotes one of the 'otherBindings', index < 0 denotes a write access (to last binding) - if (fieldBinding.constant() != Constant.NotAConstant) + if (fieldBinding.constant(currentScope) != Constant.NotAConstant) return; //{ObjectTeams: accessor for some role/team situations, too: @@ -1240,7 +1241,7 @@ public TypeBinding resolveType(BlockScope scope) { // check if accessing enum static field in initializer if (declaringClass.isEnum()) { if ((TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body - && fieldBinding.constant() == Constant.NotAConstant + && fieldBinding.constant(scope) == Constant.NotAConstant && !methodScope.isStatic && methodScope.isInsideInitializerOrConstructor()) { scope.problemReporter().enumStaticFieldUsedDuringInitialization(fieldBinding, this); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java index b08169202..8ddad992c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java @@ -84,7 +84,8 @@ import org.eclipse.jdt.internal.compiler.parser.Parser; public class ReferenceExpression extends FunctionalExpression implements IPolyExpression, InvocationSite { // secret variable name - private static final String SecretReceiverVariableName = " receiver_"; //$NON-NLS-1$ + private static final String SecretReceiverVariableName = " rec_"; //$NON-NLS-1$ + private static final char[] ImplicitArgName = " arg".toCharArray(); //$NON-NLS-1$ // secret variable for codegen public LocalVariableBinding receiverVariable; public Expression lhs; @@ -173,7 +174,7 @@ public class ReferenceExpression extends FunctionalExpression implements IPolyEx LambdaExpression implicitLambda = new LambdaExpression(this.compilationResult, false, (this.binding.modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0); Argument [] arguments = new Argument[argc]; for (int i = 0; i < argc; i++) - arguments[i] = new Argument(("arg" + i).toCharArray(), 0, null, 0, true); //$NON-NLS-1$ + arguments[i] = new Argument(CharOperation.append(ImplicitArgName, Integer.toString(i).toCharArray()), 0, null, 0, true); implicitLambda.setArguments(arguments); implicitLambda.setExpressionContext(this.expressionContext); implicitLambda.setExpectedType(this.expectedType); @@ -181,8 +182,8 @@ public class ReferenceExpression extends FunctionalExpression implements IPolyEx int parameterShift = this.receiverPrecedesParameters ? 1 : 0; Expression [] argv = new SingleNameReference[argc - parameterShift]; for (int i = 0, length = argv.length; i < length; i++) { - String name = "arg" + (i + parameterShift); //$NON-NLS-1$ - argv[i] = new SingleNameReference(name.toCharArray(), 0); + char[] name = CharOperation.append(ImplicitArgName, Integer.toString((i + parameterShift)).toCharArray()); + argv[i] = new SingleNameReference(name, 0); } boolean generateSecretReceiverVariable = shouldGenerateSecretReceiverVariable(); if (isMethodReference()) { @@ -194,7 +195,8 @@ public class ReferenceExpression extends FunctionalExpression implements IPolyEx MessageSend message = new MessageSend(); message.selector = this.selector; Expression receiver = generateSecretReceiverVariable ? new SingleNameReference(this.receiverVariable.name, 0) : copy.lhs; - message.receiver = this.receiverPrecedesParameters ? new SingleNameReference("arg0".toCharArray(), 0) : receiver; //$NON-NLS-1$ + message.receiver = this.receiverPrecedesParameters ? + new SingleNameReference(CharOperation.append(ImplicitArgName, Integer.toString(0).toCharArray()), 0) : receiver; message.typeArguments = copy.typeArguments; message.arguments = argv; implicitLambda.setBody(message); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java index 0fed7c7b7..1970af292 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -15,7 +15,8 @@ * bug 331649 - [compiler][null] consider null annotations for fields * bug 383368 - [compiler][null] syntactic null analysis for field references * Bug 412203 - [compiler] Internal compiler error: java.lang.IllegalArgumentException: info cannot be null - * Jesper S Moller - <jesper@selskabet.org> - Contributions for + * Bug 458396 - NPE in CodeStream.invoke() + * Jesper S Moller - <jesper@selskabet.org> - Contributions for * bug 382721 - [1.8][compiler] Effectively final variables needs special treatment * bug 378674 - "The method can be declared as static" is wrong * bug 404657 - [1.8][compiler] Analysis for effectively final variables fails to consider loops @@ -227,7 +228,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl public TypeBinding checkFieldAccess(BlockScope scope) { FieldBinding fieldBinding = (FieldBinding) this.binding; - this.constant = fieldBinding.constant(); + this.constant = fieldBinding.constant(scope); this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits this.bits |= Binding.FIELD; @@ -1051,7 +1052,7 @@ public TypeBinding resolveType(BlockScope scope) { scope.problemReporter().cannotReferToNonFinalOuterLocal((LocalVariableBinding)variable, this); } variableType = variable.type; - this.constant = (this.bits & ASTNode.IsStrictlyAssigned) == 0 ? variable.constant() : Constant.NotAConstant; + this.constant = (this.bits & ASTNode.IsStrictlyAssigned) == 0 ? variable.constant(scope) : Constant.NotAConstant; } else { // a field variableType = checkFieldAccess(scope); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java index 16a73814f..31a012527 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -15,15 +15,18 @@ * Bug 417295 - [1.8[[null] Massage type annotated null analysis to gel well with deep encoded type bindings. * Bug 447088 - [null] @Nullable on fully qualified field type is ignored * Bug 435805 - [1.8][compiler][null] Java 8 compiler does not recognize declaration style null annotations + * Bug 458396 - NPE in CodeStream.invoke() *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.Constant; +import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; import org.eclipse.objectteams.otdt.core.compiler.IOTConstants; import org.eclipse.objectteams.otdt.core.exceptions.InternalCompilerError; import org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.SingleValueAttribute; @@ -303,6 +306,18 @@ public Constant constant() { return fieldConstant; } +public Constant constant(Scope scope) { + if (this.constant != null) + return this.constant; + ProblemReporter problemReporter = scope.problemReporter(); + IErrorHandlingPolicy suspendedPolicy = problemReporter.suspendTempErrorHandlingPolicy(); + try { + return constant(); + } finally { + problemReporter.resumeTempErrorHandlingPolicy(suspendedPolicy); + } +} + public void fillInDefaultNonNullness(FieldDeclaration sourceField, Scope scope) { LookupEnvironment environment = scope.environment(); if ( this.type != null diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java index 6da18f4af..b866bfa1c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java @@ -1167,8 +1167,6 @@ void faultInTypesForFieldsAndMethods() { ReferenceBinding enclosingType = enclosingType(); if (enclosingType != null && enclosingType.isViewedAsDeprecated() && !isDeprecated()) this.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; - fields(); - methods(); //{ObjectTeams: do not cache memberTypes.length! // During faultInTypesForFieldsAndMethods(), memberTypes may be added (role files, on demand) @@ -1180,6 +1178,8 @@ void faultInTypesForFieldsAndMethods() { if (!this.memberTypes[i].isBinaryBinding()) // roles could be binary contained in source //carp} ((SourceTypeBinding) this.memberTypes[i]).faultInTypesForFieldsAndMethods(); + fields(); + methods(); } // NOTE: the type of each field of a source type is resolved when needed public FieldBinding[] fields() { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java index 6cb45bda2..8a74de97a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -12,6 +12,7 @@ * Stephan Herrmann - Contribution for * bug 331649 - [compiler][null] consider null annotations for fields * Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis + * Bug 458396 - NPE in CodeStream.invoke() *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -62,6 +63,14 @@ public abstract class VariableBinding public Constant constant() { return this.constant; } + + /** + * Call this variant during resolve / analyse, so we can handle the case + * when a tentative lambda resolve triggers resolving of outside code. + */ + public Constant constant(Scope scope) { + return constant(); + } public abstract AnnotationBinding[] getAnnotations(); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java index f32ec75ef..d2cd8682d 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -4531,6 +4531,12 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { throw new InvalidInputException(INVALID_HEXA); } } else if (getNextChar('p', 'P') >= 0) { // consume next character + if (end == start) { // Has no digits before exponent + if (this.sourceLevel < ClassFileConstants.JDK1_5) { + throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + } + throw new InvalidInputException(INVALID_HEXA); + } this.unicodeAsBackSlash = false; if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\') && (this.source[this.currentPosition] == 'u')) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java index 28e22a0bc..a43819cd6 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -8,6 +8,8 @@ * Contributors: * IBM Corporation - initial API and implementation * Technical University Berlin - extended API and implementation + * Stephan Herrmann - Contribution for + * Bug 458396 - NPE in CodeStream.invoke() *******************************************************************************/ package org.eclipse.jdt.internal.compiler.problem; @@ -44,6 +46,9 @@ public class ProblemHandler { public IErrorHandlingPolicy policy; public final IProblemFactory problemFactory; public final CompilerOptions options; + + /* When temporarily switching policies, store here the original root policy (for temporary resume). */ + private IErrorHandlingPolicy rootPolicy; //{ObjectTeams: support for passing a rechecker: public IProblemRechecker rechecker; @@ -360,8 +365,27 @@ public void record(CategorizedProblem problem, CompilationResult unitResult, Ref } /** @return old policy. */ public IErrorHandlingPolicy switchErrorHandlingPolicy(IErrorHandlingPolicy newPolicy) { + if (this.rootPolicy == null) + this.rootPolicy = this.policy; IErrorHandlingPolicy presentPolicy = this.policy; this.policy = newPolicy; return presentPolicy; } +/** + * Temporarily suspend a temporary error handling policy. + * @return old policy. + */ +public IErrorHandlingPolicy suspendTempErrorHandlingPolicy() { + IErrorHandlingPolicy presentPolicy = this.policy; + if (this.rootPolicy != null) + this.policy = this.rootPolicy; + return presentPolicy; +} +/** + * Resume from a corresponding {@link #suspendTempErrorHandlingPolicy()}. + * @param previousPolicy the result value of the matching suspend call + */ +public void resumeTempErrorHandlingPolicy(IErrorHandlingPolicy previousPolicy) { + this.policy = previousPolicy; +} } |