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 SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionPluginClassLoader(@Nullable ClassLoader parent, @NotNull PluginDescriptionFile description, @NotNull File dataFolder, @NotNull File file, @Nullable ClassLoader libraryLoader, @Nullable JarFile jarFile, DependencyContext dependencyContext) 
- 
Method SummaryModifier 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.URLClassLoaderaddURL, definePackage, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoaderdefineClass, defineClassMethods inherited from class java.lang.ClassLoaderclearAssertionStatus, 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, @Nullable @Nullable JarFile jarFile, DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException 
 
- 
- 
Method Details- 
getResource- Overrides:
- getResourcein class- ClassLoader
 
- 
getResources- Overrides:
- getResourcesin class- ClassLoader
- Throws:
- IOException
 
- 
loadClasspublic 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 interface- ConfiguredPluginClassLoader
- Parameters:
- name- the fully qualified name of the class to load
- resolve- whether the class should be resolved if needed or not
- checkGlobal- whether this lookup should check transitive dependencies, including either the legacy spigot global class loader or the paper- PluginClassLoaderGroup
- checkLibraries- 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:
 
- 
getConfigurationDescription copied from interface:ConfiguredPluginClassLoaderProvides the configuration of the plugin that this plugin classloader provides type access to.- Specified by:
- getConfigurationin interface- ConfiguredPluginClassLoader
- Returns:
- the plugin meta instance, holding all meta information about the plugin instance.
 
- 
initDescription 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 interface- ConfiguredPluginClassLoader
- Parameters:
- plugin- the- JavaPluginthat should be interlinked with this class loader.
 
- 
getPluginDescription copied from interface:ConfiguredPluginClassLoaderGets the plugin held by this class loader.- Specified by:
- getPluginin interface- ConfiguredPluginClassLoader
- Returns:
- the plugin or null if it doesn't exist yet
 
- 
loadClass- Overrides:
- loadClassin class- ClassLoader
- Throws:
- ClassNotFoundException
 
- 
findClass- Overrides:
- findClassin class- URLClassLoader
- Throws:
- ClassNotFoundException
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- URLClassLoader
- Throws:
- IOException
 
- 
initialize
- 
toString
- 
getGroupDescription copied from interface:ConfiguredPluginClassLoaderGet the plugin classloader group that is used by the underlying classloader- Specified by:
- getGroupin interface- ConfiguredPluginClassLoader
- Returns:
- classloader
 
 
-