/** * Returns an additional service provided by this instrument, specified by type. If an * instrument is not enabled, it will be enabled automatically by requesting a supported * service. If the instrument does not provide a service for a given type it will not be * enabled automatically. An {@link IllegalArgumentException} is thrown if a service is * looked up from the current instrument. * * @param <S> the requested type * @param instrument identification of the instrument to query * @param type the class of the requested type * @return the registered service or <code>null</code> if none is found * @since 0.26 */ public <S> S lookup(InstrumentInfo instrument, Class<S> type) { Object vm = AccessorInstrumentHandler.langAccess().getVMObject(instrument); if (vm == this.vmObject) { throw new IllegalArgumentException("Not allowed to lookup services from the currrent instrument."); } return AccessorInstrumentHandler.engineAccess().lookup(instrument, type); }
/** * Returns an additional service provided by this instrument, specified by type. If an * instrument is not enabled, it will be enabled automatically by requesting a supported * service. If the instrument does not provide a service for a given type it will not be * enabled automatically. An {@link IllegalArgumentException} is thrown if a service is * looked up from the current instrument. * * @param <S> the requested type * @param instrument identification of the instrument to query * @param type the class of the requested type * @return the registered service or <code>null</code> if none is found * @since 0.26 */ public <S> S lookup(InstrumentInfo instrument, Class<S> type) { Object vm = AccessorInstrumentHandler.langAccess().getVMObject(instrument); if (vm == this.vmObject) { throw new IllegalArgumentException("Not allowed to lookup services from the currrent instrument."); } return AccessorInstrumentHandler.engineAccess().lookup(instrument, type); }
@Override public <T> T lookup(InstrumentInfo info, Class<T> serviceClass) { PolyglotInstrument instrument = (PolyglotInstrument) LANGUAGE.getVMObject(info); return instrument.lookup(serviceClass, false); }
@Override public <T> T lookup(InstrumentInfo info, Class<T> serviceClass) { Object vmObject = LANGUAGE.getVMObject(info); Instrument instrument = (Instrument) vmObject; return instrument.lookup(serviceClass); }
@Override public <T> T lookup(InstrumentInfo info, Class<T> serviceClass) { PolyglotInstrument instrument = (PolyglotInstrument) LANGUAGE.getVMObject(info); return instrument.lookup(serviceClass); }