11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.internal.loader;
27
28 import java.io.IOException;
29 import java.net.URL;
30 import java.nio.file.InvalidPathException;
31 import java.nio.file.Paths;
32 import java.security.CodeSource;
33 import java.security.PermissionCollection;
34 import java.util.jar.Manifest;
35
36 import jdk.internal.misc.JavaLangAccess;
37 import jdk.internal.misc.SharedSecrets;
38 import jdk.internal.misc.VM;
39
40 /**
41 * Creates and provides access to the built-in platform and application class
42 * loaders. It also creates the class loader that is used to locate resources
43 * in modules defined to the boot class loader.
44 */
45
46 public class ClassLoaders {
47
48 private ClassLoaders() { }
49
50 private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
51
206
207 /**
208 * Called by the VM to support define package for AppCDS
209 */
210 protected Package defineOrCheckPackage(String pn, Manifest man, URL url) {
211 return super.defineOrCheckPackage(pn, man, url);
212 }
213 }
214
215 /**
216 * Attempts to convert the given string to a file URL.
217 *
218 * @apiNote This is called by the VM
219 */
220 @Deprecated
221 private static URL toFileURL(String s) {
222 try {
223 // Use an intermediate File object to construct a URI/URL without
224 // authority component as URLClassPath can't handle URLs with a UNC
225 // server name in the authority component.
226 return Paths.get(s).toRealPath().toFile().toURI().toURL();
227 } catch (InvalidPathException | IOException ignore) {
228 // malformed path string or class path element does not exist
229 return null;
230 }
231 }
232 }
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.internal.loader;
27
28 import java.io.IOException;
29 import java.net.URL;
30 import java.nio.file.InvalidPathException;
31 import java.nio.file.Path;
32 import java.security.CodeSource;
33 import java.security.PermissionCollection;
34 import java.util.jar.Manifest;
35
36 import jdk.internal.misc.JavaLangAccess;
37 import jdk.internal.misc.SharedSecrets;
38 import jdk.internal.misc.VM;
39
40 /**
41 * Creates and provides access to the built-in platform and application class
42 * loaders. It also creates the class loader that is used to locate resources
43 * in modules defined to the boot class loader.
44 */
45
46 public class ClassLoaders {
47
48 private ClassLoaders() { }
49
50 private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
51
206
207 /**
208 * Called by the VM to support define package for AppCDS
209 */
210 protected Package defineOrCheckPackage(String pn, Manifest man, URL url) {
211 return super.defineOrCheckPackage(pn, man, url);
212 }
213 }
214
215 /**
216 * Attempts to convert the given string to a file URL.
217 *
218 * @apiNote This is called by the VM
219 */
220 @Deprecated
221 private static URL toFileURL(String s) {
222 try {
223 // Use an intermediate File object to construct a URI/URL without
224 // authority component as URLClassPath can't handle URLs with a UNC
225 // server name in the authority component.
226 return Path.get(s).toRealPath().toFile().toURI().toURL();
227 } catch (InvalidPathException | IOException ignore) {
228 // malformed path string or class path element does not exist
229 return null;
230 }
231 }
232 }
|