/** * Defines a package by name in this <tt>ConcurrentClassLoader</tt>. * * @param name the package name * @param specTitle the specification title * @param specVersion the specification version * @param specVendor the specification vendor * @param implTitle the implementation title * @param implVersion the implementation version * @param implVendor the implementation vendor * @param sealBase if not {@code null}, then this package is sealed with respect to the given code * source URL * @return the newly defined package, or the existing one if one was already defined */ protected 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 { ThreadLocal<Boolean> suppressor = GET_PACKAGE_SUPPRESSOR; suppressor.set(Boolean.TRUE); try { Package existing = packages.get(name); if (existing != null) { return existing; } Package pkg = super.definePackage( name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); existing = packages.putIfAbsent(name, pkg); return existing != null ? existing : pkg; } finally { suppressor.remove(); } }
/** * Load a package from this class loader only. * * @param name the package name * @return the package or {@code null} if no such package is defined by this class loader */ protected final Package findLoadedPackage(final String name) { return packages.get(name); }
/** * Get all defined packages which are visible to this class loader. * * @return the packages */ protected Package[] getPackages() { ArrayList<Package> list = new ArrayList<Package>(); list.addAll(packages.values()); list.addAll(Arrays.asList(super.getPackages())); return list.toArray(new Package[list.size()]); }