Skip to content
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.oracle.svm.core.jdk;

import java.util.function.BooleanSupplier;

public final class NashornSupport {

// Determine if the jdk.scripting.nashorn module (or jar) is available. If it's not,
// the boolean supplier should return false.
static class NashornAvailable implements BooleanSupplier {

private static final String CLASSFILTER_NAME = "jdk.nashorn.api.scripting.ClassFilter";

@Override
public boolean getAsBoolean() {
try {
// Checkstyle: stop
Class.forName(CLASSFILTER_NAME);
// Checkstyle: resume
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
package com.oracle.svm.core.jdk;

import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jdk.NashornSupport.NashornAvailable;

@TargetClass(className = "jdk.nashorn.api.scripting.ClassFilter", onlyWith = JDK14OrEarlier.class)
@TargetClass(className = "jdk.nashorn.api.scripting.ClassFilter", onlyWith = {JDK14OrEarlier.class, NashornAvailable.class})
public final class Target_jdk_nashorn_api_scripting_ClassFilter {
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jdk.NashornSupport.NashornAvailable;
import com.oracle.svm.core.util.VMError;

@TargetClass(className = "jdk.nashorn.api.scripting.NashornScriptEngineFactory", onlyWith = JDK14OrEarlier.class)
@TargetClass(className = "jdk.nashorn.api.scripting.NashornScriptEngineFactory", onlyWith = {JDK14OrEarlier.class, NashornAvailable.class})
public final class Target_jdk_nashorn_api_scripting_NashornScriptEngineFactory {
@Substitute
@SuppressWarnings({"unused", "static-method"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,6 @@ public List<String> getBuilderJavaArgs() {
}
}

if (useJVMCINativeLibrary) {
builderJavaArgs.add("-XX:+UseJVMCINativeLibrary");
} else {
builderJavaArgs.add("-XX:-UseJVMCICompiler");
}

String javaVersion = String.valueOf(JavaVersionUtil.JAVA_SPEC);
String[] flagsForVersion = graalCompilerFlags.get(javaVersion);
if (flagsForVersion == null) {
Expand Down Expand Up @@ -516,6 +510,12 @@ public List<String> getBuilderJavaArgs() {
}
}

if (useJVMCINativeLibrary) {
builderJavaArgs.add("-XX:+UseJVMCINativeLibrary");
} else {
builderJavaArgs.add("-XX:-UseJVMCICompiler");
}

return builderJavaArgs;
}

Expand All @@ -524,11 +524,12 @@ public List<String> getBuilderJavaArgs() {
*/
public List<Path> getBuilderModulePath() {
List<Path> result = new ArrayList<>();
// Non-jlinked JDKs need truffle and graal-sdk on the module path since they
// don't have those modules as part of the JDK.
result.addAll(getJars(rootDir.resolve(Paths.get("lib", "jvmci")), "graal-sdk", "enterprise-graal"));
result.addAll(getJars(rootDir.resolve(Paths.get("lib", "truffle")), "truffle-api"));
if (modulePathBuild) {
result.addAll(getJars(rootDir.resolve(Paths.get("lib", "svm", "builder"))));
} else {
result.addAll(getJars(rootDir.resolve(Paths.get("lib", "jvmci")), "graal-sdk", "enterprise-graal"));
result.addAll(getJars(rootDir.resolve(Paths.get("lib", "truffle")), "truffle-api"));
}
return result;
}
Expand Down