Imported GNU Classpath 0.19 + gcj-import-20051115.

* sources.am: Regenerated.
       * Makefile.in: Likewise.
       * scripts/makemake.tcl: Use glob -nocomplain.

From-SVN: r107049
This commit is contained in:
Mark Wielaard 2005-11-15 23:20:01 +00:00
parent 02e549bfaa
commit 8f523f3a10
1241 changed files with 97711 additions and 25284 deletions

View file

@ -39,6 +39,7 @@ exception statement from your version. */
package java.io;
import gnu.classpath.Configuration;
import gnu.classpath.VMStackWalker;
import java.lang.reflect.Constructor;
import java.security.AccessController;
@ -46,8 +47,13 @@ import java.security.PrivilegedAction;
final class VMObjectInputStream
{
private static Class oisClass = ObjectInputStream.class;
private static Class vmoisClass = VMObjectInputStream.class;
static
{
if (Configuration.INIT_LOAD_LIBRARY)
{
System.loadLibrary("javaio");
}
}
// PrivilegedAction needed for Class.getClassLoader()
private static PrivilegedAction loaderAction = new PrivilegedAction()

View file

@ -1,5 +1,5 @@
/* VMObjectStreamClass.java -- VM helper functions for ObjectStreamClass
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,10 +38,19 @@ exception statement from your version. */
package java.io;
import gnu.classpath.Configuration;
import java.lang.reflect.Field;
final class VMObjectStreamClass
{
static
{
if (Configuration.INIT_LOAD_LIBRARY)
{
System.loadLibrary("javaio");
}
}
/**
* Returns true if CLAZZ has a static class initializer
* (a.k.a. <clinit>).

View file

@ -40,6 +40,7 @@ exception statement from your version. */
package java.lang;
import gnu.classpath.SystemProperties;
import gnu.classpath.Configuration;
import java.io.File;
import java.io.IOException;
@ -63,6 +64,48 @@ import java.util.zip.ZipFile;
*/
final class VMClassLoader
{
/** packages loaded by the bootstrap class loader */
static final HashMap definedPackages = new HashMap();
/**
* Converts the array string of native package names to
* Packages. The packages are then put into the
* definedPackages hashMap
*/
static
{
String[] packages = getBootPackages();
if( packages != null)
{
String specName =
SystemProperties.getProperty("java.specification.name");
String vendor =
SystemProperties.getProperty("java.specification.vendor");
String version =
SystemProperties.getProperty("java.specification.version");
Package p;
for(int i = 0; i < packages.length; i++)
{
p = new Package(packages[i],
specName,
vendor,
version,
"GNU Classpath",
"GNU",
Configuration.CLASSPATH_VERSION,
null);
definedPackages.put(packages[i], p);
}
}
}
/**
* Helper to define a class using a string of bytes. This assumes that
* the security checks have already been performed, if necessary.
@ -119,6 +162,9 @@ final class VMClassLoader
return null;
}
/** jars from property java.boot.class.path */
static final HashMap bootjars = new HashMap();
/**
* Helper to get a list of resources from the bootstrap class loader.
*
@ -139,8 +185,9 @@ final class VMClassLoader
{
try
{
v.add(new URL("file://"
+ new File(file, name).getAbsolutePath()));
File f = new File(file, name);
if (!f.exists()) continue;
v.add(new URL("file://" + f.getAbsolutePath()));
}
catch (MalformedURLException e)
{
@ -150,30 +197,28 @@ final class VMClassLoader
else if (file.isFile())
{
ZipFile zip;
try
{
zip = new ZipFile(file);
}
catch (IOException e)
{
continue;
}
String zname = name.startsWith("/") ? name.substring(1) : name;
try
{
if (zip.getEntry(zname) == null)
synchronized(bootjars)
{
zip = (ZipFile) bootjars.get(file.getName());
}
if(zip == null)
{
try
{
zip = new ZipFile(file);
synchronized(bootjars)
{
bootjars.put(file.getName(), zip);
}
}
catch (IOException e)
{
continue;
}
finally
{
try
{
zip.close();
}
catch (IOException e)
{
}
}
}
}
String zname = name.startsWith("/") ? name.substring(1) : name;
if (zip.getEntry(zname) == null)
continue;
try
{
v.add(new URL("jar:file://"
@ -188,29 +233,41 @@ final class VMClassLoader
return v.elements();
}
/**
* Helper to get a package from the bootstrap class loader. The default
* implementation of returning null may be adequate, or you may decide
* that this needs some native help.
* Returns a String[] of native package names. The default
* implementation returns an empty array, or you may decide
* this needs native help.
*/
private static String[] getBootPackages()
{
return new String[0];
}
/**
* Helper to get a package from the bootstrap class loader.
*
* @param name the name to find
* @return the named package, if it exists
*/
static Package getPackage(String name)
{
return null;
return (Package)definedPackages.get(name);
}
/**
* Helper to get all packages from the bootstrap class loader. The default
* implementation of returning an empty array may be adequate, or you may
* decide that this needs some native help.
* Helper to get all packages from the bootstrap class loader.
*
* @return all named packages, if any exist
*/
static Package[] getPackages()
{
return new Package[0];
Package[] packages = new Package[definedPackages.size()];
definedPackages.values().toArray(packages);
return packages;
}
/**

View file

@ -376,15 +376,11 @@ final class VMThread
*/
static void sleep(long ms, int ns) throws InterruptedException
{
// Round up
ms += (ns != 0) ? 1 : 0;
// Note: JDK treats a zero length sleep is like Thread.yield(),
// without checking the interrupted status of the thread.
// It's unclear if this is a bug in the implementation or the spec.
// See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
if (ms == 0)
if (ms == 0 && ns == 0)
{
if (Thread.interrupted())
throw new InterruptedException();
@ -404,11 +400,12 @@ final class VMThread
{
while (true)
{
vt.wait(ms);
vt.wait(ms, ns);
now = System.currentTimeMillis();
if (now >= end)
break;
ms = end - now;
ns = 0;
}
}
}

View file

@ -76,7 +76,7 @@ final class VMAccessController
DEFAULT_CONTEXT = new AccessControlContext(domain);
}
private static final boolean DEBUG = false;
private static final boolean DEBUG = gnu.classpath.Configuration.DEBUG;
private static void debug(String msg)
{
System.err.print(">>> VMAccessController: ");
@ -108,6 +108,8 @@ final class VMAccessController
LinkedList stack = (LinkedList) contexts.get();
if (stack == null)
{
if (DEBUG)
debug("no stack... creating ");
stack = new LinkedList();
contexts.set(stack);
}
@ -134,6 +136,10 @@ final class VMAccessController
if (stack.isEmpty())
contexts.set(null);
}
else if (DEBUG)
{
debug("no stack during pop?????");
}
}
/**
@ -166,7 +172,7 @@ final class VMAccessController
String[] methods = (String[]) stack[1];
if (DEBUG)
debug(">>> got trace of length " + classes.length);
debug("got trace of length " + classes.length);
HashSet domains = new HashSet();
HashSet seenDomains = new HashSet();
@ -185,8 +191,9 @@ final class VMAccessController
if (DEBUG)
{
debug(">>> checking " + clazz + "." + method);
debug(">>> loader = " + clazz.getClassLoader());
debug("checking " + clazz + "." + method);
// subject to getClassLoader RuntimePermission
debug("loader = " + clazz.getClassLoader());
}
// If the previous frame was a call to doPrivileged, then this is
@ -198,14 +205,16 @@ final class VMAccessController
&& method.equals ("doPrivileged"))
{
// If there was a call to doPrivileged with a supplied context,
// return that context.
// return that context. If using JAAS doAs*, it should be
// a context with a SubjectDomainCombiner
LinkedList l = (LinkedList) contexts.get();
if (l != null)
context = (AccessControlContext) l.getFirst();
privileged = 1;
}
ProtectionDomain domain = clazz.getProtectionDomain();
// subject to getProtectionDomain RuntimePermission
ProtectionDomain domain = clazz.getProtectionDomain();
if (domain == null)
continue;
@ -225,14 +234,25 @@ final class VMAccessController
ProtectionDomain[] result = (ProtectionDomain[])
domains.toArray(new ProtectionDomain[domains.size()]);
// Intersect the derived protection domain with the context supplied
// to doPrivileged.
if (context != null)
context = new AccessControlContext(result, context,
IntersectingDomainCombiner.SINGLETON);
{
DomainCombiner dc = context.getDomainCombiner ();
// If the supplied context had no explicit DomainCombiner, use
// our private version, which computes the intersection of the
// context's domains with the derived set.
if (dc == null)
context = new AccessControlContext
(IntersectingDomainCombiner.SINGLETON.combine
(result, context.getProtectionDomains ()));
// Use the supplied DomainCombiner. This should be secure,
// because only trusted code may create an
// AccessControlContext with a custom DomainCombiner.
else
context = new AccessControlContext (result, context, dc);
}
// No context was supplied. Return the derived one.
else
context = new AccessControlContext(result);
context = new AccessControlContext (result);
inGetContext.set(Boolean.FALSE);
return context;