Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java33
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java81
3 files changed, 99 insertions, 17 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index f8ca253972..1f67c69eaf 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -17750,7 +17750,7 @@ public void testBug540264() {
);
}
public void testBug542707_1() {
- if (this.complianceLevel < ClassFileConstants.JDK12) return; // switch expression
+ if (this.complianceLevel < ClassFileConstants.JDK13) return; // switch expression
// switch expression has a functional type with interesting type inference and various null issues:
Runner runner = new Runner();
runner.customOptions = getCompilerOptions();
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
index 592a418dc2..ce9e6cf0d0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
@@ -8797,4 +8797,37 @@ public class StackMapAttributeTest extends AbstractRegressionTest {
},
"SUCCESS");
}
+ public void test551368_3() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class B {\n" +
+ " public boolean bar() {\n" +
+ " return false;\n" +
+ " }\n" +
+ " public void foo() {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " \n" +
+ " public B foo(boolean test) {\n" +
+ " B b =\n" +
+ " test ?\n" +
+ " new B() {\n" +
+ " @Override\n" +
+ " public boolean bar() {\n" +
+ " return true;\n" +
+ " }\n" +
+ " } :\n" +
+ " new B();\n" +
+ " b.foo();\n" +
+ " return b;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}",
+ },
+ "SUCCESS");
+ }
}
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 81503d67a0..578d000f53 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
@@ -5917,32 +5917,68 @@ public class ClassFile implements TypeConstants, TypeIds {
return scope.createArrayType(baseType, dimensions);
} else {
// array of object types
- TypeBinding type = (TypeBinding) scope.getTypeOrPackage(
- CharOperation.splitOn('/', CharOperation.subarray(typeConstantPoolName, dimensions + 1, typeConstantPoolName.length - 1)));
+ char[] typeName = CharOperation.subarray(typeConstantPoolName, dimensions + 1, typeConstantPoolName.length - 1);
+ TypeBinding type = (TypeBinding) scope.getTypeOrPackage(CharOperation.splitOn('/', typeName));
if (!type.isValidBinding()) {
ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) type;
if ((problemReferenceBinding.problemId() & ProblemReasons.InternalNameProvided) != 0) {
type = problemReferenceBinding.closestMatch();
+ } else if ((problemReferenceBinding.problemId() & ProblemReasons.NotFound) != 0 && this.innerClassesBindings != null) {
+ // check local inner types to see if this is a anonymous type
+ Set<TypeBinding> innerTypeBindings = this.innerClassesBindings.keySet();
+ for (TypeBinding binding : innerTypeBindings) {
+ if (CharOperation.equals(binding.constantPoolName(), typeName)) {
+ type = binding;
+ break;
+ }
+ }
}
}
return scope.createArrayType(type, dimensions);
}
} else {
- TypeBinding type = checkcast ?
- (TypeBinding) scope.getTypeOrPackage(
- CharOperation.splitOn('/', CharOperation.subarray(typeConstantPoolName, 0, typeConstantPoolName.length)))
- : (TypeBinding) scope.getTypeOrPackage(
- CharOperation.splitOn('/', CharOperation.subarray(typeConstantPoolName, 1, typeConstantPoolName.length - 1)));
+ char[] typeName = checkcast ? typeConstantPoolName : CharOperation.subarray(typeConstantPoolName, 1, typeConstantPoolName.length - 1);
+ TypeBinding type = (TypeBinding) scope.getTypeOrPackage(CharOperation.splitOn('/', typeName));
if (!type.isValidBinding()) {
ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) type;
if ((problemReferenceBinding.problemId() & ProblemReasons.InternalNameProvided) != 0) {
type = problemReferenceBinding.closestMatch();
+ } else if ((problemReferenceBinding.problemId() & ProblemReasons.NotFound) != 0 && this.innerClassesBindings != null) {
+ // check local inner types to see if this is a anonymous type
+ Set<TypeBinding> innerTypeBindings = this.innerClassesBindings.keySet();
+ for (TypeBinding binding : innerTypeBindings) {
+ if (CharOperation.equals(binding.constantPoolName(), typeName)) {
+ type = binding;
+ break;
+ }
+ }
}
}
return type;
}
}
+ private TypeBinding getNewTypeBinding(char[] typeConstantPoolName, Scope scope) {
+ char[] typeName = typeConstantPoolName;
+ TypeBinding type = (TypeBinding) scope.getTypeOrPackage(CharOperation.splitOn('/', typeName));
+ if (!type.isValidBinding()) {
+ ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) type;
+ if ((problemReferenceBinding.problemId() & ProblemReasons.InternalNameProvided) != 0) {
+ type = problemReferenceBinding.closestMatch();
+ } else if ((problemReferenceBinding.problemId() & ProblemReasons.NotFound) != 0 && this.innerClassesBindings != null) {
+ // check local inner types to see if this is a anonymous type
+ Set<TypeBinding> innerTypeBindings = this.innerClassesBindings.keySet();
+ for (TypeBinding binding : innerTypeBindings) {
+ if (CharOperation.equals(binding.constantPoolName(), typeName)) {
+ type = binding;
+ break;
+ }
+ }
+ }
+ }
+ return type;
+ }
+
private TypeBinding getANewArrayTypeBinding(char[] typeConstantPoolName, Scope scope) {
if (typeConstantPoolName[0] == '[') {
int dimensions = getDimensions(typeConstantPoolName);
@@ -5980,23 +6016,42 @@ public class ClassFile implements TypeConstants, TypeIds {
return scope.createArrayType(baseType, dimensions);
} else {
// array of object types
+ char[] elementTypeClassName = CharOperation.subarray(typeConstantPoolName, dimensions + 1, typeConstantPoolName.length - 1);
TypeBinding type = (TypeBinding) scope.getTypeOrPackage(
- CharOperation.splitOn('/', CharOperation.subarray(typeConstantPoolName, dimensions + 1, typeConstantPoolName.length - 1)));
+ CharOperation.splitOn('/', elementTypeClassName));
if (!type.isValidBinding()) {
ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) type;
if ((problemReferenceBinding.problemId() & ProblemReasons.InternalNameProvided) != 0) {
type = problemReferenceBinding.closestMatch();
+ } else if ((problemReferenceBinding.problemId() & ProblemReasons.NotFound) != 0 && this.innerClassesBindings != null) {
+ // check local inner types to see if this is a anonymous type
+ Set<TypeBinding> innerTypeBindings = this.innerClassesBindings.keySet();
+ for (TypeBinding binding : innerTypeBindings) {
+ if (CharOperation.equals(binding.constantPoolName(), elementTypeClassName)) {
+ type = binding;
+ break;
+ }
+ }
}
}
return scope.createArrayType(type, dimensions);
}
} else {
TypeBinding type = (TypeBinding) scope.getTypeOrPackage(
- CharOperation.splitOn('/', CharOperation.subarray(typeConstantPoolName, 0, typeConstantPoolName.length)));
+ CharOperation.splitOn('/', typeConstantPoolName));
if (!type.isValidBinding()) {
ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) type;
if ((problemReferenceBinding.problemId() & ProblemReasons.InternalNameProvided) != 0) {
type = problemReferenceBinding.closestMatch();
+ } else if ((problemReferenceBinding.problemId() & ProblemReasons.NotFound) != 0 && this.innerClassesBindings != null) {
+ // check local inner types to see if this is a anonymous type
+ Set<TypeBinding> innerTypeBindings = this.innerClassesBindings.keySet();
+ for (TypeBinding binding : innerTypeBindings) {
+ if (CharOperation.equals(binding.constantPoolName(), typeConstantPoolName)) {
+ type = binding;
+ break;
+ }
+ }
}
}
return type;
@@ -6870,13 +6925,7 @@ public class ClassFile implements TypeConstants, TypeIds {
constantPoolOffsets[utf8index] + 3, u2At(
poolContents, 1,
constantPoolOffsets[utf8index]));
- typeBinding = (TypeBinding) scope.getTypeOrPackage(CharOperation.splitOn('/', className));
- if (!typeBinding.isValidBinding()) {
- ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) typeBinding;
- if ((problemReferenceBinding.problemId() & ProblemReasons.InternalNameProvided) != 0) {
- typeBinding = problemReferenceBinding.closestMatch();
- }
- }
+ typeBinding = getNewTypeBinding(className, scope);
VerificationTypeInfo verificationTypeInfo = new VerificationTypeInfo(VerificationTypeInfo.ITEM_UNINITIALIZED, typeBinding);
verificationTypeInfo.offset = currentPC;
frame.addStackItem(verificationTypeInfo);

Back to the top