View | Details | Raw Unified | Return to bug 240815 | Differences between
and this patch

Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java (-20 / +24 lines)
Lines 1656-1661 Link Here
1656
	 */
1656
	 */
1657
	synchronized ITypeBinding resolveWellKnownType(String name) {
1657
	synchronized ITypeBinding resolveWellKnownType(String name) {
1658
		if (this.scope == null) return null;
1658
		if (this.scope == null) return null;
1659
		ITypeBinding typeBinding = null;
1659
		try {
1660
		try {
1660
			if (("boolean".equals(name))//$NON-NLS-1$
1661
			if (("boolean".equals(name))//$NON-NLS-1$
1661
				|| ("char".equals(name))//$NON-NLS-1$
1662
				|| ("char".equals(name))//$NON-NLS-1$
Lines 1666-1714 Link Here
1666
				|| ("float".equals(name))//$NON-NLS-1$
1667
				|| ("float".equals(name))//$NON-NLS-1$
1667
				|| ("double".equals(name))//$NON-NLS-1$
1668
				|| ("double".equals(name))//$NON-NLS-1$
1668
				|| ("void".equals(name))) {//$NON-NLS-1$
1669
				|| ("void".equals(name))) {//$NON-NLS-1$
1669
				return this.getTypeBinding(Scope.getBaseType(name.toCharArray()));
1670
				typeBinding = this.getTypeBinding(Scope.getBaseType(name.toCharArray()));
1670
			} else if ("java.lang.Object".equals(name)) {//$NON-NLS-1$
1671
			} else if ("java.lang.Object".equals(name)) {//$NON-NLS-1$
1671
				return this.getTypeBinding(this.scope.getJavaLangObject());
1672
				typeBinding = this.getTypeBinding(this.scope.getJavaLangObject());
1672
			} else if ("java.lang.String".equals(name)) {//$NON-NLS-1$
1673
			} else if ("java.lang.String".equals(name)) {//$NON-NLS-1$
1673
				return this.getTypeBinding(this.scope.getJavaLangString());
1674
				typeBinding = this.getTypeBinding(this.scope.getJavaLangString());
1674
			} else if ("java.lang.StringBuffer".equals(name)) {//$NON-NLS-1$
1675
			} else if ("java.lang.StringBuffer".equals(name)) {//$NON-NLS-1$
1675
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_STRINGBUFFER, 3));
1676
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_STRINGBUFFER, 3));
1676
			} else if ("java.lang.Throwable".equals(name)) {//$NON-NLS-1$
1677
			} else if ("java.lang.Throwable".equals(name)) {//$NON-NLS-1$
1677
				return this.getTypeBinding(this.scope.getJavaLangThrowable());
1678
				typeBinding = this.getTypeBinding(this.scope.getJavaLangThrowable());
1678
			} else if ("java.lang.Exception".equals(name)) {//$NON-NLS-1$
1679
			} else if ("java.lang.Exception".equals(name)) {//$NON-NLS-1$
1679
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_EXCEPTION, 3));
1680
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_EXCEPTION, 3));
1680
			} else if ("java.lang.RuntimeException".equals(name)) {//$NON-NLS-1$
1681
			} else if ("java.lang.RuntimeException".equals(name)) {//$NON-NLS-1$
1681
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_RUNTIMEEXCEPTION, 3));
1682
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_RUNTIMEEXCEPTION, 3));
1682
			} else if ("java.lang.Error".equals(name)) {//$NON-NLS-1$
1683
			} else if ("java.lang.Error".equals(name)) {//$NON-NLS-1$
1683
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_ERROR, 3));
1684
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_ERROR, 3));
1684
			} else if ("java.lang.Class".equals(name)) {//$NON-NLS-1$
1685
			} else if ("java.lang.Class".equals(name)) {//$NON-NLS-1$
1685
				return this.getTypeBinding(this.scope.getJavaLangClass());
1686
				typeBinding = this.getTypeBinding(this.scope.getJavaLangClass());
1686
			} else if ("java.lang.Cloneable".equals(name)) {//$NON-NLS-1$
1687
			} else if ("java.lang.Cloneable".equals(name)) {//$NON-NLS-1$
1687
				return this.getTypeBinding(this.scope.getJavaLangCloneable());
1688
				typeBinding = this.getTypeBinding(this.scope.getJavaLangCloneable());
1688
			} else if ("java.io.Serializable".equals(name)) {//$NON-NLS-1$
1689
			} else if ("java.io.Serializable".equals(name)) {//$NON-NLS-1$
1689
				return this.getTypeBinding(this.scope.getJavaIoSerializable());
1690
				typeBinding = this.getTypeBinding(this.scope.getJavaIoSerializable());
1690
			} else if ("java.lang.Boolean".equals(name)) {//$NON-NLS-1$
1691
			} else if ("java.lang.Boolean".equals(name)) {//$NON-NLS-1$
1691
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_BOOLEAN, 3));
1692
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_BOOLEAN, 3));
1692
			} else if ("java.lang.Byte".equals(name)) {//$NON-NLS-1$
1693
			} else if ("java.lang.Byte".equals(name)) {//$NON-NLS-1$
1693
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_BYTE, 3));
1694
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_BYTE, 3));
1694
			} else if ("java.lang.Character".equals(name)) {//$NON-NLS-1$
1695
			} else if ("java.lang.Character".equals(name)) {//$NON-NLS-1$
1695
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_CHARACTER, 3));
1696
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_CHARACTER, 3));
1696
			} else if ("java.lang.Double".equals(name)) {//$NON-NLS-1$
1697
			} else if ("java.lang.Double".equals(name)) {//$NON-NLS-1$
1697
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_DOUBLE, 3));
1698
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_DOUBLE, 3));
1698
			} else if ("java.lang.Float".equals(name)) {//$NON-NLS-1$
1699
			} else if ("java.lang.Float".equals(name)) {//$NON-NLS-1$
1699
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_FLOAT, 3));
1700
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_FLOAT, 3));
1700
			} else if ("java.lang.Integer".equals(name)) {//$NON-NLS-1$
1701
			} else if ("java.lang.Integer".equals(name)) {//$NON-NLS-1$
1701
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_INTEGER, 3));
1702
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_INTEGER, 3));
1702
			} else if ("java.lang.Long".equals(name)) {//$NON-NLS-1$
1703
			} else if ("java.lang.Long".equals(name)) {//$NON-NLS-1$
1703
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_LONG, 3));
1704
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_LONG, 3));
1704
			} else if ("java.lang.Short".equals(name)) {//$NON-NLS-1$
1705
			} else if ("java.lang.Short".equals(name)) {//$NON-NLS-1$
1705
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_SHORT, 3));
1706
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_SHORT, 3));
1706
			} else if ("java.lang.Void".equals(name)) {//$NON-NLS-1$
1707
			} else if ("java.lang.Void".equals(name)) {//$NON-NLS-1$
1707
				return this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_VOID, 3));
1708
				typeBinding = this.getTypeBinding(this.scope.getType(TypeConstants.JAVA_LANG_VOID, 3));
1708
			}
1709
			}
1709
		} catch (AbortCompilation e) {
1710
		} catch (AbortCompilation e) {
1710
			// ignore missing types
1711
			// ignore missing types
1711
		}
1712
		}
1713
		if (typeBinding != null && !typeBinding.isRecovered()) {
1714
			return typeBinding;
1715
		}
1712
		return null;
1716
		return null;
1713
	}
1717
	}
1714
1718
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (+7 lines)
Lines 2231-2236 Link Here
2231
			return new ProblemReferenceBinding(qName, environment().createMissingType(compilationUnitScope().getCurrentPackage(), qName), ProblemReasons.NotFound);
2231
			return new ProblemReferenceBinding(qName, environment().createMissingType(compilationUnitScope().getCurrentPackage(), qName), ProblemReasons.NotFound);
2232
		}
2232
		}
2233
		if (!binding.isValidBinding()) {
2233
		if (!binding.isValidBinding()) {
2234
			if (binding instanceof PackageBinding) {
2235
				char[][] qName = new char[][] { compoundName[0] };
2236
				return new ProblemReferenceBinding(
2237
						qName,
2238
						environment().createMissingType(null, qName),
2239
						ProblemReasons.NotFound);
2240
			}
2234
			return (ReferenceBinding) binding;
2241
			return (ReferenceBinding) binding;
2235
		}
2242
		}
2236
		int currentIndex = 1;
2243
		int currentIndex = 1;
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-1 / +61 lines)
Lines 23-28 Link Here
23
import org.eclipse.core.runtime.OperationCanceledException;
23
import org.eclipse.core.runtime.OperationCanceledException;
24
import org.eclipse.jdt.core.Flags;
24
import org.eclipse.jdt.core.Flags;
25
import org.eclipse.jdt.core.IClassFile;
25
import org.eclipse.jdt.core.IClassFile;
26
import org.eclipse.jdt.core.IClasspathEntry;
26
import org.eclipse.jdt.core.ICompilationUnit;
27
import org.eclipse.jdt.core.ICompilationUnit;
27
import org.eclipse.jdt.core.IField;
28
import org.eclipse.jdt.core.IField;
28
import org.eclipse.jdt.core.IInitializer;
29
import org.eclipse.jdt.core.IInitializer;
Lines 121-127 Link Here
121
	static {
122
	static {
122
//		TESTS_NAMES = new String[] {"test0602"};
123
//		TESTS_NAMES = new String[] {"test0602"};
123
//		TESTS_RANGE = new int[] { 670, -1 };
124
//		TESTS_RANGE = new int[] { 670, -1 };
124
//		TESTS_NUMBERS =  new int[] { 688 };
125
//		TESTS_NUMBERS =  new int[] { 689, 690 };
125
	}
126
	}
126
	public static Test suite() {
127
	public static Test suite() {
127
		return buildModelTestSuite(ASTConverterTestAST3_2.class);
128
		return buildModelTestSuite(ASTConverterTestAST3_2.class);
Lines 9722-9725 Link Here
9722
		ASTNode result = runConversion(AST.JLS3, sourceUnit, sourceRange.getOffset() + sourceRange.getLength() / 2, false);
9723
		ASTNode result = runConversion(AST.JLS3, sourceUnit, sourceRange.getOffset() + sourceRange.getLength() / 2, false);
9723
		assertNotNull(result);
9724
		assertNotNull(result);
9724
	}
9725
	}
9726
	/**
9727
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=240815
9728
	 */
9729
	public void test0689() throws JavaModelException {
9730
		IJavaProject project = getJavaProject("Converter");
9731
		if (project == null) {
9732
			return;
9733
		}
9734
		// replace JCL_LIB with JCL15_LIB, and JCL_SRC with JCL15_SRC
9735
		IClasspathEntry[] classpath = project.getRawClasspath();
9736
		try {
9737
			ArrayList newClasspathEntries = new ArrayList();
9738
			for (int i = 0, length = classpath.length; i < length; i++) {
9739
				IClasspathEntry entry = classpath[i];
9740
				if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) {
9741
					newClasspathEntries.add(entry);
9742
				}
9743
			}
9744
			IClasspathEntry[] newClasspath = new IClasspathEntry[newClasspathEntries.size()];
9745
			newClasspathEntries.toArray(newClasspath);
9746
			project.setRawClasspath(newClasspath, null);
9747
			ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0689", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
9748
			ASTNode result = runConversion(AST.JLS3, sourceUnit, true, true);
9749
			assertNotNull(result);
9750
			ITypeBinding typeBinding = result.getAST().resolveWellKnownType("java.lang.Boolean");
9751
			assertNull("Should be null", typeBinding);
9752
		} finally {
9753
			project.setRawClasspath(classpath, null);
9754
		}	}
9755
	/**
9756
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=240815
9757
	 */
9758
	public void test0690() throws JavaModelException {
9759
		IJavaProject project = getJavaProject("Converter");
9760
		if (project == null) {
9761
			return;
9762
		}
9763
		// replace JCL_LIB with JCL15_LIB, and JCL_SRC with JCL15_SRC
9764
		IClasspathEntry[] classpath = project.getRawClasspath();
9765
		try {
9766
			ArrayList newClasspathEntries = new ArrayList();
9767
			for (int i = 0, length = classpath.length; i < length; i++) {
9768
				IClasspathEntry entry = classpath[i];
9769
				if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) {
9770
					newClasspathEntries.add(entry);
9771
				}
9772
			}
9773
			IClasspathEntry[] newClasspath = new IClasspathEntry[newClasspathEntries.size()];
9774
			newClasspathEntries.toArray(newClasspath);
9775
			project.setRawClasspath(newClasspath, null);
9776
			ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0690", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
9777
			ASTNode result = runConversion(AST.JLS3, sourceUnit, true, true, true);
9778
			assertNotNull(result);
9779
			ITypeBinding typeBinding = result.getAST().resolveWellKnownType("java.lang.Boolean");
9780
			assertNull("Should be null", typeBinding);
9781
		} finally {
9782
			project.setRawClasspath(classpath, null);
9783
		}
9784
	}
9725
}
9785
}
(-)plugin.xml (-1 / +1 lines)
Lines 38-44 Link Here
38
	</extension>
38
	</extension>
39
39
40
	<!-- Extra Java-like file extensions -->
40
	<!-- Extra Java-like file extensions -->
41
	<extension point="org.eclipse.core.runtime.contentTypes">
41
	<extension point="org.eclipse.core.contenttype.contentTypes"> 
42
	    <file-association 
42
	    <file-association 
43
	        content-type="org.eclipse.jdt.core.javaSource"
43
	        content-type="org.eclipse.jdt.core.javaSource"
44
	        file-extensions="foo,bar"/>
44
	        file-extensions="foo,bar"/>
(-)workspace/Converter/src/test0690/X.java (+3 lines)
Added Link Here
1
package test0690;
2
public class X {
3
}
(-)workspace/Converter/src/test0689/X.java (+3 lines)
Added Link Here
1
package test0689;
2
public class X {
3
}

Return to bug 240815