Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2012-07-05 13:53:38 +0000
committerSrikanth2012-07-05 13:53:38 +0000
commit8d19f5a1e4b345e3efd30be48a0614ea130c9e08 (patch)
treec6aa872a3516fa68b281f15972aba403c6a6e6ec
parentc7c0f45382aa459a248601386682edbbcff78c8b (diff)
downloadeclipse.jdt.core-8d19f5a1e4b345e3efd30be48a0614ea130c9e08.tar.gz
eclipse.jdt.core-8d19f5a1e4b345e3efd30be48a0614ea130c9e08.tar.xz
eclipse.jdt.core-8d19f5a1e4b345e3efd30be48a0614ea130c9e08.zip
Fixed bug 383315: NPE inv20120705-135338
FullSourceWorkspaceSearchTests.testSearchBinaryMethod()
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java65
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java12
2 files changed, 63 insertions, 14 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
index bf0958e983..34f79f6d8f 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
@@ -622,8 +622,8 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
}
}
/**
- * @bug 357547: [search] Search for method references is returning methods as overriden even if the superclass's method is only package-visible
- * @test Search for a non-overriden method because of package visibility should not be found
+ * @bug 357547: [search] Search for method references is returning methods as overridden even if the superclass's method is only package-visible
+ * @test Search for a non-overridden method because of package visibility should not be found
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547"
*/
public void testBug357547a() throws CoreException {
@@ -660,7 +660,7 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
}
}
- // search for the method name should also not return matches if not-overriden because of package-visible
+ // search for the method name should also not return matches if not-overridden because of package-visible
public void testBug357547b() throws CoreException {
IJavaProject project = null;
try
@@ -729,8 +729,6 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
deleteProject(project);
}
}
-
-
public void testBug357547d() throws CoreException {
IJavaProject project = null;
try
@@ -769,7 +767,7 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
deleteProject(project);
}
}
- // search for the method name should also not return matches if not-overriden because of package-visible
+ // search for the method name should also not return matches if not-overridden because of package-visible
// even if they are in jars
public void testBug357547e() throws CoreException, IOException {
IJavaProject project = null;
@@ -817,7 +815,7 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
deleteProject(project);
}
}
- // search for the method name should also not return matches if not-overriden because of package-visible
+ // search for the method name should also not return matches if not-overridden because of package-visible
// even if they are in jars
public void testBug357547f() throws CoreException, IOException {
IJavaProject project = null;
@@ -865,7 +863,6 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
deleteProject(project);
}
}
-
// search for declarations also should take care of default
public void testBug357547g() throws CoreException {
IJavaProject project = null;
@@ -1290,4 +1287,56 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
deleteProject("P");
}
}
+ public void testBug383315a() throws CoreException {
+ try {
+ IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "JCL15_LIB" }, "", "1.5");
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES);
+
+ search("java.lang.Object.hashCode()", METHOD, ALL_OCCURRENCES, scope, this.resultCollector);
+
+ assertSearchResults(""); // an NPE was thrown without the fix
+ } finally {
+ deleteProject("P");
+ }
+ }
+ public void testBug383315b() throws CoreException {
+ try {
+ IJavaProject p = createJavaProject("P");
+ createFolder("/P/pkg");
+ createFile("/P/pkg/A.java",
+ "package pkg;\n"+
+ "public class A {\n"+
+ " void a() {\n"+
+ " }\n"+
+ "}");
+ createFile("/P/pkg/B.java",
+ "package pkg;\n"+
+ "public class B extends A {\n"+
+ " void a() {\n"+
+ " }\n"+
+ "}");
+ createFile("/P/pkg/C.java",
+ "package pkg;\n"+
+ "public class C extends B {\n"+
+ " void a() {\n"+
+ " }\n"+
+ "}");
+ createFile("/P/pkg/D.java",
+ "package pkg;\n"+
+ "public class D extends C {\n"+
+ " void a() {\n"+
+ " }\n"+
+ " void d() {\n"+
+ " new A().a();\n"+
+ " }\n"+
+ "}");
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES);
+
+ search("C.a()", METHOD, REFERENCES, scope, this.resultCollector);
+
+ assertSearchResults("pkg/D.java void pkg.D.d() [a()] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
index 7fc6f1f621..3b450993a4 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
@@ -126,7 +126,7 @@ protected void addToResult(char[][] compoundName) {
}
/*
- * Parse the given compiation unit and build its type bindings.
+ * Parse the given compilation unit and build its type bindings.
*/
protected CompilationUnitDeclaration buildBindings(ICompilationUnit compilationUnit, boolean isTopLevelOrMember) throws JavaModelException {
// source unit
@@ -172,7 +172,7 @@ public char[][][] collect() throws JavaModelException {
}
}
} catch (AbortCompilation e) {
- // problem with classpath: report inacurrate matches
+ // problem with classpath: report inaccurate matches
return null;
}
if (this.result.length > this.resultIndex)
@@ -203,7 +203,7 @@ public char[][][] collect() throws JavaModelException {
}
if (openable instanceof ICompilationUnit) {
ICompilationUnit unit = (ICompilationUnit) openable;
- CompilationUnitDeclaration parsedUnit = buildBindings(unit, true /*only toplevel and member types are visible to the focus type*/);
+ CompilationUnitDeclaration parsedUnit = buildBindings(unit, true /*only top level and member types are visible to the focus type*/);
if (parsedUnit != null)
parsedUnit.traverse(new TypeDeclarationVisitor(), parsedUnit.scope);
} else if (openable instanceof IClassFile) {
@@ -227,13 +227,13 @@ public char[][][] collect() throws JavaModelException {
*/
protected void collectSuperTypeNames(ReferenceBinding binding, char[][] path) {
ReferenceBinding superclass = binding.superclass();
- if (path != null) {
+ if (path != null && superclass != null) {
boolean samePackage = addIfSamePackage(superclass.compoundName, path);
if (!samePackage) path = null;
}
if (superclass != null) {
addToResult(superclass.compoundName);
- collectSuperTypeNames(superclass, null);
+ collectSuperTypeNames(superclass, path);
}
ReferenceBinding[] interfaces = binding.superInterfaces();
@@ -241,7 +241,7 @@ protected void collectSuperTypeNames(ReferenceBinding binding, char[][] path) {
for (int i = 0; i < interfaces.length; i++) {
ReferenceBinding interfaceBinding = interfaces[i];
addToResult(interfaceBinding.compoundName);
- collectSuperTypeNames(interfaceBinding, null);
+ collectSuperTypeNames(interfaceBinding, path);
}
}
}

Back to the top