mirror of https://github.com/oracle/graal.git
[GR-46292] Remove deprecated TruffleInstrument.Provider and TruffleLanguage.Provider.
This commit is contained in:
parent
e73ffa17aa
commit
24a5f1a4ce
|
@ -1826,14 +1826,6 @@ suite = {
|
|||
"org.graalvm.polyglot",
|
||||
"org.graalvm.truffle.compiler",
|
||||
],
|
||||
"uses" : [
|
||||
"com.oracle.truffle.api.TruffleLanguage.Provider",
|
||||
"com.oracle.truffle.api.instrumentation.TruffleInstrument.Provider",
|
||||
"com.oracle.truffle.api.provider.TruffleLanguageProvider",
|
||||
"com.oracle.truffle.api.instrumentation.provider.TruffleInstrumentProvider",
|
||||
"com.oracle.truffle.api.TruffleLanguage.Provider", # Deprecated
|
||||
"com.oracle.truffle.api.instrumentation.TruffleInstrument.Provider", # Deprecated
|
||||
],
|
||||
"requiresConcealed": {
|
||||
"jdk.internal.vm.ci": [
|
||||
"jdk.vm.ci.common",
|
||||
|
|
|
@ -10,6 +10,8 @@ This changelog summarizes major changes between Truffle versions relevant to lan
|
|||
* GR-57550 Added support for long-width dispatch targets to Bytecode OSR.
|
||||
* PR-8266 Allow control of `throwDeniedThreadAccess` via `TruffleContext.threadAccessDeniedHandler`
|
||||
* GR-57817 Java Native access for [JEP-472](https://openjdk.org/jeps/472) is now automatically provided for all languages and tools by Truffle. For more information, refer to the [GraalVM SDK Changelog](https://github.com/oracle/graal/blob/master/sdk/CHANGELOG.md).
|
||||
* GR-46292 The deprecated `TruffleInstrument.Provider` and `TruffleLanguage.Provider` interfaces, deprecated since version 23.1, have now been removed. They are replaced by the `com.oracle.truffle.api.provider.TruffleLanguageProvider` and `com.oracle.truffle.api.instrumentation.provider.TruffleInstrumentProvider` interfaces. The implementations of these interfaces are automatically generated by the annotation processor and this change requires no source code modifications, only recompilation.
|
||||
* GR-46293 The deprecated `com.oracle.truffle.api.library.DefaultExportProvider` and `com.oracle.truffle.api.library.EagerExportProvider` interfaces, deprecated since version 23.1, have now been removed. They are replaced by the `com.oracle.truffle.api.library.provider.DefaultExportProvider` and `com.oracle.truffle.api.library.provider.EagerExportProvider` interfaces. The implementations of these interfaces are automatically generated by the annotation processor and this change requires no source code modifications, only recompilation.
|
||||
|
||||
|
||||
## Version 24.1.0
|
||||
|
|
|
@ -1715,10 +1715,6 @@ suite = {
|
|||
"com.oracle.truffle.api.library.provider.EagerExportProvider",
|
||||
"com.oracle.truffle.api.instrumentation.provider.TruffleInstrumentProvider",
|
||||
"com.oracle.truffle.api.strings.provider.JCodingsProvider",
|
||||
"com.oracle.truffle.api.library.DefaultExportProvider", # Deprecated
|
||||
"com.oracle.truffle.api.library.EagerExportProvider", # Deprecated
|
||||
"com.oracle.truffle.api.TruffleLanguage.Provider", # Deprecated
|
||||
"com.oracle.truffle.api.instrumentation.TruffleInstrument.Provider", # Deprecated
|
||||
],
|
||||
},
|
||||
|
||||
|
|
|
@ -395,7 +395,6 @@ innr protected abstract interface static ContextLocalFactory
|
|||
innr protected abstract interface static ContextThreadLocalFactory
|
||||
innr protected final static ContextLocalProvider
|
||||
innr public abstract interface static !annotation Registration
|
||||
innr public abstract interface static Provider
|
||||
innr public final static Env
|
||||
meth protected abstract void onCreate(com.oracle.truffle.api.instrumentation.TruffleInstrument$Env)
|
||||
meth protected final <%0 extends java.lang.Object> com.oracle.truffle.api.ContextLocal<{%%0}> createContextLocal(com.oracle.truffle.api.instrumentation.TruffleInstrument$ContextLocalFactory<{%%0}>)
|
||||
|
@ -468,13 +467,6 @@ supr java.lang.Object
|
|||
hfds err,in,instrumenter,messageTransport,options,out,polyglotInstrument,services
|
||||
hcls GuardedExecutableNode,MessageTransportProxy
|
||||
|
||||
CLSS public abstract interface static com.oracle.truffle.api.instrumentation.TruffleInstrument$Provider
|
||||
outer com.oracle.truffle.api.instrumentation.TruffleInstrument
|
||||
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="23.1")
|
||||
meth public abstract com.oracle.truffle.api.instrumentation.TruffleInstrument create()
|
||||
meth public abstract java.lang.String getInstrumentClassName()
|
||||
meth public abstract java.util.Collection<java.lang.String> getServicesClassNames()
|
||||
|
||||
CLSS public abstract interface static !annotation com.oracle.truffle.api.instrumentation.TruffleInstrument$Registration
|
||||
outer com.oracle.truffle.api.instrumentation.TruffleInstrument
|
||||
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
|
||||
|
@ -537,14 +529,6 @@ CLSS public abstract interface com.oracle.truffle.api.nodes.NodeInterface
|
|||
|
||||
CLSS public abstract interface java.lang.Cloneable
|
||||
|
||||
CLSS public abstract interface !annotation java.lang.Deprecated
|
||||
anno 0 java.lang.annotation.Documented()
|
||||
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
|
||||
anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, MODULE, PARAMETER, TYPE])
|
||||
intf java.lang.annotation.Annotation
|
||||
meth public abstract !hasdefault boolean forRemoval()
|
||||
meth public abstract !hasdefault java.lang.String since()
|
||||
|
||||
CLSS public abstract interface !annotation java.lang.FunctionalInterface
|
||||
anno 0 java.lang.annotation.Documented()
|
||||
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
|
||||
|
|
|
@ -55,11 +55,9 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -101,7 +99,6 @@ import com.oracle.truffle.api.frame.FrameDescriptor;
|
|||
import com.oracle.truffle.api.frame.MaterializedFrame;
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
import com.oracle.truffle.api.instrumentation.InstrumentationHandler.InstrumentClientInstrumenter;
|
||||
import com.oracle.truffle.api.instrumentation.provider.TruffleInstrumentProvider;
|
||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||
import com.oracle.truffle.api.nodes.ExecutableNode;
|
||||
import com.oracle.truffle.api.nodes.LanguageInfo;
|
||||
|
@ -1515,40 +1512,6 @@ public abstract class TruffleInstrument {
|
|||
Class<? extends InternalResource>[] internalResources() default {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to register a {@link TruffleInstrument} using a {@link ServiceLoader}. This interface is
|
||||
* not intended to be implemented directly by an instrument developer, rather the implementation
|
||||
* is generated by the Truffle DSL. The generated implementation has to inherit the
|
||||
* {@link Registration} annotations from the {@link TruffleInstrument}.
|
||||
*
|
||||
* @since 19.3.0
|
||||
* @deprecated Use {@link TruffleInstrumentProvider}.
|
||||
*/
|
||||
@Deprecated(since = "23.1")
|
||||
public interface Provider {
|
||||
|
||||
/**
|
||||
* Returns the name of a class implementing the {@link TruffleInstrument}.
|
||||
*
|
||||
* @since 19.3.0
|
||||
*/
|
||||
String getInstrumentClassName();
|
||||
|
||||
/**
|
||||
* Creates a new instance of a {@link TruffleInstrument}.
|
||||
*
|
||||
* @since 19.3.0
|
||||
*/
|
||||
TruffleInstrument create();
|
||||
|
||||
/**
|
||||
* Returns the class names of provided services.
|
||||
*
|
||||
* @since 19.3.0
|
||||
*/
|
||||
Collection<String> getServicesClassNames();
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
// Instrument is loaded by Engine which should load InstrumentationHandler
|
||||
|
|
|
@ -8,10 +8,6 @@ intf java.lang.annotation.Annotation
|
|||
meth public abstract !hasdefault java.lang.String limit()
|
||||
meth public abstract !hasdefault java.lang.String value()
|
||||
|
||||
CLSS public abstract interface com.oracle.truffle.api.library.DefaultExportProvider
|
||||
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="23.1")
|
||||
intf com.oracle.truffle.api.library.provider.DefaultExportProvider
|
||||
|
||||
CLSS public abstract com.oracle.truffle.api.library.DynamicDispatchLibrary
|
||||
cons protected init()
|
||||
meth public abstract java.lang.Object cast(java.lang.Object)
|
||||
|
@ -20,10 +16,6 @@ meth public static com.oracle.truffle.api.library.LibraryFactory<com.oracle.truf
|
|||
supr com.oracle.truffle.api.library.Library
|
||||
hfds FACTORY
|
||||
|
||||
CLSS public abstract interface com.oracle.truffle.api.library.EagerExportProvider
|
||||
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="23.1")
|
||||
intf com.oracle.truffle.api.library.provider.EagerExportProvider
|
||||
|
||||
CLSS public abstract interface !annotation com.oracle.truffle.api.library.ExportLibrary
|
||||
anno 0 java.lang.annotation.Repeatable(java.lang.Class<? extends java.lang.annotation.Annotation> value=class com.oracle.truffle.api.library.ExportLibrary$Repeat)
|
||||
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
|
||||
|
@ -241,14 +233,6 @@ CLSS public abstract interface com.oracle.truffle.api.nodes.NodeInterface
|
|||
|
||||
CLSS public abstract interface java.lang.Cloneable
|
||||
|
||||
CLSS public abstract interface !annotation java.lang.Deprecated
|
||||
anno 0 java.lang.annotation.Documented()
|
||||
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
|
||||
anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, MODULE, PARAMETER, TYPE])
|
||||
intf java.lang.annotation.Annotation
|
||||
meth public abstract !hasdefault boolean forRemoval()
|
||||
meth public abstract !hasdefault java.lang.String since()
|
||||
|
||||
CLSS public java.lang.Object
|
||||
cons public init()
|
||||
meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* The Universal Permissive License (UPL), Version 1.0
|
||||
*
|
||||
* Subject to the condition set forth below, permission is hereby granted to any
|
||||
* person obtaining a copy of this software, associated documentation and/or
|
||||
* data (collectively the "Software"), free of charge and under any and all
|
||||
* copyright rights in the Software, and any and all patent rights owned or
|
||||
* freely licensable by each licensor hereunder covering either (i) the
|
||||
* unmodified Software as contributed to or provided by such licensor, or (ii)
|
||||
* the Larger Works (as defined below), to deal in both
|
||||
*
|
||||
* (a) the Software, and
|
||||
*
|
||||
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
|
||||
* one is included with the Software each a "Larger Work" to which the Software
|
||||
* is contributed by such licensors),
|
||||
*
|
||||
* without restriction, including without limitation the rights to copy, create
|
||||
* derivative works of, display, perform, and distribute the Software and make,
|
||||
* use, sell, offer for sale, import, export, have made, and have sold the
|
||||
* Software and the Larger Work(s), and to sublicense the foregoing rights on
|
||||
* either these or other terms.
|
||||
*
|
||||
* This license is subject to the following condition:
|
||||
*
|
||||
* The above copyright notice and either this complete permission notice or at a
|
||||
* minimum a reference to the UPL must be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.oracle.truffle.api.library;
|
||||
|
||||
/**
|
||||
* Service provider interface implemented by external default exports of a library. This class is
|
||||
* not intended to be implemented manually but automatically generated by the annotation processor
|
||||
* when needed.
|
||||
*
|
||||
* @since 20.0
|
||||
* @deprecated Use {@link com.oracle.truffle.api.library.provider.DefaultExportProvider}.
|
||||
*/
|
||||
@Deprecated(since = "23.1")
|
||||
public interface DefaultExportProvider extends com.oracle.truffle.api.library.provider.DefaultExportProvider {
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* The Universal Permissive License (UPL), Version 1.0
|
||||
*
|
||||
* Subject to the condition set forth below, permission is hereby granted to any
|
||||
* person obtaining a copy of this software, associated documentation and/or
|
||||
* data (collectively the "Software"), free of charge and under any and all
|
||||
* copyright rights in the Software, and any and all patent rights owned or
|
||||
* freely licensable by each licensor hereunder covering either (i) the
|
||||
* unmodified Software as contributed to or provided by such licensor, or (ii)
|
||||
* the Larger Works (as defined below), to deal in both
|
||||
*
|
||||
* (a) the Software, and
|
||||
*
|
||||
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
|
||||
* one is included with the Software each a "Larger Work" to which the Software
|
||||
* is contributed by such licensors),
|
||||
*
|
||||
* without restriction, including without limitation the rights to copy, create
|
||||
* derivative works of, display, perform, and distribute the Software and make,
|
||||
* use, sell, offer for sale, import, export, have made, and have sold the
|
||||
* Software and the Larger Work(s), and to sublicense the foregoing rights on
|
||||
* either these or other terms.
|
||||
*
|
||||
* This license is subject to the following condition:
|
||||
*
|
||||
* The above copyright notice and either this complete permission notice or at a
|
||||
* minimum a reference to the UPL must be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.oracle.truffle.api.library;
|
||||
|
||||
/**
|
||||
* Service provider interface implemented by library exports if they needed to be loaded eagerly
|
||||
* with a library. For example, this is used for exports that are marked to be
|
||||
* {@link ExportLibrary#useForAOT() used for AOT}. On SVM we can rely that the closed world analysis
|
||||
* registers all exports at image generation time, so there is no need to use these service
|
||||
* providers.
|
||||
* <p>
|
||||
* Service provider interface implementations and uses are intended to be automatically generated by
|
||||
* the Truffle DSL annotation processor. Do not declare custom eager export providers or call
|
||||
* {@link #ensureRegistered()}.
|
||||
*
|
||||
* @since 21.2
|
||||
* @deprecated Use {@link com.oracle.truffle.api.library.provider.EagerExportProvider}.
|
||||
*/
|
||||
@Deprecated(since = "23.1")
|
||||
public interface EagerExportProvider extends com.oracle.truffle.api.library.provider.EagerExportProvider {
|
||||
}
|
|
@ -445,7 +445,6 @@ innr protected abstract interface static ContextLocalFactory
|
|||
innr protected abstract interface static ContextThreadLocalFactory
|
||||
innr protected final static ContextLocalProvider
|
||||
innr public abstract interface static !annotation Registration
|
||||
innr public abstract interface static Provider
|
||||
innr public abstract static ContextReference
|
||||
innr public abstract static LanguageReference
|
||||
innr public final static !enum ContextPolicy
|
||||
|
@ -647,14 +646,6 @@ meth public java.util.List<java.lang.String> getArgumentNames()
|
|||
supr java.lang.Object
|
||||
hfds argumentNames,disposed,source
|
||||
|
||||
CLSS public abstract interface static com.oracle.truffle.api.TruffleLanguage$Provider
|
||||
outer com.oracle.truffle.api.TruffleLanguage
|
||||
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="23.1")
|
||||
meth public abstract com.oracle.truffle.api.TruffleLanguage<?> create()
|
||||
meth public abstract java.lang.String getLanguageClassName()
|
||||
meth public abstract java.util.Collection<java.lang.String> getServicesClassNames()
|
||||
meth public abstract java.util.List<com.oracle.truffle.api.TruffleFile$FileTypeDetector> createFileTypeDetectors()
|
||||
|
||||
CLSS public abstract interface static !annotation com.oracle.truffle.api.TruffleLanguage$Registration
|
||||
outer com.oracle.truffle.api.TruffleLanguage
|
||||
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
|
||||
|
|
|
@ -58,13 +58,11 @@ import java.nio.file.StandardOpenOption;
|
|||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -95,7 +93,6 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
|
|||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
||||
import com.oracle.truffle.api.InternalResource.Id;
|
||||
import com.oracle.truffle.api.TruffleFile.FileSystemContext;
|
||||
import com.oracle.truffle.api.TruffleFile.FileTypeDetector;
|
||||
import com.oracle.truffle.api.TruffleLanguage.Env;
|
||||
import com.oracle.truffle.api.TruffleSafepoint.Interrupter;
|
||||
import com.oracle.truffle.api.TruffleSafepoint.Interruptible;
|
||||
|
@ -108,7 +105,6 @@ import com.oracle.truffle.api.nodes.ExecutableNode;
|
|||
import com.oracle.truffle.api.nodes.LanguageInfo;
|
||||
import com.oracle.truffle.api.nodes.Node;
|
||||
import com.oracle.truffle.api.nodes.RootNode;
|
||||
import com.oracle.truffle.api.provider.TruffleLanguageProvider;
|
||||
import com.oracle.truffle.api.source.Source;
|
||||
|
||||
/**
|
||||
|
@ -542,47 +538,6 @@ public abstract class TruffleLanguage<C> {
|
|||
Class<? extends InternalResource>[] internalResources() default {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to register a {@link TruffleLanguage} using a {@link ServiceLoader}. This interface is
|
||||
* not intended to be implemented directly by a language developer, rather the implementation is
|
||||
* generated by the Truffle DSL. The generated implementation has to inherit the
|
||||
* {@link Registration} and {@code ProvidedTags} annotations from the {@link TruffleLanguage}.
|
||||
*
|
||||
* @since 19.3.0
|
||||
* @deprecated Use {@link TruffleLanguageProvider}.
|
||||
*/
|
||||
@Deprecated(since = "23.1")
|
||||
public interface Provider {
|
||||
|
||||
/**
|
||||
* Returns the name of a class implementing the {@link TruffleLanguage}.
|
||||
*
|
||||
* @since 19.3.0
|
||||
*/
|
||||
String getLanguageClassName();
|
||||
|
||||
/**
|
||||
* Creates a new instance of a {@link TruffleLanguage}.
|
||||
*
|
||||
* @since 19.3.0
|
||||
*/
|
||||
TruffleLanguage<?> create();
|
||||
|
||||
/**
|
||||
* Creates file type detectors used by the {@link TruffleLanguage}.
|
||||
*
|
||||
* @since 19.3.0
|
||||
*/
|
||||
List<FileTypeDetector> createFileTypeDetectors();
|
||||
|
||||
/**
|
||||
* Returns the class names of provided services.
|
||||
*
|
||||
* @since 19.3.0
|
||||
*/
|
||||
Collection<String> getServicesClassNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for creating context local and context thread local references.
|
||||
*
|
||||
|
|
|
@ -114,8 +114,6 @@ import com.oracle.truffle.api.instrumentation.ThreadsListener;
|
|||
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||
import com.oracle.truffle.api.interop.TruffleObject;
|
||||
import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
||||
import com.oracle.truffle.api.library.provider.DefaultExportProvider;
|
||||
import com.oracle.truffle.api.library.provider.EagerExportProvider;
|
||||
import com.oracle.truffle.api.nodes.EncapsulatingNodeReference;
|
||||
import com.oracle.truffle.api.nodes.LanguageInfo;
|
||||
import com.oracle.truffle.api.nodes.Node;
|
||||
|
@ -328,12 +326,6 @@ final class EngineAccessor extends Accessor {
|
|||
Map<Class<?>, T> found = new LinkedHashMap<>();
|
||||
// 1) Add known Truffle DynamicObjectLibraryProvider service.
|
||||
DYNAMIC_OBJECT.lookupTruffleService(type).forEach((s) -> found.putIfAbsent(s.getClass(), s));
|
||||
Class<? extends T> legacyInterface = null;
|
||||
if (type == EagerExportProvider.class) {
|
||||
legacyInterface = com.oracle.truffle.api.library.EagerExportProvider.class.asSubclass(type);
|
||||
} else if (type == DefaultExportProvider.class) {
|
||||
legacyInterface = com.oracle.truffle.api.library.DefaultExportProvider.class.asSubclass(type);
|
||||
}
|
||||
for (AbstractClassLoaderSupplier loaderSupplier : EngineAccessor.locatorOrDefaultLoaders()) {
|
||||
ClassLoader loader = loaderSupplier.get();
|
||||
if (loader != null) {
|
||||
|
@ -344,16 +336,6 @@ final class EngineAccessor extends Accessor {
|
|||
found.putIfAbsent(service.getClass(), service);
|
||||
}
|
||||
}
|
||||
// 3) Lookup implementations of a legacy interface
|
||||
// GR-46293 Remove the deprecated service interface lookup.
|
||||
if (legacyInterface != null && loaderSupplier.supportsLegacyProviders()) {
|
||||
JDKSupport.exportToUnnamedModuleOf(loader);
|
||||
for (T service : ServiceLoader.load(legacyInterface, loader)) {
|
||||
if (loaderSupplier.accepts(service.getClass())) {
|
||||
found.putIfAbsent(service.getClass(), service);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return found.values();
|
||||
|
@ -2217,10 +2199,6 @@ final class EngineAccessor extends Accessor {
|
|||
this.hashCode = loader == null ? 0 : loader.hashCode();
|
||||
}
|
||||
|
||||
boolean supportsLegacyProviders() {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean accepts(@SuppressWarnings("unused") Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
|
@ -2264,11 +2242,6 @@ final class EngineAccessor extends Accessor {
|
|||
super(classLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean supportsLegacyProviders() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(Class<?> clazz) {
|
||||
return clazz.getModule().isNamed();
|
||||
|
@ -2296,11 +2269,6 @@ final class EngineAccessor extends Accessor {
|
|||
super(loader);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean supportsLegacyProviders() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(Class<?> clazz) {
|
||||
return clazz.getModule().isNamed();
|
||||
|
|
|
@ -49,7 +49,6 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
@ -57,7 +56,6 @@ import java.util.function.Supplier;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.oracle.truffle.api.InternalResource;
|
||||
import com.oracle.truffle.api.TruffleOptions;
|
||||
import com.oracle.truffle.api.instrumentation.TruffleInstrument;
|
||||
import com.oracle.truffle.api.instrumentation.TruffleInstrument.Registration;
|
||||
|
@ -77,7 +75,7 @@ final class InstrumentCache {
|
|||
private final String website;
|
||||
private final boolean internal;
|
||||
private final Set<String> services;
|
||||
private final ProviderAdapter providerAdapter;
|
||||
private final TruffleInstrumentProvider provider;
|
||||
private final SandboxPolicy sandboxPolicy;
|
||||
private final Map<String, InternalResourceCache> internalResources;
|
||||
|
||||
|
@ -120,7 +118,7 @@ final class InstrumentCache {
|
|||
}
|
||||
|
||||
private InstrumentCache(String id, String name, String version, String className, boolean internal, Set<String> services,
|
||||
ProviderAdapter providerAdapter, String website, SandboxPolicy sandboxPolicy, Map<String, InternalResourceCache> internalResources) {
|
||||
TruffleInstrumentProvider provider, String website, SandboxPolicy sandboxPolicy, Map<String, InternalResourceCache> internalResources) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
|
@ -128,7 +126,7 @@ final class InstrumentCache {
|
|||
this.className = className;
|
||||
this.internal = internal;
|
||||
this.services = services;
|
||||
this.providerAdapter = providerAdapter;
|
||||
this.provider = provider;
|
||||
this.sandboxPolicy = sandboxPolicy;
|
||||
this.internalResources = internalResources;
|
||||
}
|
||||
|
@ -174,10 +172,7 @@ final class InstrumentCache {
|
|||
continue;
|
||||
}
|
||||
usesTruffleClassLoader |= truffleClassLoader == loader;
|
||||
loadProviders(loader).filter((p) -> supplier.accepts(p.getProviderClass())).forEach((p) -> loadInstrumentImpl(p, list, classNamesUsed, optionalResources));
|
||||
if (supplier.supportsLegacyProviders()) {
|
||||
loadLegacyProviders(loader).filter((p) -> supplier.accepts(p.getProviderClass())).forEach((p) -> loadInstrumentImpl(p, list, classNamesUsed, optionalResources));
|
||||
}
|
||||
loadProviders(loader).filter((p) -> supplier.accepts(p.getClass())).forEach((p) -> loadInstrumentImpl(p, list, classNamesUsed, optionalResources));
|
||||
}
|
||||
/*
|
||||
* Resolves a missing debugger instrument when the GuestLangToolsClassLoader does not define
|
||||
|
@ -188,26 +183,20 @@ final class InstrumentCache {
|
|||
if (!usesTruffleClassLoader) {
|
||||
Module truffleModule = InstrumentCache.class.getModule();
|
||||
loadProviders(truffleClassLoader).//
|
||||
filter((p) -> p.getProviderClass().getModule().equals(truffleModule)).//
|
||||
filter((p) -> p.getClass().getModule().equals(truffleModule)).//
|
||||
forEach((p) -> loadInstrumentImpl(p, list, classNamesUsed, optionalResources));
|
||||
}
|
||||
list.sort(Comparator.comparing(InstrumentCache::getId));
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Stream<? extends ProviderAdapter> loadLegacyProviders(ClassLoader loader) {
|
||||
JDKSupport.exportToUnnamedModuleOf(loader);
|
||||
return StreamSupport.stream(ServiceLoader.load(TruffleInstrument.Provider.class, loader).spliterator(), false).map(LegacyProvider::new);
|
||||
private static Stream<? extends TruffleInstrumentProvider> loadProviders(ClassLoader loader) {
|
||||
return StreamSupport.stream(ServiceLoader.load(TruffleInstrumentProvider.class, loader).spliterator(), false);
|
||||
}
|
||||
|
||||
private static Stream<? extends ProviderAdapter> loadProviders(ClassLoader loader) {
|
||||
return StreamSupport.stream(ServiceLoader.load(TruffleInstrumentProvider.class, loader).spliterator(), false).map(ModuleAwareProvider::new);
|
||||
}
|
||||
|
||||
private static void loadInstrumentImpl(ProviderAdapter providerAdapter, List<? super InstrumentCache> list, Set<? super String> classNamesUsed,
|
||||
private static void loadInstrumentImpl(TruffleInstrumentProvider provider, List<? super InstrumentCache> list, Set<? super String> classNamesUsed,
|
||||
Map<String, Map<String, Supplier<InternalResourceCache>>> optionalResources) {
|
||||
Class<?> providerClass = providerAdapter.getProviderClass();
|
||||
Class<?> providerClass = provider.getClass();
|
||||
Module providerModule = providerClass.getModule();
|
||||
JDKSupport.exportTransitivelyTo(providerModule);
|
||||
/*
|
||||
|
@ -219,7 +208,7 @@ final class InstrumentCache {
|
|||
emitWarning("Warning Truffle instrument ignored: Provider %s is missing @Registration annotation.", providerClass);
|
||||
return;
|
||||
}
|
||||
String className = providerAdapter.getInstrumentClassName();
|
||||
String className = EngineAccessor.INSTRUMENT_PROVIDER.getInstrumentClassName(provider);
|
||||
String name = reg.name();
|
||||
String id = reg.id();
|
||||
if (id == null || id.isEmpty()) {
|
||||
|
@ -234,10 +223,10 @@ final class InstrumentCache {
|
|||
String website = reg.website();
|
||||
SandboxPolicy sandboxPolicy = reg.sandbox();
|
||||
boolean internal = reg.internal();
|
||||
Set<String> servicesClassNames = new TreeSet<>(providerAdapter.getServicesClassNames());
|
||||
Set<String> servicesClassNames = new TreeSet<>(EngineAccessor.INSTRUMENT_PROVIDER.getServicesClassNames(provider));
|
||||
Map<String, InternalResourceCache> resources = new HashMap<>();
|
||||
for (String resourceId : providerAdapter.getInternalResourceIds()) {
|
||||
resources.put(resourceId, new InternalResourceCache(id, resourceId, () -> providerAdapter.createInternalResource(resourceId)));
|
||||
for (String resourceId : EngineAccessor.INSTRUMENT_PROVIDER.getInternalResourceIds(provider)) {
|
||||
resources.put(resourceId, new InternalResourceCache(id, resourceId, () -> EngineAccessor.INSTRUMENT_PROVIDER.createInternalResource(provider, resourceId)));
|
||||
}
|
||||
for (Map.Entry<String, Supplier<InternalResourceCache>> resourceSupplier : optionalResources.getOrDefault(id, Map.of()).entrySet()) {
|
||||
InternalResourceCache resource = resourceSupplier.getValue().get();
|
||||
|
@ -249,7 +238,7 @@ final class InstrumentCache {
|
|||
// we don't want multiple instruments with the same class name
|
||||
if (!classNamesUsed.contains(className)) {
|
||||
classNamesUsed.add(className);
|
||||
list.add(new InstrumentCache(id, name, version, className, internal, servicesClassNames, providerAdapter, website, sandboxPolicy, Collections.unmodifiableMap(resources)));
|
||||
list.add(new InstrumentCache(id, name, version, className, internal, servicesClassNames, provider, website, sandboxPolicy, Collections.unmodifiableMap(resources)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +259,7 @@ final class InstrumentCache {
|
|||
}
|
||||
|
||||
TruffleInstrument loadInstrument() {
|
||||
return providerAdapter.create();
|
||||
return (TruffleInstrument) EngineAccessor.INSTRUMENT_PROVIDER.create(provider);
|
||||
}
|
||||
|
||||
boolean supportsService(Class<?> clazz) {
|
||||
|
@ -305,108 +294,4 @@ final class InstrumentCache {
|
|||
PrintStream out = System.err;
|
||||
out.printf(message + "%n", args);
|
||||
}
|
||||
|
||||
private interface ProviderAdapter {
|
||||
Class<?> getProviderClass();
|
||||
|
||||
TruffleInstrument create();
|
||||
|
||||
String getInstrumentClassName();
|
||||
|
||||
Collection<String> getServicesClassNames();
|
||||
|
||||
List<String> getInternalResourceIds();
|
||||
|
||||
InternalResource createInternalResource(String resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider adapter for deprecated {@code TruffleInstrument.Provider}. GR-46292 Remove the
|
||||
* deprecated {@code TruffleInstrument.Provider} and this adapter. When removed, the
|
||||
* {@link ModuleAwareProvider} should also be removed.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final class LegacyProvider implements ProviderAdapter {
|
||||
|
||||
private final TruffleInstrument.Provider provider;
|
||||
|
||||
LegacyProvider(TruffleInstrument.Provider provider) {
|
||||
Objects.requireNonNull(provider, "Provider must be non null");
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getProviderClass() {
|
||||
return provider.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TruffleInstrument create() {
|
||||
return provider.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstrumentClassName() {
|
||||
return provider.getInstrumentClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getServicesClassNames() {
|
||||
return provider.getServicesClassNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInternalResourceIds() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalResource createInternalResource(String resourceId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider adapter for {@link TruffleInstrumentProvider}. When the {@link LegacyProvider} is
|
||||
* removed, this class should also be removed.
|
||||
*/
|
||||
private static final class ModuleAwareProvider implements ProviderAdapter {
|
||||
|
||||
private final TruffleInstrumentProvider provider;
|
||||
|
||||
ModuleAwareProvider(TruffleInstrumentProvider provider) {
|
||||
Objects.requireNonNull(provider, "Provider must be non null");
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getProviderClass() {
|
||||
return provider.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TruffleInstrument create() {
|
||||
return (TruffleInstrument) EngineAccessor.INSTRUMENT_PROVIDER.create(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstrumentClassName() {
|
||||
return EngineAccessor.INSTRUMENT_PROVIDER.getInstrumentClassName(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getServicesClassNames() {
|
||||
return EngineAccessor.INSTRUMENT_PROVIDER.getServicesClassNames(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInternalResourceIds() {
|
||||
return EngineAccessor.INSTRUMENT_PROVIDER.getInternalResourceIds(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalResource createInternalResource(String resourceId) {
|
||||
return EngineAccessor.INSTRUMENT_PROVIDER.createInternalResource(provider, resourceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,16 +185,6 @@ final class JDKSupport {
|
|||
private JDKSupport() {
|
||||
}
|
||||
|
||||
static void exportTo(Module clientModule) {
|
||||
if (!isExportedTo(clientModule)) {
|
||||
exportFromTo(clientModule);
|
||||
}
|
||||
}
|
||||
|
||||
static void exportToUnnamedModuleOf(ClassLoader loader) {
|
||||
exportTo(loader.getUnnamedModule());
|
||||
}
|
||||
|
||||
static void exportTransitivelyTo(Module clientModule) {
|
||||
if (isExportedTo(clientModule)) {
|
||||
return;
|
||||
|
|
|
@ -71,7 +71,6 @@ import org.graalvm.polyglot.SandboxPolicy;
|
|||
|
||||
import com.oracle.truffle.api.CompilerDirectives;
|
||||
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
|
||||
import com.oracle.truffle.api.InternalResource;
|
||||
import com.oracle.truffle.api.TruffleFile.FileTypeDetector;
|
||||
import com.oracle.truffle.api.TruffleLanguage;
|
||||
import com.oracle.truffle.api.TruffleLanguage.ContextPolicy;
|
||||
|
@ -108,7 +107,7 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
private final boolean needsAllEncodings;
|
||||
private final Set<String> services;
|
||||
private final ContextPolicy contextPolicy;
|
||||
private final ProviderAdapter providerAdapter;
|
||||
private final TruffleLanguageProvider provider;
|
||||
private final String website;
|
||||
private final SandboxPolicy sandboxPolicy;
|
||||
private volatile List<FileTypeDetector> fileTypeDetectors;
|
||||
|
@ -125,9 +124,9 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
private LanguageCache(String id, String name, String implementationName, String version, String className,
|
||||
String languageHome, Set<String> characterMimeTypes, Set<String> byteMimeTypes, String defaultMimeType,
|
||||
Set<String> dependentLanguages, boolean interactive, boolean internal, boolean needsAllEncodings, Set<String> services,
|
||||
ContextPolicy contextPolicy, ProviderAdapter providerAdapter, String website, SandboxPolicy sandboxPolicy,
|
||||
ContextPolicy contextPolicy, TruffleLanguageProvider provider, String website, SandboxPolicy sandboxPolicy,
|
||||
Map<String, InternalResourceCache> internalResources) {
|
||||
assert providerAdapter != null : "Provider must be non null";
|
||||
assert provider != null : "Provider must be non null";
|
||||
this.className = className;
|
||||
this.name = name;
|
||||
this.implementationName = implementationName;
|
||||
|
@ -145,7 +144,7 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
this.languageHome = languageHome;
|
||||
this.services = services;
|
||||
this.contextPolicy = contextPolicy;
|
||||
this.providerAdapter = providerAdapter;
|
||||
this.provider = provider;
|
||||
this.website = website;
|
||||
this.sandboxPolicy = sandboxPolicy;
|
||||
this.internalResources = internalResources;
|
||||
|
@ -173,7 +172,7 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
null,
|
||||
Collections.emptySet(),
|
||||
false, false, false, hostLanguageProvider.getServicesClassNames(),
|
||||
ContextPolicy.SHARED, new ModuleAwareProvider(hostLanguageProvider), "", SandboxPolicy.UNTRUSTED, Map.of());
|
||||
ContextPolicy.SHARED, hostLanguageProvider, "", SandboxPolicy.UNTRUSTED, Map.of());
|
||||
cache.staticIndex = PolyglotEngineImpl.HOST_LANGUAGE_INDEX;
|
||||
return cache;
|
||||
}
|
||||
|
@ -275,10 +274,7 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
if (loader == null) {
|
||||
continue;
|
||||
}
|
||||
loadProviders(loader).filter((p) -> supplier.accepts(p.getProviderClass())).forEach((p) -> loadLanguageImpl(p, caches, optionalResources));
|
||||
if (supplier.supportsLegacyProviders()) {
|
||||
loadLegacyProviders(loader).filter((p) -> supplier.accepts(p.getProviderClass())).forEach((p) -> loadLanguageImpl(p, caches, optionalResources));
|
||||
}
|
||||
loadProviders(loader).filter((p) -> supplier.accepts(p.getClass())).forEach((p) -> loadLanguageImpl(p, caches, optionalResources));
|
||||
}
|
||||
|
||||
Map<String, LanguageCache> idToCache = new LinkedHashMap<>();
|
||||
|
@ -304,23 +300,17 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
return idToCache;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Stream<? extends ProviderAdapter> loadLegacyProviders(ClassLoader loader) {
|
||||
JDKSupport.exportToUnnamedModuleOf(loader);
|
||||
return StreamSupport.stream(ServiceLoader.load(TruffleLanguage.Provider.class, loader).spliterator(), false).map(LegacyProvider::new);
|
||||
}
|
||||
|
||||
private static Stream<? extends ProviderAdapter> loadProviders(ClassLoader loader) {
|
||||
return StreamSupport.stream(ServiceLoader.load(TruffleLanguageProvider.class, loader).spliterator(), false).map(ModuleAwareProvider::new);
|
||||
private static Stream<? extends TruffleLanguageProvider> loadProviders(ClassLoader loader) {
|
||||
return StreamSupport.stream(ServiceLoader.load(TruffleLanguageProvider.class, loader).spliterator(), false);
|
||||
}
|
||||
|
||||
private static boolean hasSameCodeSource(LanguageCache first, LanguageCache second) {
|
||||
return first.providerAdapter.getProviderClass() == second.providerAdapter.getProviderClass();
|
||||
return first.provider.getClass() == second.provider.getClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void loadLanguageImpl(ProviderAdapter providerAdapter, List<LanguageCache> into, Map<String, Map<String, Supplier<InternalResourceCache>>> optionalResources) {
|
||||
Class<?> providerClass = providerAdapter.getProviderClass();
|
||||
private static void loadLanguageImpl(TruffleLanguageProvider provider, List<LanguageCache> into, Map<String, Map<String, Supplier<InternalResourceCache>>> optionalResources) {
|
||||
Class<?> providerClass = provider.getClass();
|
||||
Module providerModule = providerClass.getModule();
|
||||
JDKSupport.exportTransitivelyTo(providerModule);
|
||||
/*
|
||||
|
@ -332,7 +322,7 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
emitWarning("Warning Truffle language ignored: Provider %s is missing @Registration annotation.", providerClass);
|
||||
return;
|
||||
}
|
||||
String className = providerAdapter.getLanguageClassName();
|
||||
String className = EngineAccessor.LANGUAGE_PROVIDER.getLanguageClassName(provider);
|
||||
String name = reg.name();
|
||||
String id = reg.id();
|
||||
if (id == null || id.isEmpty()) {
|
||||
|
@ -384,11 +374,11 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
needsAllEncodings = true;
|
||||
}
|
||||
}
|
||||
Set<String> servicesClassNames = new TreeSet<>(providerAdapter.getServicesClassNames());
|
||||
Set<String> servicesClassNames = new TreeSet<>(EngineAccessor.LANGUAGE_PROVIDER.getServicesClassNames(provider));
|
||||
SandboxPolicy sandboxPolicy = reg.sandbox();
|
||||
Map<String, InternalResourceCache> resources = new HashMap<>();
|
||||
for (String resourceId : providerAdapter.getInternalResourceIds()) {
|
||||
resources.put(resourceId, new InternalResourceCache(id, resourceId, () -> providerAdapter.createInternalResource(resourceId)));
|
||||
for (String resourceId : EngineAccessor.LANGUAGE_PROVIDER.getInternalResourceIds(provider)) {
|
||||
resources.put(resourceId, new InternalResourceCache(id, resourceId, () -> EngineAccessor.LANGUAGE_PROVIDER.createInternalResource(provider, resourceId)));
|
||||
}
|
||||
for (Map.Entry<String, Supplier<InternalResourceCache>> resourceSupplier : optionalResources.getOrDefault(id, Map.of()).entrySet()) {
|
||||
InternalResourceCache resource = resourceSupplier.getValue().get();
|
||||
|
@ -399,14 +389,14 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
}
|
||||
into.add(new LanguageCache(id, name, implementationName, version, className, languageHome,
|
||||
characterMimes, byteMimeTypes, defaultMime, dependentLanguages, interactive, internal, needsAllEncodings,
|
||||
servicesClassNames, reg.contextPolicy(), providerAdapter, reg.website(), sandboxPolicy, Collections.unmodifiableMap(resources)));
|
||||
servicesClassNames, reg.contextPolicy(), provider, reg.website(), sandboxPolicy, Collections.unmodifiableMap(resources)));
|
||||
}
|
||||
|
||||
private static String formatLanguageLocation(LanguageCache languageCache) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Language class ").append(languageCache.getClassName());
|
||||
|
||||
CodeSource source = languageCache.providerAdapter.getProviderClass().getProtectionDomain().getCodeSource();
|
||||
CodeSource source = languageCache.provider.getClass().getProtectionDomain().getCodeSource();
|
||||
URL url = source != null ? source.getLocation() : null;
|
||||
if (url != null) {
|
||||
sb.append(", Loaded from " + url);
|
||||
|
@ -600,14 +590,14 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
}
|
||||
|
||||
TruffleLanguage<?> loadLanguage() {
|
||||
return providerAdapter.create();
|
||||
return (TruffleLanguage<?>) EngineAccessor.LANGUAGE_PROVIDER.create(provider);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<? extends Tag>> getProvidedTags() {
|
||||
Set<Class<? extends Tag>> res = providedTags;
|
||||
if (res == null) {
|
||||
ProvidedTags tags = providerAdapter.getProviderClass().getAnnotation(ProvidedTags.class);
|
||||
ProvidedTags tags = provider.getClass().getAnnotation(ProvidedTags.class);
|
||||
if (tags == null) {
|
||||
res = Collections.emptySet();
|
||||
} else {
|
||||
|
@ -635,7 +625,7 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
List<? extends FileTypeDetector> getFileTypeDetectors() {
|
||||
List<FileTypeDetector> result = fileTypeDetectors;
|
||||
if (result == null) {
|
||||
result = providerAdapter.createFileTypeDetectors();
|
||||
result = EngineAccessor.LANGUAGE_PROVIDER.createFileTypeDetectors(provider);
|
||||
fileTypeDetectors = result;
|
||||
}
|
||||
return result;
|
||||
|
@ -708,118 +698,4 @@ final class LanguageCache implements Comparable<LanguageCache> {
|
|||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
private interface ProviderAdapter {
|
||||
Class<?> getProviderClass();
|
||||
|
||||
TruffleLanguage<?> create();
|
||||
|
||||
String getLanguageClassName();
|
||||
|
||||
Collection<String> getServicesClassNames();
|
||||
|
||||
List<FileTypeDetector> createFileTypeDetectors();
|
||||
|
||||
List<String> getInternalResourceIds();
|
||||
|
||||
InternalResource createInternalResource(String resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider adapter for deprecated {@code TruffleLanguage.Provider}. GR-46292 Remove the
|
||||
* deprecated {@code TruffleLanguage.Provider} and this adapter. When removed, the
|
||||
* {@link ModuleAwareProvider} should also be removed.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final class LegacyProvider implements ProviderAdapter {
|
||||
|
||||
private final TruffleLanguage.Provider provider;
|
||||
|
||||
LegacyProvider(TruffleLanguage.Provider provider) {
|
||||
Objects.requireNonNull(provider, "Provider must be non null");
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getProviderClass() {
|
||||
return provider.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TruffleLanguage<?> create() {
|
||||
return provider.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageClassName() {
|
||||
return provider.getLanguageClassName();
|
||||
}
|
||||
|
||||
public Collection<String> getServicesClassNames() {
|
||||
return provider.getServicesClassNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileTypeDetector> createFileTypeDetectors() {
|
||||
return provider.createFileTypeDetectors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInternalResourceIds() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalResource createInternalResource(String resourceId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider adapter for {@link TruffleLanguageProvider}. When the {@link LegacyProvider} is
|
||||
* removed, this class should also be removed.
|
||||
*/
|
||||
private static final class ModuleAwareProvider implements ProviderAdapter {
|
||||
|
||||
private final TruffleLanguageProvider provider;
|
||||
|
||||
ModuleAwareProvider(TruffleLanguageProvider provider) {
|
||||
Objects.requireNonNull(provider, "Provider must be non null");
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getProviderClass() {
|
||||
return provider.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TruffleLanguage<?> create() {
|
||||
return (TruffleLanguage<?>) EngineAccessor.LANGUAGE_PROVIDER.create(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageClassName() {
|
||||
return EngineAccessor.LANGUAGE_PROVIDER.getLanguageClassName(provider);
|
||||
}
|
||||
|
||||
public Collection<String> getServicesClassNames() {
|
||||
return EngineAccessor.LANGUAGE_PROVIDER.getServicesClassNames(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileTypeDetector> createFileTypeDetectors() {
|
||||
return EngineAccessor.LANGUAGE_PROVIDER.createFileTypeDetectors(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInternalResourceIds() {
|
||||
return EngineAccessor.LANGUAGE_PROVIDER.getInternalResourceIds(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalResource createInternalResource(String resourceId) {
|
||||
return EngineAccessor.LANGUAGE_PROVIDER.createInternalResource(provider, resourceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -297,7 +297,6 @@ final class ObjectSizeCalculator {
|
|||
}
|
||||
if (obj instanceof PolyglotContextConfig ||
|
||||
obj instanceof TruffleLanguageProvider ||
|
||||
obj instanceof TruffleLanguage.Provider ||
|
||||
obj instanceof ExecutionEventListener ||
|
||||
obj instanceof ClassValue ||
|
||||
obj instanceof PolyglotWrapper ||
|
||||
|
|
|
@ -8,7 +8,6 @@ innr protected abstract interface static ContextLocalFactory
|
|||
innr protected abstract interface static ContextThreadLocalFactory
|
||||
innr protected final static ContextLocalProvider
|
||||
innr public abstract interface static !annotation Registration
|
||||
innr public abstract interface static Provider
|
||||
innr public abstract static ContextReference
|
||||
innr public abstract static LanguageReference
|
||||
innr public final static !enum ContextPolicy
|
||||
|
|
Loading…
Reference in New Issue