01: /*
02: *
03: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
04: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License version
08: * 2 only, as published by the Free Software Foundation.
09: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * General Public License version 2 for more details (a copy is
14: * included at /legal/license.txt).
15: *
16: * You should have received a copy of the GNU General Public License
17: * version 2 along with this work; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
22: * Clara, CA 95054 or visit www.sun.com if you need additional
23: * information or have any questions.
24: */
25:
26: /*
27: * @(#)AuxPreloadClassLoader.java 1.5 06/10/10
28: *
29: * Class loader for MIDP implementation running on CDC/PP
30: */
31: package sun.misc;
32:
33: import java.net.URL;
34: import java.net.URLConnection;
35: import java.net.URLClassLoader;
36: import java.io.IOException;
37: import java.io.InputStream;
38: import java.util.HashSet;
39: import java.security.CodeSource;
40: import java.security.PermissionCollection;
41: import java.security.SecureClassLoader;
42: import java.security.ProtectionDomain;
43: import java.security.AccessController;
44: import java.security.AccessControlContext;
45: import java.security.PrivilegedExceptionAction;
46: import java.security.cert.Certificate;
47:
48: public class AuxPreloadClassLoader extends SecureClassLoader {
49:
50: private PermissionCollection perms;
51: private ClassLoader parent;
52:
53: public AuxPreloadClassLoader(PermissionCollection pc,
54: ClassLoader parent) {
55: super (parent);
56: perms = pc;
57: this .parent = parent;
58: }
59:
60: protected PermissionCollection getPermissions(CodeSource cs) {
61: return perms; // is this right?
62: }
63:
64: public synchronized Class loadClass(String classname,
65: boolean resolve) throws ClassNotFoundException {
66: Class resultClass;
67: resultClass = findLoadedClass(classname);
68: if (resultClass == null) {
69: String slashname;
70: slashname = classname.replace('.', '/');
71: try {
72: resultClass = lookupClass(slashname); // from ROM image
73: } catch (Exception e) {
74: /*DEBUG e.printStackTrace(); */
75: resultClass = null;
76: }
77: /* DEBUG if (resultClass!=null) System.out.println("AuxClassLoader found "+classname); */
78: }
79: /*
80: * WE DON'T DELIGATE. WE LEAVE THAT UP TO OUR CHILD.
81: * WE JUST FAIL.
82: */
83: if (resultClass == null)
84: throw new ClassNotFoundException(classname);
85: if (resolve)
86: resolveClass(resultClass);
87: return resultClass;
88: }
89:
90: private native Class lookupClass(String classname);
91:
92: }
|