Skip to content

Commit

Permalink
open Truffle API to clients (such as TruffleNode) loaded via org.graa…
Browse files Browse the repository at this point in the history
…lvm.polyglot.Engine.loadLanguageClass(String)
  • Loading branch information
dougxc committed Oct 16, 2019
1 parent 765bd75 commit 7817ee7
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.impl.DispatchOutputStream;
import com.oracle.truffle.api.impl.TruffleJDKServices;
import com.oracle.truffle.api.impl.TruffleLocator;
import com.oracle.truffle.api.interop.InteropException;
import com.oracle.truffle.api.interop.TruffleObject;
Expand Down Expand Up @@ -237,7 +238,16 @@ public void resetPreInitializedEngine() {
public Class<?> loadLanguageClass(String className) {
for (ClassLoader loader : TruffleLocator.loaders()) {
try {
return loader.loadClass(className);
Class<?> c = loader.loadClass(className);
if (!TruffleOptions.AOT) {
/*
* In JDK 9+, the Truffle API packages must be dynamically exported to a Truffle
* API client since the Truffle API module descriptor only exports these
* packages to modules known at build time (such as the Graal module).
*/
TruffleJDKServices.exportTo(loader, null);
}
return c;
} catch (ClassNotFoundException e) {
}
}
Expand Down

0 comments on commit 7817ee7

Please sign in to comment.