diff options
author | Shankha Banerjee | 2014-04-28 17:52:04 +0000 |
---|---|---|
committer | Stephan Herrmann | 2014-04-28 19:09:17 +0000 |
commit | 51eb8b8143716633a7515ed92273af51162b4257 (patch) | |
tree | 8200a31b9c16e157a1437b0b097139b1dcd683c6 | |
parent | 4f8754b531ef7a0f61f91d095d8127db2debc51a (diff) | |
download | eclipse.jdt.core-51eb8b8143716633a7515ed92273af51162b4257.tar.gz eclipse.jdt.core-51eb8b8143716633a7515ed92273af51162b4257.tar.xz eclipse.jdt.core-51eb8b8143716633a7515ed92273af51162b4257.zip |
Bug 425420 - NPE exception on standard Java build
Signed-off-by: Shankha Banerjee <shankhba@in.ibm.com>
3 files changed, 45 insertions, 16 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java index bd64a00d9a..6cffbf483b 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -604,4 +604,29 @@ public class BasicBuildTests extends BuilderTests { expectingNoProblems(); assertEquals("Incorrect value", 0, previous); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=425420 + public void testBug425420() throws JavaModelException { + IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + // don't env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ + env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ + + IPath path = env.addClass(root, "", "X", //$NON-NLS-1$ //$NON-NLS-2$ + "class X {\n" + + " void test() {\n" + + " int x = 0;\n" + + " int y = 0 >= 0 ? x : \"\"; \n" + + " }\n" + + "}"); + + fullBuild(projectPath); + expectingProblemsFor( + path, + "Problem : The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files [ resource : </Project/src/X.java> range : <0,1> category : <10> severity : <2>]" + ); + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java index e785703294..8eb91dbf0a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -91,6 +91,10 @@ public char[] shortReadableName() { return readableName(); } +public char[] sourceName() { + return this.compoundName.length == 0 ? null : this.compoundName[this.compoundName.length - 1]; // last segment of [java][util][Map$Entry] +} + public String toString() { StringBuffer buffer = new StringBuffer(10); buffer.append("ProblemType:[compoundName="); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index 6370feb4dd..60ad654257 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -2231,8 +2231,8 @@ public void finalVariableBound(TypeVariableBinding typeVariable, TypeReference t if (severity == ProblemSeverities.Ignore) return; this.handle( IProblem.FinalBoundForTypeVariable, - new String[] { new String(typeVariable.sourceName), new String(typeRef.resolvedType.readableName())}, - new String[] { new String(typeVariable.sourceName), new String(typeRef.resolvedType.shortReadableName())}, + new String[] { new String(typeVariable.sourceName()), new String(typeRef.resolvedType.readableName())}, + new String[] { new String(typeVariable.sourceName()), new String(typeRef.resolvedType.shortReadableName())}, severity, typeRef.sourceStart, typeRef.sourceEnd); @@ -3579,7 +3579,7 @@ public void invalidConstructor(Statement statement, MethodBinding targetConstruc new String(shownConstructor.declaringClass.readableName()), typesAsString(invocationArguments, false), new String(inferredTypeArgument.readableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) }, new String[] { new String(shownConstructor.declaringClass.sourceName()), @@ -3587,7 +3587,7 @@ public void invalidConstructor(Statement statement, MethodBinding targetConstruc new String(shownConstructor.declaringClass.shortReadableName()), typesAsString(invocationArguments, true), new String(inferredTypeArgument.shortReadableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) }, sourceStart, sourceEnd); @@ -4127,7 +4127,7 @@ public void invalidMethod(MessageSend messageSend, MethodBinding method) { new String(shownMethod.declaringClass.readableName()), typesAsString(invocationArguments, false), new String(inferredTypeArgument.readableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) }, new String[] { new String(shownMethod.selector), @@ -4135,7 +4135,7 @@ public void invalidMethod(MessageSend messageSend, MethodBinding method) { new String(shownMethod.declaringClass.shortReadableName()), typesAsString(invocationArguments, true), new String(inferredTypeArgument.shortReadableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) }, (int) (messageSend.nameSourcePosition >>> 32), (int) messageSend.nameSourcePosition); @@ -4956,7 +4956,7 @@ public void javadocInvalidConstructor(Statement statement, MethodBinding targetC new String(shownConstructor.declaringClass.readableName()), typesAsString(invocationArguments, false), new String(inferredTypeArgument.readableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) }, new String[] { new String(shownConstructor.declaringClass.sourceName()), @@ -4964,7 +4964,7 @@ public void javadocInvalidConstructor(Statement statement, MethodBinding targetC new String(shownConstructor.declaringClass.shortReadableName()), typesAsString(invocationArguments, true), new String(inferredTypeArgument.shortReadableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) }, severity, sourceStart, @@ -5188,7 +5188,7 @@ public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, new String(shownMethod.declaringClass.readableName()), typesAsString(invocationArguments, false), new String(inferredTypeArgument.readableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) }, new String[] { new String(shownMethod.selector), @@ -5196,7 +5196,7 @@ public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, new String(shownMethod.declaringClass.shortReadableName()), typesAsString(invocationArguments, true), new String(inferredTypeArgument.shortReadableName()), - new String(typeParameter.sourceName), + new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) }, severity, (int) (messageSend.nameSourcePosition >>> 32), @@ -7861,8 +7861,8 @@ public void typeMismatchError(TypeBinding typeArgument, TypeVariableBinding type if (location == null) { // binary case this.handle( IProblem.TypeArgumentMismatch, - new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) }, - new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) }, + new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) }, + new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) }, ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal, 0, 0); @@ -7870,8 +7870,8 @@ public void typeMismatchError(TypeBinding typeArgument, TypeVariableBinding type } this.handle( IProblem.TypeArgumentMismatch, - new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) }, - new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) }, + new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) }, + new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) }, location.sourceStart, location.sourceEnd); } |