Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Allow java.home to be overriden with androidide.java.home
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Jul 7, 2022
1 parent 2b84123 commit ac7ec80
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class Locations {

private PathFactory pathFactory = Paths::get;

static final Path javaHome = FileSystems.getDefault().getPath(System.getProperty("java.home"));
static final Path javaHome = FileSystems.getDefault().getPath(com.sun.tools.javac.util.JavaHomeProvider.getJavaHome());
static final Path thisSystemModules = javaHome.resolve("lib").resolve("modules");

Map<Path, FileSystem> fileSystems = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public void close() throws IOException {
}

static Path findCtSym() {
String javaHome = System.getProperty("java.home");
String javaHome = com.sun.tools.javac.util.JavaHomeProvider.getJavaHome();
Path file = Paths.get(javaHome);
// file == ${jdk.home}
for (String name : symbolFileLocation)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sun.tools.javac.util;

public class JavaHomeProvider {

public static String PROP_ANDROIDIDE_JAVA_HOME = "androidide.java.home";

public static String getJavaHome() {
String javaHome = System.getProperty(PROP_ANDROIDIDE_JAVA_HOME);
if (javaHome == null || javaHome.trim().length() == 0) {
javaHome = System.getProperty("java.home");
}

return javaHome;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public class ImageReaderFactory {
private ImageReaderFactory() {}

private static final String JAVA_HOME = System.getProperty("java.home");
private static final String JAVA_HOME = com.sun.tools.javac.util.JavaHomeProvider.getJavaHome();
private static final Path BOOT_MODULES_JIMAGE =
Paths.get(JAVA_HOME, "lib", "modules");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ private static class Options {
Pattern includePattern;
boolean inverse = false;
boolean compileTimeView = false;
String systemModulePath = System.getProperty("java.home");
String systemModulePath = com.sun.tools.javac.util.JavaHomeProvider.getJavaHome();
String upgradeModulePath;
String modulePath;
Set<String> rootModules = new HashSet<>();
Expand Down

0 comments on commit ac7ec80

Please sign in to comment.