Skip to content

Commit f17387f

Browse files
committed
GH-210 call Context.newBuilder().allowExperimentalOptions(true) instead of Context.create()
1 parent e6e4d22 commit f17387f

File tree

1 file changed

+7
-3
lines changed
  • visualvm/sampler.truffle/libsrc/org/graalvm/visualvm/sampler/truffle/stagent

1 file changed

+7
-3
lines changed

visualvm/sampler.truffle/libsrc/org/graalvm/visualvm/sampler/truffle/stagent/TruffleJMX.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ public static void agentmain(final String agentArgs, final Instrumentation inst)
8888
}
8989

9090
private static Object getContext() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, SecurityException, IllegalAccessException, IllegalArgumentException {
91-
// return org.graalvm.polyglot.Context.create()
91+
// return org.graalvm.polyglot.Context.newBuilder().allowExperimentalOptions(true)
9292
ClassLoader systemCl = ClassLoader.getSystemClassLoader();
9393
Class contextClass = systemCl.loadClass("org.graalvm.polyglot.Context");
94-
Method createMethod = contextClass.getMethod("create", String[].class);
95-
Object context = createMethod.invoke(null, new Object[] {new String[0]});
94+
Method builderMethod = contextClass.getMethod("newBuilder", String[].class);
95+
Object builder = builderMethod.invoke(null, new Object[] {new String[0]});
96+
Method allowExpMethod = builder.getClass().getMethod("allowExperimentalOptions", boolean.class);
97+
builder = allowExpMethod.invoke(builder, new Object[] {Boolean.TRUE});
98+
Method buildMethod = builder.getClass().getMethod("build");
99+
Object context = buildMethod.invoke(builder, new Object[]{});
96100
if (DEBUG) System.out.println("Context: " + context.getClass());
97101
if (DEBUG) System.out.println("Context ClassLoader: " + context.getClass().getClassLoader());
98102
return context;

0 commit comments

Comments
 (0)