17 * accompanied this code).
18 *
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27 package com.sun.javatest.agent;
28
29 import java.io.ByteArrayInputStream;
30 import java.io.InputStream;
31
32 class AgentClassLoader extends ClassLoader {
33 AgentClassLoader(Agent.Task parent) {
34 this.parent = parent;
35 }
36
37 public synchronized Class loadClass(String className, boolean resolve) throws ClassNotFoundException {
38
39 // check the cache first
40 Class c = findLoadedClass(className);
41
42 // not found in the cache?
43 if (c == null) {
44 try {
45 ClassLoader cl = getClass().getClassLoader();
46 if (cl != null) {
47 // if this class has a class loader, defer to that,
48 // (and assume it will call findSystemClass if necessary)
49 c = cl.loadClass(className);
50 }
51 else {
52 // this class must be loaded via system class loader,
53 // so go use that one
54 c = findSystemClass(className);
55 }
56 }
57 catch (ClassNotFoundException e) {
58 AgentRemoteClassData data = parent.getClassData(className);
59 c = defineClass(className, data.getByteData(), 0, data.getByteData().length);
60 }
|
17 * accompanied this code).
18 *
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27 package com.sun.javatest.agent;
28
29 import java.io.ByteArrayInputStream;
30 import java.io.InputStream;
31
32 class AgentClassLoader extends ClassLoader {
33 AgentClassLoader(Agent.Task parent) {
34 this.parent = parent;
35 }
36
37 public synchronized Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException {
38
39 // check the cache first
40 Class<?> c = findLoadedClass(className);
41
42 // not found in the cache?
43 if (c == null) {
44 try {
45 ClassLoader cl = getClass().getClassLoader();
46 if (cl != null) {
47 // if this class has a class loader, defer to that,
48 // (and assume it will call findSystemClass if necessary)
49 c = cl.loadClass(className);
50 }
51 else {
52 // this class must be loaded via system class loader,
53 // so go use that one
54 c = findSystemClass(className);
55 }
56 }
57 catch (ClassNotFoundException e) {
58 AgentRemoteClassData data = parent.getClassData(className);
59 c = defineClass(className, data.getByteData(), 0, data.getByteData().length);
60 }
|