/** {@inheritDoc} */ @Override protected final Package definePackage(final String name, final String specTitle, final String specVersion, final String specVendor, final String implTitle, final String implVersion, final String implVendor, final URL sealBase) throws IllegalArgumentException { return super.definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); }
/** {@inheritDoc} */ @Override public final void clearAssertionStatus() { super.clearAssertionStatus(); }
/** * Atomically define or load the named class. If the class is already defined, the existing class is returned. * * @param className the class name to define or load * @param bytes the bytes to use to define the class * @param off the offset into the byte array at which the class bytes begin * @param len the number of bytes in the class * @return the class */ protected final Class<?> defineOrLoadClass(final String className, final byte[] bytes, int off, int len) { try { final Class<?> definedClass = defineClass(className, bytes, off, len); return definedClass; } catch (LinkageError e) { final Class<?> loadedClass = findLoadedClass(className); if (loadedClass != null) { return loadedClass; } throw e; } }
private Class<?> performLoadClassUnchecked(final String className, final boolean exportsOnly, final boolean resolve) throws ClassNotFoundException { if (className.charAt(0) == '[') { // Use Class.forName to load the array type final Class<?> array = Class.forName(className, false, this); if (resolve) { resolveClass(array); } return array; } return findClass(className, exportsOnly, resolve); }
/** * Finds the resource with the given name and exported status, returning the resource content as a stream. * * @param name the resource name * @param exportsOnly {@code true} to consider only exported resources or {@code false} to consider all resources * @return the resource stream, or {@code null} if the resource is not found */ protected InputStream findResourceAsStream(final String name, final boolean exportsOnly) { final URL url = findResource(name, exportsOnly); try { return url == null ? null : url.openStream(); } catch (IOException e) { return null; } }
/** * Perform a class load operation. If the class is in the package or a subpackage of a package in the system packages list, * the parent class loader is used to load the class. Otherwise, this method checks to see if the class loader * object is locked; if so, it unlocks it and submits the request to the class loader thread. Otherwise, it will * load the class itself by delegating to {@link #findClass(String, boolean, boolean)}. * * @param className the class name * @param exportsOnly {@code true} to consider only exported resources or {@code false} to consider all resources * @param resolve {@code true} to resolve the loaded class * @return the class returned by {@link #findClass(String, boolean, boolean)} * @throws ClassNotFoundException if {@link #findClass(String, boolean, boolean)} throws this exception */ private Class<?> performLoadClass(String className, boolean exportsOnly, final boolean resolve) throws ClassNotFoundException { if (className == null) { throw new IllegalArgumentException("name is null"); } for (String s : Module.systemPackages) { if (className.startsWith(s)) { return definingLoader != null ? definingLoader.loadClass(className) : findSystemClass(className); } } return performLoadClassChecked(className, exportsOnly, resolve); }
/** * Implementation of {@link ClassLoader#findClass(String)}. * * @param className the class name * @return the result of {@code findClass(className, false, false)} */ protected final Class<?> findClass(final String className) throws ClassNotFoundException { return findClass(className, false, false); }
/** * Perform the actual work to load a package which is visible to this class loader. By default, uses a simple * parent-first delegation strategy. * * @param name the package name * @return the package, or {@code null} if no such package is visible to this class loader */ protected Package getPackageByName(final String name) { final Package parentPackage = super.getPackage(name); return parentPackage == null ? findLoadedPackage(name) : parentPackage; }
/** * Returns an input stream for reading the specified resource. If the resource starts with {@code "java/"}, then * this method delegates to the parent class loader. Otherwise, this method delegates to {@link #findResourceAsStream(String, boolean)}. * * @param name the resource name * @return the resource stream, or {@code null} if the resource is not found */ public final InputStream getResourceAsStream(final String name) { for (String s : Module.systemPaths) { if (name.startsWith(s)) { return definingLoader != null ? definingLoader.getResourceAsStream(name) : ClassLoader.getSystemResourceAsStream(name); } } return findResourceAsStream(name, false); }
/** * Finds all available resources with the given name. * * @see #getResource(String) * * @param name the resource name * @return an enumeration over all the resource URLs; if no resources could be found, the enumeration will be empty * @throws IOException if an I/O error occurs */ public final Enumeration<URL> getResources(final String name) throws IOException { for (String s : Module.systemPaths) { if (name.startsWith(s)) { return definingLoader != null ? definingLoader.getResources(name) : ClassLoader.getSystemResources(name); } } return findResources(name, false); }
Class<?> findSystemClassInternal(String name) throws ClassNotFoundException { return findSystemClass(name); }
private Class<?> performLoadClassUnchecked(final String className, final boolean exportsOnly, final boolean resolve) throws ClassNotFoundException { if (className.charAt(0) == '[') { // Use Class.forName to load the array type final Class<?> array = Class.forName(className, false, this); if (resolve) { resolveClass(array); } return array; } return findClass(className, exportsOnly, resolve); }
/** * Finds the resource with the given name and exported status, returning the resource content as a stream. * * @param name the resource name * @param exportsOnly {@code true} to consider only exported resources or {@code false} to consider all resources * @return the resource stream, or {@code null} if the resource is not found */ protected InputStream findResourceAsStream(final String name, final boolean exportsOnly) { final URL url = findResource(name, exportsOnly); try { return url == null ? null : url.openStream(); } catch (IOException e) { return null; } }
/** * Implementation of {@link ClassLoader#findClass(String)}. * * @param className the class name * @return the result of {@code findClass(className, false, false)} */ protected final Class<?> findClass(final String className) throws ClassNotFoundException { return findClass(className, false, false); }
/** * Perform the actual work to load a package which is visible to this class loader. By default, uses a simple * parent-first delegation strategy. * * @param name the package name * @return the package, or {@code null} if no such package is visible to this class loader */ protected Package getPackageByName(final String name) { final Package parentPackage = super.getPackage(name); return parentPackage == null ? findLoadedPackage(name) : parentPackage; }
/** * Returns an input stream for reading the specified resource. This method delegates to {@link #findResourceAsStream(String, boolean)}. * * @param name the resource name * @return the resource stream, or {@code null} if the resource is not found */ public final InputStream getResourceAsStream(final String name) { for (String s : Module.systemPaths) { if (name.startsWith(s)) { return JDKSpecific.getSystemResourceAsStream(name); } } return findResourceAsStream(name, false); }
/** * Finds all available resources with the given name. * * @see #getResource(String) * * @param name the resource name * @return an enumeration over all the resource URLs; if no resources could be found, the enumeration will be empty * @throws IOException if an I/O error occurs */ public final Enumeration<URL> getResources(final String name) throws IOException { for (String s : Module.systemPaths) { if (name.startsWith(s)) { return JDKSpecific.getSystemResources(name); } } return findResources(name, false); }
/** {@inheritDoc} */ @Override protected final Package definePackage(final String name, final String specTitle, final String specVersion, final String specVendor, final String implTitle, final String implVersion, final String implVendor, final URL sealBase) throws IllegalArgumentException { return super.definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); }
/** * Atomically define or load the named class. If the class is already defined, the existing class is returned. * * @param className the class name to define or load * @param bytes the bytes to use to define the class * @param off the offset into the byte array at which the class bytes begin * @param len the number of bytes in the class * @return the class */ protected final Class<?> defineOrLoadClass(final String className, final byte[] bytes, int off, int len) { try { final Class<?> definedClass = defineClass(className, bytes, off, len); return definedClass; } catch (LinkageError e) { final Class<?> loadedClass = findLoadedClass(className); if (loadedClass != null) { return loadedClass; } throw e; } }
/** * Finds the resource with the given name. The name of a resource is a {@code '/'}-separated path name that * identifies the resource. If the resource name starts with {@code "java/"} then the parent class loader is used. * Otherwise, this method delegates to {@link #findResource(String, boolean)}. * * @param name the name of the resource * @return the resource URL, or {@code null} if no such resource exists or the invoker does not have adequate * permission to access it */ public final URL getResource(final String name) { for (String s : Module.systemPaths) { if (name.startsWith(s)) { // Whatever loads jboss-modules.jar should have it's classes accessible. // This could even be the bootclasspath, in which case CL is null, and we prefer the system CL return definingLoader != null ? definingLoader.getResource(name) : ClassLoader.getSystemResource(name); } } return findResource(name, false); }