diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-06-11 17:33:22 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-06-11 17:33:22 +0000 |
commit | fcb37d05b6e1759e95ad62130956711c63cb2c3d (patch) | |
tree | ebbe68b8e8e326e400af4e79b545b2dd31fd6942 /libjava/java/lang/ClassLoader.java | |
parent | ec31870d5b51b9ac18ca48e8c8736136bd4c0cb0 (diff) | |
download | ppe42-gcc-fcb37d05b6e1759e95ad62130956711c63cb2c3d.tar.gz ppe42-gcc-fcb37d05b6e1759e95ad62130956711c63cb2c3d.zip |
* java/lang/Class.h (Class::desiredAssertionStatus): Declare.
(Class::getPackagePortion): Likewise.
* java/lang/Class.java (desiredAssertionStatus): New method from
Classpath.
(getPackagePortion): Likewise.
* java/lang/VMClassLoader.java (defaultAssertionStatus,
packageAssertionStatus, classAssertionStatus): New methods from
Classpath.
* java/lang/ClassLoader.java (defaultAssertionStatus,
systemPackageAssertionStatus, packageAssertionStatus,
systemClassAssertionStatus, classAssertionStatus): New fields from
Classpath.
(setDefaultAssertionStatus, setPackageAssertionStatus,
setClassAssertionStatus, clearAssertionStatus): New methods from
Classpath.
* Makefile.in: Rebuilt.
* Makefile.am (core_java_source_files): Added AssertionError.java.
* java/lang/AssertionError.java: New from Classpath.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang/ClassLoader.java')
-rw-r--r-- | libjava/java/lang/ClassLoader.java | 121 |
1 files changed, 117 insertions, 4 deletions
diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java index 32351d84040..7925fe73d87 100644 --- a/libjava/java/lang/ClassLoader.java +++ b/libjava/java/lang/ClassLoader.java @@ -1,6 +1,6 @@ // ClassLoader.java - Define policies for loading Java classes. -/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation +/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation This file is part of libgcj. @@ -20,9 +20,7 @@ import java.security.Permission; import java.security.Permissions; import java.security.Policy; import java.security.ProtectionDomain; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Stack; +import java.util.*; /** * The class <code>ClassLoader</code> is intended to be subclassed by @@ -34,6 +32,47 @@ import java.util.Stack; public abstract class ClassLoader { + /** + * The desired assertion status of classes loaded by this loader, if not + * overridden by package or class instructions. + */ + // Package visible for use by Class. + boolean defaultAssertionStatus = VMClassLoader.defaultAssertionStatus(); + + /** + * The command-line state of the package assertion status overrides. This + * map is never modified, so it does not need to be synchronized. + */ + // Package visible for use by Class. + static final Map systemPackageAssertionStatus + = VMClassLoader.packageAssertionStatus(); + + /** + * The map of package assertion status overrides, or null if no package + * overrides have been specified yet. The values of the map should be + * Boolean.TRUE or Boolean.FALSE, and the unnamed package is represented + * by the null key. This map must be synchronized on this instance. + */ + // Package visible for use by Class. + Map packageAssertionStatus; + + /** + * The command-line state of the class assertion status overrides. This + * map is never modified, so it does not need to be synchronized. + */ + // Package visible for use by Class. + static final Map systemClassAssertionStatus + = VMClassLoader.classAssertionStatus(); + + /** + * The map of class assertion status overrides, or null if no class + * overrides have been specified yet. The values of the map should be + * Boolean.TRUE or Boolean.FALSE. This map must be synchronized on this + * instance. + */ + // Package visible for use by Class. + Map classAssertionStatus; + private ClassLoader parent; private HashMap definedPackages = new HashMap(); @@ -577,4 +616,78 @@ public abstract class ClassLoader // Default to returning null. Derived classes implement this. return null; } + + /** + * Set the default assertion status for classes loaded by this classloader, + * used unless overridden by a package or class request. + * + * @param enabled true to set the default to enabled + * @see #setClassAssertionStatus(String, boolean) + * @see #setPackageAssertionStatus(String, boolean) + * @see #clearAssertionStatus() + * @since 1.4 + */ + public void setDefaultAssertionStatus(boolean enabled) + { + defaultAssertionStatus = enabled; + } + + /** + * Set the default assertion status for packages, used unless overridden + * by a class request. This default also covers subpackages, unless they + * are also specified. The unnamed package should use null for the name. + * + * @param name the package (and subpackages) to affect + * @param enabled true to set the default to enabled + * @see #setDefaultAssertionStatus(String, boolean) + * @see #setClassAssertionStatus(String, boolean) + * @see #clearAssertionStatus() + * @since 1.4 + */ + public synchronized void setPackageAssertionStatus(String name, + boolean enabled) + { + if (packageAssertionStatus == null) + packageAssertionStatus + = new HashMap(systemPackageAssertionStatus); + packageAssertionStatus.put(name, Boolean.valueOf(enabled)); + } + + /** + * Set the default assertion status for a class. This only affects the + * status of top-level classes, any other string is harmless. + * + * @param name the class to affect + * @param enabled true to set the default to enabled + * @throws NullPointerException if name is null + * @see #setDefaultAssertionStatus(String, boolean) + * @see #setPackageAssertionStatus(String, boolean) + * @see #clearAssertionStatus() + * @since 1.4 + */ + public synchronized void setClassAssertionStatus(String name, + boolean enabled) + { + if (classAssertionStatus == null) + classAssertionStatus = new HashMap(systemClassAssertionStatus); + // The toString() hack catches null, as required. + classAssertionStatus.put(name.toString(), Boolean.valueOf(enabled)); + } + + /** + * Resets the default assertion status of this classloader, its packages + * and classes, all to false. This allows overriding defaults inherited + * from the command line. + * + * @see #setDefaultAssertionStatus(boolean) + * @see #setClassAssertionStatus(String, boolean) + * @see #setPackageAssertionStatus(String, boolean) + * @since 1.4 + */ + public synchronized void clearAssertionStatus() + { + defaultAssertionStatus = false; + packageAssertionStatus = new HashMap(); + classAssertionStatus = new HashMap(); + } } |