use of org.graalvm.options.OptionValues in project graal by oracle.
the class InspectorInstrument method onCreate.
@Override
protected void onCreate(Env env) {
OptionValues options = env.getOptions();
if (options.hasSetOptions()) {
Server server = new Server(env);
try {
InetSocketAddress socketAddress = options.get(Inspect).createSocket(options.get(Remote));
server.start("Main Context", socketAddress, options.get(Suspend), options.get(WaitAttached), options.get(HideErrors), options.get(Path));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
use of org.graalvm.options.OptionValues in project graal by oracle.
the class OptionProcessorTest method testOptionValues.
@Test
public void testOptionValues() {
Engine engine = Engine.create();
OptionDescriptors descriptors = engine.getInstruments().get("optiontestinstr1").getOptions();
OptionValues optionValues = engine.getInstruments().get("optiontestinstr1").lookup(OptionValues.class);
assertSame(descriptors, optionValues.getDescriptors());
assertFalse(optionValues.hasSetOptions());
OptionKey<?> optionKey1 = descriptors.get("optiontestinstr1.StringOption1").getKey();
OptionKey<?> optionKey2 = descriptors.get("optiontestinstr1.StringOption2").getKey();
assertFalse(optionValues.hasBeenSet(optionKey1));
assertEquals("defaultValue", optionValues.get(optionKey1));
assertEquals("defaultValue", optionValues.get(optionKey2));
engine = Engine.newBuilder().option("optiontestinstr1.StringOption1", "test").build();
optionValues = engine.getInstruments().get("optiontestinstr1").lookup(OptionValues.class);
assertTrue(optionValues.hasSetOptions());
optionKey1 = descriptors.get("optiontestinstr1.StringOption1").getKey();
optionKey2 = descriptors.get("optiontestinstr1.StringOption2").getKey();
assertTrue(optionValues.hasBeenSet(optionKey1));
assertFalse(optionValues.hasBeenSet(optionKey2));
assertEquals("test", optionValues.get(optionKey1));
assertEquals("defaultValue", optionValues.get(optionKey2));
engine = Engine.newBuilder().option("optiontestlang1.StringOption1", "testLang").build();
optionValues = engine.getInstruments().get("optiontestinstr1").lookup(OptionValues.class);
// A language option was set, not the instrument one. Instrument sees no option set:
assertFalse(optionValues.hasSetOptions());
}
Aggregations