diff options
| author | gary <gary@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-07 14:48:59 +0000 |
|---|---|---|
| committer | gary <gary@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-07 14:48:59 +0000 |
| commit | fe09dab129415da5abf880c63478f725a3735fec (patch) | |
| tree | 6cf536258c857420080043168abdc63d0bbff7e1 /libjava/java/lang | |
| parent | 05a849e5563535b30fbbd0bb50fa47eed2e016a6 (diff) | |
| download | ppe42-gcc-fe09dab129415da5abf880c63478f725a3735fec.tar.gz ppe42-gcc-fe09dab129415da5abf880c63478f725a3735fec.zip | |
2006-08-07 Gary Benson <gbenson@redhat.com>
PR libgcj/28340:
* java/lang/ClassLoader.java (clinit): Install a default
security manager if java.security.manager is defined.
(getParent, getSystemClassLoader): Use the correct stack
frame during security checks.
* java/net/URLClassLoader.java (findClass): Avoid calling
this.toString() during VM initialization.
(runtimeInitialized): New method.
* java/net/natURLClassLoader.cc: New file.
* Makefile.am (nat_source_files): Added the above.
* Makefile.in: Rebuilt.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115999 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang')
| -rw-r--r-- | libjava/java/lang/ClassLoader.java | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java index 13d8ca65e47..bcbfc298bd4 100644 --- a/libjava/java/lang/ClassLoader.java +++ b/libjava/java/lang/ClassLoader.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.lang; +import gnu.classpath.SystemProperties; import gnu.java.util.DoubleEnumeration; import gnu.java.util.EmptyEnumeration; @@ -156,6 +157,39 @@ public abstract class ClassLoader static final ClassLoader systemClassLoader = VMClassLoader.getSystemClassLoader(); + static + { + // Find out if we have to install a default security manager. Note + // that this is done here because we potentially need the system + // class loader to load the security manager and note also that we + // don't need the security manager until the system class loader + // is created. If the runtime chooses to use a class loader that + // doesn't have the system class loader as its parent, it is + // responsible for setting up a security manager before doing so. + String secman = SystemProperties.getProperty("java.security.manager"); + if (secman != null && SecurityManager.current == null) + { + if (secman.equals("") || secman.equals("default")) + { + SecurityManager.current = new SecurityManager(); + } + else + { + try + { + Class cl = Class.forName(secman, false, systemClassLoader); + SecurityManager.current = (SecurityManager) cl.newInstance(); + } + catch (Exception x) + { + throw (InternalError) + new InternalError("Unable to create SecurityManager") + .initCause(x); + } + } + } + } + /** * The default protection domain, used when defining a class with a null * paramter for the domain. @@ -496,7 +530,7 @@ public abstract class ClassLoader SecurityManager sm = System.getSecurityManager(); if (sm != null) { - Class c = VMSecurityManager.getClassContext(ClassLoader.class)[1]; + Class c = VMSecurityManager.getClassContext(ClassLoader.class)[0]; ClassLoader cl = c.getClassLoader(); if (cl != null && ! cl.isAncestorOf(this)) sm.checkPermission(new RuntimePermission("getClassLoader")); @@ -739,7 +773,7 @@ public abstract class ClassLoader SecurityManager sm = System.getSecurityManager(); if (sm != null) { - Class c = VMSecurityManager.getClassContext(ClassLoader.class)[1]; + Class c = VMSecurityManager.getClassContext(ClassLoader.class)[0]; ClassLoader cl = c.getClassLoader(); if (cl != null && cl != systemClassLoader) sm.checkPermission(new RuntimePermission("getClassLoader")); |

