Skip to content

Commit

Permalink
Restrict Espresso API to only detect JAVA_HOME under Native Image (ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
linghengqian authored and kyooosukedn committed May 14, 2023
1 parent b0a7a9c commit 20fea43
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
*/
public final class EspressoInlineExpressionParser implements JVMInlineExpressionParser {

private static final String JAVA_HOME;

private static final String JAVA_CLASSPATH;

static {
// TODO https://github.com/oracle/graal/issues/4555 not yet closed
JAVA_HOME = System.getenv("JAVA_HOME");
ShardingSpherePreconditions.checkNotNull(JAVA_HOME, () -> new RuntimeException("Failed to determine the system's environment variable JAVA_HOME!"));
if ("Substrate VM".equals(System.getProperty("java.vm.name"))) {
String javaHome = System.getenv("JAVA_HOME");
ShardingSpherePreconditions.checkNotNull(javaHome, () -> new RuntimeException("Failed to determine the system's environment variable JAVA_HOME!"));
}
URL resource = Objects.requireNonNull(EspressoInlineExpressionParser.class.getClassLoader().getResource("espresso-need-libs"));
String dir = resource.getPath();
JAVA_CLASSPATH = String.join(":", dir + "/groovy.jar", dir + "/guava.jar", dir + "/shardingsphere-infra-expr-hotsopt.jar");
Expand Down Expand Up @@ -84,7 +84,7 @@ private Value getInlineExpressionParser() {

private Context getContext() {
return Context.newBuilder().allowAllAccess(true)
.option("java.Properties.org.graalvm.home", JAVA_HOME)
.option("java.Properties.org.graalvm.home", System.getenv("JAVA_HOME"))
.option("java.MultiThreaded", Boolean.TRUE.toString())
.option("java.Classpath", JAVA_CLASSPATH)
.build();
Expand Down

0 comments on commit 20fea43

Please sign in to comment.