Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,22 @@ public void buildAnalysisScope() throws IOException {

IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
File installLocation = defaultVMInstall.getInstallLocation();
java.nio.file.Path installPath = installLocation.toPath();

if (Util.isWindows()) {
addToScopeWindows("resources.jar", installPath);
addToScopeWindows("rt.jar", installPath);
addToScopeWindows("jsse.jar", installPath);
addToScopeWindows("jce.jar", installPath);
addToScopeWindows("charsets.jar", installPath);
} else {
addToScopeNotWindows("resources.jar", installPath);
addToScopeNotWindows("rt.jar", installPath);
addToScopeNotWindows("jsse.jar", installPath);
addToScopeNotWindows("jce.jar", installPath);
addToScopeNotWindows("charsets.jar", installPath);
}

scope.addToScope(ClassLoaderReference.Primordial, new JarFile(
installLocation.toPath().resolve("jre").resolve("lib").resolve("resources.jar").toFile()));
scope.addToScope(ClassLoaderReference.Primordial,
new JarFile(installLocation.toPath().resolve("jre").resolve("lib").resolve("rt.jar").toFile()));
scope.addToScope(ClassLoaderReference.Primordial,
new JarFile(installLocation.toPath().resolve("jre").resolve("lib").resolve("jsse.jar").toFile()));
scope.addToScope(ClassLoaderReference.Primordial,
new JarFile(installLocation.toPath().resolve("jre").resolve("lib").resolve("jce.jar").toFile()));
scope.addToScope(ClassLoaderReference.Primordial, new JarFile(
installLocation.toPath().resolve("jre").resolve("lib").resolve("charsets.jar").toFile()));
}

if (getExclusionsFile() != null) {
Expand All @@ -91,6 +96,16 @@ public void buildAnalysisScope() throws IOException {
}
}

void addToScopeWindows(String fileName, java.nio.file.Path installPath) throws IOException {
scope.addToScope(ClassLoaderReference.Primordial,
new JarFile(installPath.resolve("lib").resolve(fileName).toFile()));
}

void addToScopeNotWindows(String fileName, java.nio.file.Path installPath) throws IOException {
scope.addToScope(ClassLoaderReference.Primordial,
new JarFile(installPath.resolve("jre").resolve("lib").resolve(fileName).toFile()));
}

@Override
protected EclipseProjectPath<?, IJavaProject> createProjectPath(IJavaProject project)
throws IOException, CoreException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public final class Util {

private Util() {
}

public static String getOSName() {
return System.getProperty("os.name");
}

public static boolean isWindows() {
return getOSName().startsWith("Windows");
}

/**
* Enhance an {@link AnalysisScope} to include in a particular loader,
Expand Down