void ensureInitialized() { if (!initialized) { synchronized (instrumentLock) { if (!initialized) { try { Class<?> loadedInstrument = cache.getInstrumentationClass(); INSTRUMENT.initializeInstrument(engine.instrumentationHandler, this, loadedInstrument); this.options = INSTRUMENT.describeOptions(engine.instrumentationHandler, this, cache.getId()); } catch (Exception e) { throw new IllegalStateException(String.format("Error initializing instrument '%s' using class '%s'.", cache.getId(), cache.getClassName()), e); } initialized = true; } } } }
void ensureInitialized() { if (!initialized) { synchronized (engine) { if (!initialized) { try { Class<?> loadedInstrument = cache.getInstrumentationClass(); INSTRUMENT.initializeInstrument(engine.instrumentationHandler, this, loadedInstrument); this.options = INSTRUMENT.describeOptions(engine.instrumentationHandler, this, cache.getId()); } catch (Exception e) { throw new IllegalStateException(String.format("Error initializing instrument '%s' using class '%s'.", cache.getId(), cache.getClassName()), e); } initialized = true; } } } }
void setEnabledImpl(final boolean enabled, boolean cleanup) { synchronized (instrumentLock) { if (this.enabled != enabled) { if (enabled) { if (PolyglotRuntime.this.disposed) { return; } INSTRUMENT.initializeInstrument(PolyglotRuntime.this.instrumentationHandler, this, getCache().getInstrumentationClass()); OptionDescriptors descriptors = INSTRUMENT.describeOptions(getRuntime().instrumentationHandler, this, this.getId()); OptionValuesImpl values = new OptionValuesImpl(null, descriptors); INSTRUMENT.createInstrument(PolyglotRuntime.this.instrumentationHandler, this, cache.services(), values); } else { INSTRUMENT.disposeInstrument(PolyglotRuntime.this.instrumentationHandler, this, cleanup); } this.enabled = enabled; } } }