Package org.bukkit.plugin.java
Class PluginClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.bukkit.plugin.java.PluginClassLoader
- All Implemented Interfaces:
ConfiguredPluginClassLoader,Closeable,AutoCloseable
@Internal
public final class PluginClassLoader
extends URLClassLoader
implements ConfiguredPluginClassLoader
A ClassLoader for plugins, to allow shared classes across multiple plugins
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPluginClassLoader(@Nullable ClassLoader parent, @NotNull PluginDescriptionFile description, @NotNull File dataFolder, @NotNull File file, @Nullable ClassLoader libraryLoader, JarFile jarFile, DependencyContext dependencyContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected Class<?>Provides the configuration of the plugin that this plugin classloader provides type access to.getGroup()Get the plugin classloader group that is used by the underlying classloaderGets the plugin held by this class loader.getResource(String name) getResources(String name) voidinit(JavaPlugin plugin) Initializes both this configured plugin class loader and the java plugin passed to link to each other.voidinitialize(@NotNull JavaPlugin javaPlugin) Class<?>Attempts to load a class from this plugin class loader using the passed fully qualified name.protected Class<?>toString()Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
dependencyContext
-
-
Constructor Details
-
PluginClassLoader
@Internal public PluginClassLoader(@Nullable @Nullable ClassLoader parent, @NotNull @NotNull PluginDescriptionFile description, @NotNull @NotNull File dataFolder, @NotNull @NotNull File file, @Nullable @Nullable ClassLoader libraryLoader, JarFile jarFile, DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException
-
-
Method Details
-
getResource
- Overrides:
getResourcein classClassLoader
-
getResources
- Overrides:
getResourcesin classClassLoader- Throws:
IOException
-
loadClass
public Class<?> loadClass(@NotNull @NotNull String name, boolean resolve, boolean checkGlobal, boolean checkLibraries) throws ClassNotFoundException Description copied from interface:ConfiguredPluginClassLoaderAttempts to load a class from this plugin class loader using the passed fully qualified name. This lookup logic can be configured through the following parameters to define how wide or how narrow the class lookup should be.- Specified by:
loadClassin interfaceConfiguredPluginClassLoader- Parameters:
name- the fully qualified name of the class to loadresolve- whether the class should be resolved if needed or notcheckGlobal- whether this lookup should check transitive dependencies, including either the legacy spigot global class loader or the paperPluginClassLoaderGroupcheckLibraries- whether the defined libraries should be checked for the class or not- Returns:
- the class found at the fully qualified class name passed under the passed restrictions
- Throws:
ClassNotFoundException- if the class could not be found considering the passed restrictions- See Also:
-
getConfiguration
Description copied from interface:ConfiguredPluginClassLoaderProvides the configuration of the plugin that this plugin classloader provides type access to.- Specified by:
getConfigurationin interfaceConfiguredPluginClassLoader- Returns:
- the plugin meta instance, holding all meta information about the plugin instance.
-
init
Description copied from interface:ConfiguredPluginClassLoaderInitializes both this configured plugin class loader and the java plugin passed to link to each other. This logic is to be called exactly once when the initial setup between the class loader and the instantiatedJavaPluginis loaded.- Specified by:
initin interfaceConfiguredPluginClassLoader- Parameters:
plugin- theJavaPluginthat should be interlinked with this class loader.
-
getPlugin
Description copied from interface:ConfiguredPluginClassLoaderGets the plugin held by this class loader.- Specified by:
getPluginin interfaceConfiguredPluginClassLoader- Returns:
- the plugin or null if it doesn't exist yet
-
loadClass
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
findClass
- Overrides:
findClassin classURLClassLoader- Throws:
ClassNotFoundException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classURLClassLoader- Throws:
IOException
-
initialize
-
toString
-
getGroup
Description copied from interface:ConfiguredPluginClassLoaderGet the plugin classloader group that is used by the underlying classloader- Specified by:
getGroupin interfaceConfiguredPluginClassLoader- Returns:
- classloader
-