Package com.sun.star.lib.unoloader
Class UnoClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
com.sun.star.lib.unoloader.UnoClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
The root UNO class loader.
This class loader is able to load all published URE classes, including the
classes representing the published URE UNO types. For consistency, it is
important that within each Java UNO environment there is one instance of this
class loader that is the defining class loader of all published URE classes
(and hence of all unpublished URE classes, too) and of all classes
representing UNO types (the published URE UNO types, any unpublished URE UNO
types, and any additional UNO types introduced by components; for the latter,
URLClassLoader.addURL(java.net.URL)
may be necessary).
This is an internal, unstable class of the Uno Runtime Environment; it should not be used by client code.
- Since:
- UDK 3.2.0
-
Constructor Summary
ConstructorDescriptionUnoClassLoader
(URL base, URL[] classPath, ClassLoader parent) Instantiates the root UNO class loader. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Executes a UNO JAR.getClassLoader
(URL jar, Attributes mainAttributes) Obtains a class loader for a UNO JAR.static Attributes
getJarMainAttributes
(URL jar) Obtains the main section of the manifest of a JAR.Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
Methods 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, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
UnoClassLoader
Instantiates the root UNO class loader.- Parameters:
base
- a base URL relative to which the URE JARs (java_uno.jar
andlibreoffice.jar
) can be found; must not benull
.classPath
- an array of URLs that form the class path of this class loader; may benull
, which is the same as an empty array. The URLs are interpreted in the same way as the arguments of aURLClassLoader
.parent
- the parent class loader for delegation.- Throws:
MalformedURLException
- if the givenbase
URL is malformed.
-
-
Method Details
-
getClassLoader
Obtains a class loader for a UNO JAR.- Parameters:
jar
- the URL of a UNO JAR; must not benull
.mainAttributes
- represents the main section of the manifest of the given JARjar
;null
if the given JAR does not have a manifest. (This redundant parameter is there for performance reasons, as typically the caller of this method already has this information available.)- Returns:
- an appropriate class loader; will never be
null
. - Throws:
MalformedURLException
- if the givenjar
URL or any of the UNO-Type-Path URLs specified in the given JAR are malformed.
-
execute
public void execute(URL jar, String[] arguments) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException Executes a UNO JAR.- Parameters:
jar
- the URL of a UNO JAR that specifies a Main-Class; must not benull
.arguments
- any arguments passed to themain
method of the specified Main-Class of the given JARjar
; must not benull
.- Throws:
IOException
- if there are any problems processing the given JARjar
.ClassNotFoundException
- if the given JARjar
does not specify a Main-Class, or if the specified Main-Class cannot be found.NoSuchMethodException
- if the specified Main-Class of the given JARjar
does not have an appropriatemain
method.InvocationTargetException
- if an exception occurs while executing themain
method of the specified Main-Class of the given JARjar
.
-
getJarMainAttributes
Obtains the main section of the manifest of a JAR.- Parameters:
jar
- the URL of a JAR; must not benull
.- Returns:
- the representation of the main section of the manifest of the
given JAR
jar
, ornull
if the given JAR does not have a manifest. - Throws:
IOException
- if there are any problems processing the given JARjar
.
-