use of com.oracle.truffle.api.instrumentation.TruffleInstrument in project graal by oracle.
the class DebuggerExampleTest method setupDebugger.
@Before
public void setupDebugger() throws IOException {
// BEGIN: DebuggerExampleTest
Instrument instrument = engine.getInstruments().get(DebuggerExample.ID);
assert !isCreated(instrument) : "Not enabled yet";
debugger = instrument.lookup(DebuggerController.class);
assert isCreated(instrument) : "Got enabled";
assert debugger != null : "We can control the debugger";
// END: DebuggerExampleTest
assertTrue("Enabled by requesting registered services class", isCreated(instrument));
assertNotNull("Debugger interface found", debugger);
DebuggerExample itself = instrument.lookup(DebuggerExample.class);
assertNull("Debugger instrument itself isn't found", itself);
TruffleInstrument instr = instrument.lookup(TruffleInstrument.class);
assertNull("Instrument itself isn't found", instr);
// ensure debugger gets loaded
assertEvalOut("", "");
}
use of com.oracle.truffle.api.instrumentation.TruffleInstrument in project graal by oracle.
the class InstrumentRegistrationProcessor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
generateFile(registrations);
registrations.clear();
return true;
}
for (Element e : roundEnv.getElementsAnnotatedWith(Registration.class)) {
Registration annotation = e.getAnnotation(Registration.class);
if (annotation != null && e.getKind() == ElementKind.CLASS) {
if (!e.getModifiers().contains(Modifier.PUBLIC)) {
emitError("Registered instrument class must be public", e);
continue;
}
if (e.getEnclosingElement().getKind() != ElementKind.PACKAGE && !e.getModifiers().contains(Modifier.STATIC)) {
emitError("Registered instrument inner-class must be static", e);
continue;
}
TypeMirror truffleLang = processingEnv.getTypeUtils().erasure(processingEnv.getElementUtils().getTypeElement(TruffleInstrument.class.getName()).asType());
if (!processingEnv.getTypeUtils().isAssignable(e.asType(), truffleLang)) {
emitError("Registered instrument class must subclass TruffleInstrument", e);
continue;
}
assertNoErrorExpected(e);
registrations.add((TypeElement) e);
}
}
return true;
}
Aggregations