Skip to content

Commit

Permalink
Preprocessing service compliance with JEP 220/261.
Browse files Browse the repository at this point in the history
As part of processing#5753 and processing#5750, migrated the preprocessing service to use the jmod for java base. Will refactor out this logic to support other jmods shortly with some code clean up and tests. All of this allows our use of the JDT to work without rt.java which was removed as part of Jigsaw. Please see JEP 220 and JEP 261.
  • Loading branch information
sampottinger committed Jan 26, 2019
1 parent 023f046 commit 2081d09
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
12 changes: 11 additions & 1 deletion build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<property name="jdk.version" value="0" />
<property name="jdk.update" value="1" />
<property name="jdk.build" value="13" />

<!-- See https://gist.github.com/P7h/9741922
or http://stackoverflow.com/q/10268583 -->
<property name="jdk.hash" value="1961070e4c9b4e26a04e7f5a083f551e" />
Expand Down Expand Up @@ -651,6 +651,16 @@
<arg line="${jdk.path.macosx}/Contents/Home/bin macosx/work/Processing.app/Contents/PlugIns/adoptopenjdk-11.0.1.jdk/Contents/Home/bin"/>
</exec>

<exec executable="cp">
<arg value="-r"/>
<arg line="${jdk.path.macosx}/Contents/Home/jmods macosx/work/Processing.app/Contents/PlugIns/adoptopenjdk-11.0.1.jdk/Contents/Home/jmods"/>
</exec>

<exec executable="cp">
<arg value="-r"/>
<arg line="${jdk.path.macosx}/Contents/Home/legal macosx/work/Processing.app/Contents/PlugIns/adoptopenjdk-11.0.1.jdk/Contents/Home/legal"/>
</exec>

<property name="contents.dir"
location="macosx/work/Processing.app/Contents" />

Expand Down
Binary file modified java/mode/org.eclipse.core.resources.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion java/src/processing/mode/java/pdex/ErrorChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private void handleSketchProblems(PreprocessedSketch ps) {

if (problems.isEmpty()) {
AtomicReference<ClassPath> searchClassPath = new AtomicReference<>(null);

List<Problem> cuProblems = Arrays.stream(iproblems)
// Filter Warnings if they are not enabled
.filter(iproblem -> !(iproblem.isWarning() && !JavaMode.warningsEnabled))
Expand Down Expand Up @@ -324,4 +325,4 @@ static public String[] getImportSuggestions(ClassPath cp, String className) {
})
.toArray(String[]::new);
}
}
}
31 changes: 11 additions & 20 deletions java/src/processing/mode/java/pdex/PreprocessingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -589,18 +583,13 @@ static private List<String> buildSketchLibraryClassPath(JavaMode mode,
static private List<String> buildJavaRuntimeClassPath() {
StringBuilder classPath = new StringBuilder();

{ // Java runtime
String rtPath = System.getProperty("java.home") +
File.separator + "lib" + File.separator + "rt.jar";
if (new File(rtPath).exists()) {
classPath.append(File.pathSeparator).append(rtPath);
} else {
rtPath = System.getProperty("java.home") + File.separator +
File.separator + "lib" + File.separator + "rt.jar";
if (new File(rtPath).exists()) {
classPath.append(File.pathSeparator).append(rtPath);
}
}
{ // Java runtime (jmods in Java 9+)
StringJoiner jmodPathJoiner = new StringJoiner(File.separator);
jmodPathJoiner.add(System.getProperty("java.home"));
jmodPathJoiner.add("jmods");
jmodPathJoiner.add("java.base.jmod");
String jmodsPath = jmodPathJoiner.toString();
classPath.append(File.pathSeparator).append(jmodsPath);
}

{ // JavaFX runtime
Expand Down Expand Up @@ -675,7 +664,9 @@ static private boolean ignorableImport(String packageName) {
static {
Map<String, String> compilerOptions = new HashMap<>();

JavaCore.setComplianceOptions(JavaCore.VERSION_1_7, compilerOptions);
compilerOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_11);
compilerOptions.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_11);
compilerOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_11);

// See http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_api_options.htm&anchor=compiler

Expand Down

0 comments on commit 2081d09

Please sign in to comment.