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

For nb.org projects, use the correct nbjavac prepend for the internal (boot)classpath. #5174

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -42,6 +42,7 @@
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.swing.event.ChangeListener;
import org.netbeans.api.java.classpath.ClassPath;
import org.netbeans.api.java.platform.JavaPlatform;
Expand Down Expand Up @@ -423,9 +424,15 @@ private PropertyEvaluator createEvaluator(ModuleList ml) {
buildDefaults.put(CP, "${module.classpath}:${cp.extra}"); // NOI18N
buildDefaults.put(RUN_CP, "${module.run.classpath}:${cp.extra}:${build.classes.dir}"); // NOI18N
if (type == NbModuleType.NETBEANS_ORG && "true".equals(projectProperties.getProperties().get("requires.nb.javac"))) {
ModuleEntry javacapi = ml.getEntry("org.netbeans.libs.javacapi");
if (javacapi != null) {
buildDefaults.put(ClassPathProviderImpl.BOOTCLASSPATH_PREPEND, javacapi.getClassPathExtensions());
ModuleEntry javacLibrary = ml.getEntry("org.netbeans.libs.javacapi");
if (javacLibrary != null) {
List<String> bootstrapAPIs = new ArrayList<>();
for (String ext : javacLibrary.getClassPathExtensions().split(Pattern.quote(File.pathSeparator))) {
if (ext.endsWith("-api.jar")) {
bootstrapAPIs.add(ext);
}
}
buildDefaults.put(ClassPathProviderImpl.BOOTCLASSPATH_PREPEND, bootstrapAPIs.stream().collect(Collectors.joining(File.pathSeparator)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be more compact to say
String path = Stream.of(javacLibrary.getClassPathExtensions().split(Pattern.quote(File.pathSeparator))).
filter(ext -> ext.endsWith("-api.jar")).
collect(Collectors.joining(File.pathSeparator)));
buildDefaults.put(ClassPathProviderImpl.BOOTCLASSPATH_PREPEND, path);

or even extract path calculation into a private method with meaningful name

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public ClassPath findClassPath(
@Override
public ClassPath run() {
if (boot == null) {
ClassPathImplementation prependCP = createPathFromProperty(BOOTCLASSPATH_PREPEND);
final String loc = project.evaluator().getProperty(Evaluator.NBJDK_BOOTCLASSPATH_MODULAR);
if(loc != null) {
final File locf = new File(loc);
Expand All @@ -122,13 +123,15 @@ public ClassPath run() {
.findFirst()
.orElse(null);
if (locf.equals(jpLocf)) {
boot = jp.getBootstrapLibraries();
boot = ClassPathSupport.createProxyClassPath(
ClassPathFactory.createClassPath(prependCP),
jp.getBootstrapLibraries());
break;
}
}
} else {
boot = ClassPathFactory.createClassPath(ClassPathSupport.createProxyClassPathImplementation(
createPathFromProperty(BOOTCLASSPATH_PREPEND),
prependCP,
createPathFromProperty(Evaluator.NBJDK_BOOTCLASSPATH),
createFxPath()));
}
Expand Down