Skip to content

Commit

Permalink
lookup sources for jars in the module path
Browse files Browse the repository at this point in the history
  • Loading branch information
adinn authored and fniephaus committed Sep 3, 2022
1 parent f7e1ca2 commit 985d2ed
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ public class SourceCache {
*/
protected static final List<Path> classPathEntries = new ArrayList<>();
/**
* A list of all entries in the classpath used by the native image classloader.
* A list of all entries in the module path used by the native image classloader.
*/
protected static final List<Path> modulePathEntries = new ArrayList<>();
/**
* A list of all entries in the source search path specified by the user on the command line.
*/
protected static final List<String> sourcePathEntries = new ArrayList<>();

Expand Down Expand Up @@ -126,6 +130,8 @@ private void addJDKSources() {
private void addGraalSources() {
classPathEntries.stream()
.forEach(classPathEntry -> addGraalSourceRoot(classPathEntry, true));
modulePathEntries.stream()
.forEach(modulePathEntry -> addGraalSourceRoot(modulePathEntry, true));
sourcePathEntries.stream()
.forEach(sourcePathEntry -> addGraalSourceRoot(Paths.get(sourcePathEntry), false));
}
Expand Down Expand Up @@ -179,6 +185,8 @@ private void addGraalSourceRoot(Path sourcePath, boolean fromClassPath) {
private void addApplicationSources() {
classPathEntries.stream()
.forEach(classPathEntry -> addApplicationSourceRoot(classPathEntry, true));
modulePathEntries.stream()
.forEach(modulePathEntry -> addApplicationSourceRoot(modulePathEntry, true));
sourcePathEntries.stream()
.forEach(sourcePathEntry -> addApplicationSourceRoot(Paths.get(sourcePathEntry), false));
}
Expand Down Expand Up @@ -503,6 +511,15 @@ static void addClassPathEntry(Path path) {
classPathEntries.add(path);
}

/**
* Add a path to the list of module path entries.
*
* @param path The path to add.
*/
static void addModulePathEntry(Path path) {
modulePathEntries.add(path);
}

/**
* Add a path to the list of source path entries.
*
Expand All @@ -527,6 +544,9 @@ public void afterAnalysis(AfterAnalysisAccess access) {
for (Path entry : loader.classpath()) {
SourceCache.addClassPathEntry(entry);
}
for (Path entry : loader.modulepath()) {
SourceCache.addModulePathEntry(entry);
}
// also add any necessary source path entries
if (SubstrateOptions.DebugInfoSourceSearchPath.getValue() != null) {
for (String searchPathEntry : OptionUtils.flatten(",", SubstrateOptions.DebugInfoSourceSearchPath.getValue())) {
Expand All @@ -541,8 +561,7 @@ class SourceRoot {
boolean isJDK;

SourceRoot(Path path) {
this.path = path;
this.isJDK = false;
this(path, false);
}

SourceRoot(Path path, boolean isJDK) {
Expand Down

0 comments on commit 985d2ed

Please sign in to comment.