Class.h (Class::desiredAssertionStatus): Declare.
* 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. From-SVN: r54517
This commit is contained in:
parent
c6226a7e2a
commit
419831367f
10 changed files with 428 additions and 12 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue