Bug 531763 - [9] replace provisional API in JavaModelAccess used by
jdt.debug
Change-Id: Ia3259dfc57f376b613f1a2c7dcfa188997874e2d
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
index a9b76df..7c38d53 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
@@ -17,6 +17,7 @@
package org.eclipse.jdt.core;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -1207,4 +1208,30 @@
*/
void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation, IProgressMonitor monitor)
throws JavaModelException;
+
+ /**
+ * Returns the classpath entry that refers to the given path or <code>null</code> if there is no reference to the
+ * path.
+ *
+ * @param path
+ * IPath
+ * @return the classpath entry or <code>null</null>.
+ * @throws JavaModelException
+ * @since 3.14
+ */
+ IClasspathEntry getClasspathEntryFor(IPath path) throws JavaModelException;
+
+ /**
+ * When compiling test code in a modular project that has non-source classpath entries which don't have the
+ * {@link IClasspathAttribute#MODULE} set, the module is assumed to read the unnamed module (which is useful for
+ * test-only dependencies that should not be mentioned in the module-info.java). When executing test code that was
+ * compiled like this, corresponding "--add-reads" options need to be passed to the java runtime. This method
+ * returns the list of modules on the project's classpath for which this is the case.
+ *
+ * @return the set of module names
+ * @throws JavaModelException
+ * when access to the classpath or module description of the given project fails.
+ * @since 3.14
+ */
+ Set<String> determineModulesOfProjectsWithNonEmptyClasspath() throws JavaModelException;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
index 85100bf..25f9d89 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
@@ -1783,13 +1783,7 @@
return computePackageFragmentRoots(getResolvedClasspath(), true/*retrieveExportedRoots*/, true/*filterModuleRoots*/, rootToResolvedEntries, excludeTestCode);
}
- /**
- * Returns the classpath entry that refers to the given path
- * or <code>null</code> if there is no reference to the path.
- * @param path IPath
- * @return IClasspathEntry
- * @throws JavaModelException
- */
+ @Override
public IClasspathEntry getClasspathEntryFor(IPath path) throws JavaModelException {
getResolvedClasspath(); // force resolution
PerProjectInfo perProjectInfo = getPerProjectInfo();
@@ -3758,4 +3752,8 @@
return null;
}
+ @Override
+ public Set<String> determineModulesOfProjectsWithNonEmptyClasspath() throws JavaModelException {
+ return ModuleUpdater.determineModulesOfProjectsWithNonEmptyClasspath(this, getExpandedClasspath());
+ }
}