diff options
author | Till Brychcy | 2017-09-15 20:31:55 +0000 |
---|---|---|
committer | Stephan Herrmann | 2017-09-16 12:37:08 +0000 |
commit | ac3e5d5ce47edc6a64f2f6e3bf5db4952cedca2f (patch) | |
tree | bbd66a9d428a77be8c1e93fbdf3a86f766063508 | |
parent | 773355c1c1569cde7c697292cc71abc0ec95f937 (diff) | |
download | eclipse.jdt.core-ac3e5d5ce47edc6a64f2f6e3bf5db4952cedca2f.tar.gz eclipse.jdt.core-ac3e5d5ce47edc6a64f2f6e3bf5db4952cedca2f.tar.xz eclipse.jdt.core-ac3e5d5ce47edc6a64f2f6e3bf5db4952cedca2f.zip |
thrown"
Change-Id: I2865b00a42a04c3e6a998fc1b8c5b65e071f1493
3 files changed, 65 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java index fb9a98b100..b221591c24 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java @@ -165,6 +165,7 @@ public static Test suite() { since_9.add(Deprecated9Test.class); since_9.add(ModuleAttributeTests.class); since_9.add(AutomaticModuleNamingTest.class); + since_9.add(UnnamedModuleTest.class); // Build final test suite TestSuite all = new TestSuite(TestAll.class.getName()); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnnamedModuleTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnnamedModuleTest.java new file mode 100644 index 0000000000..296df8d1c6 --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnnamedModuleTest.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2017 Till Brychcy 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * + * Contributors: + * Till Brychcy - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import junit.framework.Test; + +public class UnnamedModuleTest extends AbstractRegressionTest9 { + +static { +// TESTS_NAMES = new String[] { "testBugXXX" }; +// TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 }; +// TESTS_RANGE = new int[] { 11, -1 }; +} +public UnnamedModuleTest(String name) { + super(name); +} +public static Test suite() { + return buildMinimalComplianceTestSuite(testClass(), F_9); +} + +public static Class<UnnamedModuleTest> testClass() { + return UnnamedModuleTest.class; +} + +public void testBug522327() { + runConformTest( + new String[] { + "nonmodular/ProblemWithThrowable.java", + "package nonmodular;\n" + + "\n" + + "import java.io.IOException;\n" + + "import java.sql.SQLException;\n" + + "\n" + + "public class ProblemWithThrowable {\n" + + " public void saveProperties() throws IOException {\n" + + " }\n" + + "}\n" + + "", + } + ); +} +} 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 c2db451907..c95e3f15a6 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 @@ -1651,11 +1651,17 @@ private ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean ReferenceBinding binding = getCachedType(compoundName); if (binding == null) { PackageBinding packageBinding = computePackageFrom(compoundName, false /* valid pkg */); - binding = new UnresolvedReferenceBinding(compoundName, packageBinding); - if (wasMissingType) { - binding.tagBits |= TagBits.HasMissingType; // record it was bound to a missing type + if(this.useModuleSystem) { + // the package might not have been seen in getCachedType, so retry + binding = packageBinding.getType0(compoundName[compoundName.length - 1]); + } + if(binding == null) { + binding = new UnresolvedReferenceBinding(compoundName, packageBinding); + if (wasMissingType) { + binding.tagBits |= TagBits.HasMissingType; // record it was bound to a missing type + } + packageBinding.addType(binding); } - packageBinding.addType(binding); } else if (binding == TheNotFoundType) { // report the missing class file first if (!wasMissingType) { |