Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing default VMInstall when querying JVM system-packages #722

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

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 @@ -532,14 +532,18 @@
if (javaPackages == null) {
String profileSystemPackages = preJava9ProfileProperties.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES, ""); //$NON-NLS-1$
if (profileSystemPackages.isBlank()) {
return null;
return List.of();
}
javaPackages = COMMA.splitAsStream(profileSystemPackages).filter(p -> p.startsWith("java.")).toList(); //$NON-NLS-1$
}
IVMInstall targetVM = JavaRuntime.getDefaultVMInstall(); // Set by the Target-Definition if specified there
if (targetVM == null) {
LOGGER.warn("No default JRE installation selected"); //$NON-NLS-1$
return List.of();
}
Collection<String> targetVMSystemPackages = querySystemPackages(targetVM, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather let querySystemPackages return a stream instead instead it is even converted to a stream right after that... and having null as return value for collections is really ugly....

if (targetVMSystemPackages == null) {
return null;
return List.of();
}
Stream<String> targetVMNonJavaPackages = targetVMSystemPackages.stream().filter(p -> !p.startsWith("java.")); //$NON-NLS-1$

Expand Down Expand Up @@ -666,17 +670,17 @@
String release = environment != null ? environment.getProfileProperties().getProperty(JavaCore.COMPILER_COMPLIANCE) : null;
try {
Collection<String> packages = new TreeSet<>();
String jrtPath = "lib/" + org.eclipse.jdt.internal.compiler.util.JRTUtil.JRT_FS_JAR; //$NON-NLS-1$

Check warning on line 673 in build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java

View check run for this annotation

Jenkins - eclipse-pde / Java Compiler

tycho-compiler:compile

NORMAL:
String path = new File(vm.getInstallLocation(), jrtPath).toString(); // $NON-NLS-1$
var jrt = org.eclipse.jdt.internal.core.builder.ClasspathLocation.forJrtSystem(path, null, null, release);

Check warning on line 675 in build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java

View check run for this annotation

Jenkins - eclipse-pde / Java Compiler

tycho-compiler:compile

NORMAL:
for (String moduleName : jrt.getModuleNames(null)) {

Check warning on line 676 in build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java

View check run for this annotation

Jenkins - eclipse-pde / Java Compiler

tycho-compiler:compile

NORMAL:
var module = jrt.getModule(moduleName);

Check warning on line 677 in build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java

View check run for this annotation

Jenkins - eclipse-pde / Java Compiler

tycho-compiler:compile

NORMAL:
if (module == null) {
continue;
}
for (var packageExport : module.exports()) {

Check warning on line 681 in build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java

View check run for this annotation

Jenkins - eclipse-pde / Java Compiler

tycho-compiler:compile

NORMAL:
if (!packageExport.isQualified()) {

Check warning on line 682 in build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java

View check run for this annotation

Jenkins - eclipse-pde / Java Compiler

tycho-compiler:compile

NORMAL:
packages.add(new String(packageExport.name()));

Check warning on line 683 in build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java

View check run for this annotation

Jenkins - eclipse-pde / Java Compiler

tycho-compiler:compile

NORMAL:
}
}
}
Expand Down
Loading