use of com.oracle.truffle.api.test.host.HostExceptionTest.CatcherObject in project graal by oracle.
the class MultiClassLoaderTest method before.
@Before
public void before() {
context = Context.newBuilder().allowAllAccess(true).build();
ProxyLanguage.setDelegate(new ProxyLanguage() {
@Override
protected LanguageContext createContext(Env contextEnv) {
env = contextEnv;
return super.createContext(contextEnv);
}
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
String req = request.getSource().getCharacters().toString();
if (req.startsWith("get:")) {
String name = req.substring(4);
RootCallTarget reader = new RootNode(ProxyLanguage.get(null)) {
@Override
public Object execute(VirtualFrame frame) {
Object obj = frame.getArguments()[0];
try {
Object hash = InteropLibrary.getFactory().getUncached(obj).readMember(obj, "hash");
return InteropLibrary.getFactory().getUncached(hash).readMember(hash, name);
} catch (UnsupportedMessageException | UnknownIdentifierException e) {
throw new IllegalStateException(e);
}
}
}.getCallTarget();
return RootNode.createConstantNode(new CatcherObject(reader)).getCallTarget();
}
throw new IllegalArgumentException();
}
});
context.initialize(ProxyLanguage.ID);
context.enter();
assertNotNull(env);
}
Aggregations