Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2019-05-09 14:21:29 +0000
committerAndrey Loskutov2019-05-10 11:30:20 +0000
commit2ad2b8d585b1167800deee0b2802a3691f509b43 (patch)
tree0e9bcf0bb0ed8265f40989b411e0c342188d4ae5
parent752fbc656301185a7a6ecbffce294c8b25e839a2 (diff)
downloadeclipse.jdt.core-2ad2b8d585b1167800deee0b2802a3691f509b43.tar.gz
eclipse.jdt.core-2ad2b8d585b1167800deee0b2802a3691f509b43.tar.xz
eclipse.jdt.core-2ad2b8d585b1167800deee0b2802a3691f509b43.zip
Bug 547095 - SIOOBE trying to search in context of a class from modularI20190510-1800
JDK Updated documentPath constructed in findIndexMatches() to consider module name of the requested type. Change-Id: Ifbae408c357c4822500adce26fddd1bf44e47781 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs9Tests.java40
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java41
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/LocalVariablePattern.java9
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java10
4 files changed, 98 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs9Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs9Tests.java
index 5e5de35370..20381fa9a6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs9Tests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs9Tests.java
@@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.APPLICATION_LIBRARIES;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.REFERENCED_PROJECTS;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.SOURCES;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.SYSTEM_LIBRARIES;
+
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -39,6 +44,9 @@ import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.TypeReferenceMatch;
+import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.core.LocalVariable;
+import org.eclipse.jdt.internal.core.TypeParameter;
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
@@ -4653,5 +4661,37 @@ public void testBug547051_modular() throws Exception {
}
}
+public void testBug547095_local_variables_search_modular() throws Exception {
+ try {
+ IJavaProject project = createJava9Project("P");
+ IType type = project.findType("java.util.Collection");
+
+ IMethod method = type.getMethod("equals", new String[] {"Ljava.lang.Object;" });
+ LocalVariable lv = new LocalVariable(((JavaElement)method), "o", 0, 0, 0, 0, "QObject;", null, 0, true);
+ SearchPattern pattern = SearchPattern.createPattern(lv, REFERENCES, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH);
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, SYSTEM_LIBRARIES | APPLICATION_LIBRARIES | REFERENCED_PROJECTS | SOURCES);
+ search(pattern, scope, this.resultCollector);
+ // should not throw an error
+ }
+ finally {
+ deleteProject("P");
+ }
+}
+
+public void testBug547095_type_patter_search_modular() throws Exception {
+ try {
+ IJavaProject project = createJava9Project("P");
+ IType type = project.findType("java.util.Collection");
+ TypeParameter tp = new TypeParameter(((JavaElement)type), "E");
+ SearchPattern pattern = SearchPattern.createPattern(tp, REFERENCES, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH);
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, SYSTEM_LIBRARIES | APPLICATION_LIBRARIES | REFERENCED_PROJECTS | SOURCES);
+ search(pattern, scope, this.resultCollector);
+ // should not throw an error
+ }
+ finally {
+ deleteProject("P");
+ }
+}
+
// Add more tests here
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
index 66cc595b96..3051fe8f0c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
@@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.APPLICATION_LIBRARIES;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.REFERENCED_PROJECTS;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.SOURCES;
+import static org.eclipse.jdt.core.search.IJavaSearchScope.SYSTEM_LIBRARIES;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -74,8 +79,11 @@ import org.eclipse.jdt.core.search.TypeReferenceMatch;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.core.ClassFile;
+import org.eclipse.jdt.internal.core.JavaElement;
import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.LocalVariable;
import org.eclipse.jdt.internal.core.SourceMethod;
+import org.eclipse.jdt.internal.core.TypeParameter;
import org.eclipse.jdt.internal.core.index.DiskIndex;
import org.eclipse.jdt.internal.core.index.Index;
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
@@ -15163,4 +15171,37 @@ public void testBug547051_nonModular() throws Exception {
}
}
+public void testBug547095_local_variables_search_non_modular() throws Exception {
+ try {
+ IJavaProject project = createJavaProject("P");
+ setUpProjectCompliance(project, "1.8", true);
+ IType type = project.findType("java.util.Collection");
+
+ IMethod method = type.getMethod("equals", new String[] {"Ljava.lang.Object;" });
+ LocalVariable lv = new LocalVariable(((JavaElement)method), "o", 0, 0, 0, 0, "QObject;", null, 0, true);
+ SearchPattern pattern = SearchPattern.createPattern(lv, REFERENCES, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH);
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, SYSTEM_LIBRARIES | APPLICATION_LIBRARIES | REFERENCED_PROJECTS | SOURCES);
+ search(pattern, scope, this.resultCollector);
+ // should not throw an error
+ }
+ finally {
+ deleteProject("P");
+ }
+}
+
+public void testBug547095_type_pattern_search_non_modular() throws Exception {
+ try {
+ IJavaProject project = createJavaProject("P");
+ setUpProjectCompliance(project, "1.8", true);
+ IType type = project.findType("java.util.Collection");
+ TypeParameter tp = new TypeParameter(((JavaElement)type), "E");
+ SearchPattern pattern = SearchPattern.createPattern(tp, REFERENCES, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH);
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, SYSTEM_LIBRARIES | APPLICATION_LIBRARIES | REFERENCED_PROJECTS | SOURCES);
+ search(pattern, scope, this.resultCollector);
+ // should not throw an error
+ }
+ finally {
+ deleteProject("P");
+ }
+}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/LocalVariablePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/LocalVariablePattern.java
index 0078d58eb1..dc6838a197 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/LocalVariablePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/LocalVariablePattern.java
@@ -42,7 +42,14 @@ public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchP
if (root.isArchive()) {
IType type = (IType)this.localVariable.getAncestor(IJavaElement.TYPE);
relativePath = (type.getFullyQualifiedName('$')).replace('.', '/') + SuffixConstants.SUFFIX_STRING_class;
- documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
+ IModuleDescription md = root.getModuleDescription();
+ if(md != null) {
+ String module = md.getElementName();
+ documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR
+ + module + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
+ } else {
+ documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
+ }
} else {
IPath path = this.localVariable.getPath();
documentPath = path.toString();
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java
index 5f74dd6bb2..751233de98 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IModuleDescription;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeParameter;
@@ -87,7 +88,14 @@ public class TypeParameterPattern extends JavaSearchPattern {
if (root.isArchive()) {
IType type = (IType) this.typeParameter.getAncestor(IJavaElement.TYPE);
relativePath = (type.getFullyQualifiedName('$')).replace('.', '/') + SuffixConstants.SUFFIX_STRING_class;
- documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
+ IModuleDescription md = root.getModuleDescription();
+ if(md != null) {
+ String module = md.getElementName();
+ documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR
+ + module + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
+ } else {
+ documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
+ }
} else {
IPath path = this.typeParameter.getPath();
documentPath = path.toString();

Back to the top