diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java index 6357803..250b66e 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java @@ -37,7 +37,7 @@ super(name); } static { -// TESTS_NAMES = new String[] { "testAddExternalLibFolder6" }; +// TESTS_NAMES = new String[] { "testBug360164" }; } public static Test suite() { TestSuite suite = (TestSuite) buildModelTestSuite(JavaProjectTests.class); @@ -2389,4 +2389,36 @@ deleteProject("JavaProjectTestsInvalidProject"); } } +// Bug 360164 - Compile error in XSDImpl +// test that we can tolerate if a 1.4 project refers to an enum inside a library. +public void testBug360164() throws IOException, CoreException { + String libPath = getWorkspacePath()+"JavaProjectTests/bin/bug360164.jar"; + try { + this.createJavaProject("P", new String[] {"src"}, new String[] {"JCL_LIB", libPath}, "bin", JavaCore.VERSION_1_4); + IFile file = createFile("/P/src/X.java", + "import p360164.Provider;\n" + + "import p360164.MyEnum;\n" + + "public class X {\n" + + " int foo(Provider p) {\n" + + " MyEnum e = p.getE();\n" + + " switch (e) {\n" + + " case ONE: return 1;\n" + + " case TWO: return 2;\n" + + " }\n" + + " return 0;\n" + + " }\n" + + "}" + ); + ICompilationUnit unit = (ICompilationUnit)JavaCore.create(file); + ProblemRequestor problemRequestor = new ProblemRequestor(); + WorkingCopyOwner owner = newWorkingCopyOwner(problemRequestor); + unit.getWorkingCopy(owner, null); + assertProblems("Unexpected problems", + "----------\n" + + "----------\n", + problemRequestor); + } finally { + this.deleteProject("P"); + } +} } diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/bin/bug360164.jar b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/bin/bug360164.jar new file mode 100644 index 0000000..134f3f6 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/bin/bug360164.jar Binary files differ diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java index 74dd0eb..8a84619 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java @@ -975,8 +975,14 @@ } public boolean hasTypeBit(int bit) { // ensure hierarchy is resolved, which will propagate bits down to us - superclass(); - superInterfaces(); + boolean wasToleratingMissingTypeProcessingAnnotations = this.environment.mayTolerateMissingType; + this.environment.mayTolerateMissingType = true; + try { + superclass(); + superInterfaces(); + } finally { + this.environment.mayTolerateMissingType = wasToleratingMissingTypeProcessingAnnotations; + } return (this.typeBits & bit) != 0; } private void initializeTypeVariable(TypeVariableBinding variable, TypeVariableBinding[] existingVariables, SignatureWrapper wrapper, char[][][] missingTypeNames) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java index 84d3e74..2e7fe97 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java @@ -74,6 +74,7 @@ private ArrayList missingTypes; Set typesBeingConnected; public boolean isProcessingAnnotations = false; + public boolean mayTolerateMissingType = false; final static int BUILD_FIELDS_AND_METHODS = 4; final static int BUILD_TYPE_HIERARCHY = 1; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java index 3038368..2da4984 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java @@ -55,7 +55,7 @@ } if (targetType == null || targetType == this) { // could not resolve any better, error was already reported against it // report the missing class file first - only if not resolving a previously missing type - if ((this.tagBits & TagBits.HasMissingType) == 0) { + if ((this.tagBits & TagBits.HasMissingType) == 0 && !environment.mayTolerateMissingType) { environment.problemReporter.isClassPathCorrect( this.compoundName, environment.unitBeingCompleted,