src/share/classes/java/net/URLClassLoader.java
Print this page
rev 10449 : [mq]: cds
rev 10450 : mq
*** 1,7 ****
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 405,427 ****
}
}
return pkg;
}
! /*
! * Defines a Class using the class bytes obtained from the specified
! * Resource. The resulting Class must be resolved before it can be
! * used.
! */
! private Class<?> defineClass(String name, Resource res) throws IOException {
! long t0 = System.nanoTime();
! int i = name.lastIndexOf('.');
! URL url = res.getCodeSourceURL();
! if (i != -1) {
! String pkgname = name.substring(0, i);
! // Check if package already loaded.
! Manifest man = res.getManifest();
if (getAndVerifyPackage(pkgname, man, url) == null) {
try {
if (man != null) {
definePackage(pkgname, man, url);
} else {
--- 405,418 ----
}
}
return pkg;
}
! // Also called by VM to define Package for classes loaded from the CDS
! // archive
! private void definePackageInternal(String pkgname, Manifest man, URL url)
! {
if (getAndVerifyPackage(pkgname, man, url) == null) {
try {
if (man != null) {
definePackage(pkgname, man, url);
} else {
*** 436,445 ****
--- 427,456 ----
pkgname);
}
}
}
}
+
+ /*
+ * Defines a Class using the class bytes obtained from the specified
+ * Resource. The resulting Class must be resolved before it can be
+ * used.
+ *
+ * NOTE: the logic used here has been duplicated in the VM native code
+ * (search for invocation of definePackageInternal in the HotSpot sources).
+ * If this is changed, the VM code also need to be modified.
+ */
+ private Class<?> defineClass(String name, Resource res) throws IOException {
+ long t0 = System.nanoTime();
+ int i = name.lastIndexOf('.');
+ URL url = res.getCodeSourceURL();
+ if (i != -1) {
+ String pkgname = name.substring(0, i);
+ // Check if package already loaded.
+ Manifest man = res.getManifest();
+ definePackageInternal(pkgname, man, url);
+ }
// Now read the class bytes and define the class
java.nio.ByteBuffer bb = res.getByteBuffer();
if (bb != null) {
// Use (direct) ByteBuffer:
CodeSigner[] signers = res.getCodeSigners();