use of org.graalvm.polyglot.impl.AbstractPolyglotImpl in project graal by oracle.
the class ContextPreInitializationTest method findImpl.
AbstractPolyglotImpl findImpl() throws ReflectiveOperationException {
Method getImplMethod = Engine.class.getDeclaredMethod("getImpl");
getImplMethod.setAccessible(true);
return (AbstractPolyglotImpl) getImplMethod.invoke(null);
}
use of org.graalvm.polyglot.impl.AbstractPolyglotImpl in project graal by oracle.
the class IOHelper method initImpl.
private static AbstractPolyglotImpl initImpl() {
try {
Method method = Engine.class.getDeclaredMethod("getImpl");
method.setAccessible(true);
AbstractPolyglotImpl polyglotImpl = (AbstractPolyglotImpl) method.invoke(null);
polyglotImpl.setIO(new IOAccessImpl());
return polyglotImpl;
} catch (Exception e) {
throw new IllegalStateException("Failed to initialize execution listener class.", e);
}
}
use of org.graalvm.polyglot.impl.AbstractPolyglotImpl in project graal by oracle.
the class Management method initImpl.
private static AbstractPolyglotImpl initImpl() {
try {
Method method = Engine.class.getDeclaredMethod("getImpl");
method.setAccessible(true);
AbstractPolyglotImpl impl = (AbstractPolyglotImpl) method.invoke(null);
impl.setMonitoring(new ManagementAccessImpl());
return impl;
} catch (Exception e) {
throw new IllegalStateException("Failed to initialize execution listener class.", e);
}
}
use of org.graalvm.polyglot.impl.AbstractPolyglotImpl in project graal by oracle.
the class SourceAPITest method testNoContentSource.
@Test
@SuppressWarnings("rawtypes")
public void testNoContentSource() {
AbstractPolyglotImpl polyglot = (AbstractPolyglotImpl) ReflectionUtils.invokeStatic(Engine.class, "getImpl");
com.oracle.truffle.api.source.Source truffleSource = com.oracle.truffle.api.source.Source.newBuilder(ProxyLanguage.ID, "x", "name").content(com.oracle.truffle.api.source.Source.CONTENT_NONE).build();
Class<?>[] sourceConstructorTypes = new Class[] { AbstractSourceDispatch.class, Object.class };
Source source = ReflectionUtils.newInstance(Source.class, sourceConstructorTypes, polyglot.getAPIAccess().getDispatch(Source.create(ProxyLanguage.ID, "")), truffleSource);
assertFalse(source.hasCharacters());
assertFalse(source.hasBytes());
try {
source.getCharacters();
fail();
} catch (UnsupportedOperationException ex) {
// O.K.
}
try {
Context.create().eval(source);
fail();
} catch (IllegalArgumentException ex) {
// O.K.
}
com.oracle.truffle.api.source.SourceSection truffleSection = truffleSource.createSection(1, 2, 3, 4);
Class<?>[] sectionConstructorTypes = new Class[] { Source.class, AbstractSourceSectionDispatch.class, Object.class };
SourceSection section = ReflectionUtils.newInstance(SourceSection.class, sectionConstructorTypes, source, getSourceSectionDispatch(polyglot), truffleSection);
assertFalse(section.hasCharIndex());
assertTrue(section.hasLines());
assertTrue(section.hasColumns());
assertEquals("", section.getCharacters());
assertTrue(truffleSource.getURI().toString().contains("name"));
}
use of org.graalvm.polyglot.impl.AbstractPolyglotImpl in project graal by oracle.
the class PolyglotImpl method getImpl.
private static AbstractPolyglotImpl getImpl() {
AbstractPolyglotImpl local = abstractImpl;
if (local == null) {
try {
Method f = Engine.class.getDeclaredMethod("getImpl");
f.setAccessible(true);
abstractImpl = local = (AbstractPolyglotImpl) f.invoke(null);
assert local != null : "polyglot impl not found";
} catch (Exception e) {
throw new AssertionError(e);
}
}
return local;
}
Aggregations