Commit b9f42bb0 by Tom Tromey Committed by Tom Tromey

Proxy.java (generate): Uncomment protection domain code.

	* java/lang/reflect/Proxy.java (generate): Uncomment protection
	domain code.
	* java/lang/natClassLoader.cc (defineClass): Added `loader'
	argument.
	(linkClass0): Now in VMClassLoader.
	(markClassErrorState0): Likewise.
	(getSystemClassLoaderInternal): New method.
	* java/lang/natClass.cc (initializeClass): Use
	VMClassLoader::resolveClass.
	* java/lang/ClassLoader.java: New version, from Classpath.
	* java/lang/Class.java (getProtectionDomain):
	protectionDomainPermission and unknownProtectionDomain now in
	VMClassLoader.
	* java/lang/Class.h: VMClassLoader now a friend class.
	* gnu/gcj/runtime/VMClassLoader.java (instance): Now
	package-private.
	* gcj/javaprims.h: Regenerated class list.
	* resolve.cc (_Jv_PrepareClass): Use VMClassLoader::resolveClass.
	* java/lang/VMClassLoader.java: New version from Classpath;
	modified for libgcj use.

From-SVN: r71765
parent d70f15d2
2003-09-25 Tom Tromey <tromey@redhat.com>
* java/lang/reflect/Proxy.java (generate): Uncomment protection
domain code.
* java/lang/natClassLoader.cc (defineClass): Added `loader'
argument.
(linkClass0): Now in VMClassLoader.
(markClassErrorState0): Likewise.
(getSystemClassLoaderInternal): New method.
* java/lang/natClass.cc (initializeClass): Use
VMClassLoader::resolveClass.
* java/lang/ClassLoader.java: New version, from Classpath.
* java/lang/Class.java (getProtectionDomain):
protectionDomainPermission and unknownProtectionDomain now in
VMClassLoader.
* java/lang/Class.h: VMClassLoader now a friend class.
* gnu/gcj/runtime/VMClassLoader.java (instance): Now
package-private.
* gcj/javaprims.h: Regenerated class list.
* resolve.cc (_Jv_PrepareClass): Use VMClassLoader::resolveClass.
* java/lang/VMClassLoader.java: New version from Classpath;
modified for libgcj use.
2003-09-25 Michael Koch <konqueror@gmx.de>
* java/nio/ByteBufferHelper.java:
......
// javaprims.h - Main external header file for libgcj. -*- c++ -*-
/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
This file is part of libgcj.
......@@ -373,6 +373,39 @@ extern "Java"
class Manifest;
}
namespace logging
{
class ConsoleHandler;
class ErrorManager;
class FileHandler;
class Filter;
class Formatter;
class Handler;
class Level;
class LogManager;
class LogRecord;
class Logger;
class LoggingPermission;
class MemoryHandler;
class SimpleFormatter;
class SocketHandler;
class StreamHandler;
class XMLFormatter;
}
namespace prefs
{
class AbstractPreferences;
class BackingStoreException;
class InvalidPreferencesFormatException;
class NodeChangeEvent;
class NodeChangeListener;
class PreferenceChangeEvent;
class PreferenceChangeListener;
class Preferences;
class PreferencesFactory;
}
namespace regex
{
class Matcher;
......
......@@ -90,7 +90,7 @@ public final class VMClassLoader extends java.net.URLClassLoader
private int lib_control;
// The only VMClassLoader that can exist.
public static VMClassLoader instance = new VMClassLoader();
static VMClassLoader instance = new VMClassLoader();
private static final int LIB_FULL = 0;
private static final int LIB_CACHE = 1;
......
......@@ -290,6 +290,7 @@ private:
// Friends classes and functions to implement the ClassLoader
friend class java::lang::ClassLoader;
friend class java::lang::VMClassLoader;
friend class java::io::ObjectOutputStream;
friend class java::io::ObjectInputStream;
......
......@@ -227,12 +227,12 @@ public final class Class implements Serializable
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(ClassLoader.protectionDomainPermission);
sm.checkPermission(VMClassLoader.protectionDomainPermission);
ProtectionDomain protectionDomain = getProtectionDomain0();
if (protectionDomain == null)
return ClassLoader.unknownProtectionDomain;
return VMClassLoader.unknownProtectionDomain;
else
return protectionDomain;
}
......
......@@ -48,6 +48,7 @@ details. */
#include <java/lang/System.h>
#include <java/lang/SecurityManager.h>
#include <java/lang/StringBuffer.h>
#include <java/lang/VMClassLoader.h>
#include <gnu/gcj/runtime/StackTrace.h>
#include <gcj/method.h>
#include <gnu/gcj/runtime/MethodRef.h>
......@@ -758,7 +759,7 @@ java::lang::Class::initializeClass (void)
{
// this can throw exceptions, so exit the monitor as a precaution.
_Jv_MonitorExit (this);
java::lang::ClassLoader::resolveClass0 (this);
java::lang::VMClassLoader::resolveClass (this);
_Jv_MonitorEnter (this);
}
else
......
// natClassLoader.cc - Implementation of java.lang.ClassLoader native methods.
/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
/* Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation
This file is part of libgcj.
......@@ -44,11 +44,12 @@ details. */
/////////// java.lang.ClassLoader native methods ////////////
java::lang::Class *
java::lang::ClassLoader::defineClass0 (jstring name,
jbyteArray data,
jint offset,
jint length,
java::security::ProtectionDomain *pd)
java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader,
jstring name,
jbyteArray data,
jint offset,
jint length,
java::security::ProtectionDomain *pd)
{
#ifdef INTERPRETER
jclass klass;
......@@ -62,8 +63,8 @@ java::lang::ClassLoader::defineClass0 (jstring name,
// Record the defining loader. For the system class loader, we
// record NULL.
if (this != java::lang::ClassLoader::getSystemClassLoader())
klass->loader = this;
if (loader != java::lang::ClassLoader::getSystemClassLoader())
klass->loader = loader;
if (name != 0)
{
......@@ -105,6 +106,36 @@ java::lang::ClassLoader::defineClass0 (jstring name,
#endif
}
// Finish linking a class. Only called from ClassLoader::resolveClass.
void
java::lang::VMClassLoader::linkClass0 (java::lang::Class *klass)
{
_Jv_WaitForState (klass, JV_STATE_LINKED);
}
void
java::lang::VMClassLoader::markClassErrorState0 (java::lang::Class *klass)
{
klass->state = JV_STATE_ERROR;
klass->notifyAll ();
}
java::lang::ClassLoader *
java::lang::VMClassLoader::getSystemClassLoaderInternal()
{
_Jv_InitClass (&gnu::gcj::runtime::VMClassLoader::class$);
return gnu::gcj::runtime::VMClassLoader::instance;
}
jclass
java::lang::VMClassLoader::getPrimitiveClass (jchar type)
{
char sig[2];
sig[0] = (char) type;
sig[1] = '\0';
return _Jv_FindClassFromSignature (sig, NULL);
}
void
_Jv_WaitForState (jclass klass, int state)
{
......@@ -141,39 +172,6 @@ _Jv_WaitForState (jclass klass, int state)
throw new java::lang::LinkageError;
}
// Finish linking a class. Only called from ClassLoader::resolveClass.
void
java::lang::ClassLoader::linkClass0 (java::lang::Class *klass)
{
_Jv_WaitForState (klass, JV_STATE_LINKED);
}
void
java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
{
klass->state = JV_STATE_ERROR;
klass->notifyAll ();
}
jclass
java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *cl,
jstring name,
jbyteArray data,
jint offset,
jint length)
{
return cl->defineClass (name, data, offset, length);
}
jclass
java::lang::VMClassLoader::getPrimitiveClass (jchar type)
{
char sig[2];
sig[0] = (char) type;
sig[1] = '\0';
return _Jv_FindClassFromSignature (sig, NULL);
}
typedef unsigned int uaddr __attribute__ ((mode (pointer)));
/** This function does class-preparation for compiled classes.
......@@ -281,7 +279,7 @@ _Jv_PrepareCompiledClass (jclass klass)
// The set of initiating class loaders are used to ensure
// safety of linking, and is maintained in the hash table
// "initiated_classes". A defining classloader is by definition also
// initiating, so we only store classes in this table, if they have more
// initiating, so we only store classes in this table if they have more
// than one class loader associated.
//
......
......@@ -1335,17 +1335,10 @@ public class Proxy implements Serializable
{
// XXX Do we require more native support here?
// XXX Security hole - it is possible for another thread to grab the
// VMClassLoader.defineClass Method object, and abuse it while we
// have temporarily made it accessible. Do we need to add some
// synchronization lock to prevent user reflection while we use it?
// XXX This is waiting on VM support for protection domains.
Class vmClassLoader = Class.forName("java.lang.VMClassLoader");
Class[] types = {ClassLoader.class, String.class,
byte[].class, int.class, int.class,
/* ProtectionDomain.class */ };
ProtectionDomain.class };
Method m = vmClassLoader.getDeclaredMethod("defineClass", types);
// Bypass the security check of setAccessible(true), since this
......@@ -1354,7 +1347,7 @@ public class Proxy implements Serializable
m.flag = true;
Object[] args = {loader, qualName, bytecode, new Integer(0),
new Integer(bytecode.length),
/* Object.class.getProtectionDomain() */ };
Object.class.getProtectionDomain() };
Class clazz = (Class) m.invoke(null, args);
m.flag = false;
......
......@@ -32,6 +32,7 @@ details. */
#include <java/lang/AbstractMethodError.h>
#include <java/lang/NoClassDefFoundError.h>
#include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/VMClassLoader.h>
#include <java/lang/reflect/Modifier.h>
using namespace gcj;
......@@ -435,7 +436,7 @@ _Jv_PrepareClass(jclass klass)
// resolved.
if (klass->superclass)
java::lang::ClassLoader::resolveClass0 (klass->superclass);
java::lang::VMClassLoader::resolveClass (klass->superclass);
_Jv_InterpClass *clz = (_Jv_InterpClass*)klass;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment