PR libgcj/12016, PR libgcj/18405, PR libgcj/17738:
* java/lang/Package.java (getPackages): Use VMClassLoader when appropriate. (getPackage): Likewise. * prims.cc (_Jv_CreateJavaVM): Call _Jv_RegisterBootstrapPackages. * include/jvm.h (_Jv_RegisterBootstrapPackages): Declare. * java/lang/VMClassLoader.java (getPackage): Rewrote. (getPackages): Likewise. (definedPackages): New field. (definePackageForNative): New method. * java/lang/Class.h (_Jv_FindClassInCache): Updated. * java/lang/natVMClassLoader.cc (loadClass): Updated. * defineclass.cc (handleClassBegin): Use ClassLoader.findLoadedClass. * java/lang/natClassLoader.cc (_Jv_RegisterInitiatingLoader): Rewrote. (struct _Jv_LoaderInfo): Removed. (initiated_classes): Likewise. (_Jv_UnregisterClass): Don't use initiated_classes. (_Jv_FindClassInCache): Likewise. Removed 'loader' argument. (_Jv_FindClass): Register classes found during boostrap. (BOOTSTRAP_CLASS_LIST_SIZE): New define. (bootstrap_class_list): New global. (bootstrap_index): Likewise. (_Jv_RegisterBootstrapPackages): New function. * gnu/gcj/runtime/natVMClassLoader.cc (findClass): Call definePackageForNative. (findClass): Updated. * gnu/gcj/runtime/VMClassLoader.java (definePackageForNative): New method. From-SVN: r93155
This commit is contained in:
parent
2f2bc52472
commit
3fd8010046
11 changed files with 159 additions and 106 deletions
|
@ -1,6 +1,6 @@
|
|||
/* VMClassLoader.java -- Reference implementation of native interface
|
||||
required by ClassLoader
|
||||
Copyright (C) 1998, 2001, 2002, 2003, 2004 Free Software Foundation
|
||||
Copyright (C) 1998, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -76,6 +76,8 @@ final class VMClassLoader
|
|||
unknownProtectionDomain = new ProtectionDomain(null, permissions);
|
||||
}
|
||||
|
||||
static final HashMap definedPackages = new HashMap();
|
||||
|
||||
/**
|
||||
* Helper to define a class using a string of bytes. This assumes that
|
||||
* the security checks have already been performed, if necessary.
|
||||
|
@ -173,9 +175,9 @@ final class VMClassLoader
|
|||
* @param name the name to find
|
||||
* @return the named package, if it exists
|
||||
*/
|
||||
static Package getPackage(String name)
|
||||
static synchronized Package getPackage(String name)
|
||||
{
|
||||
return null;
|
||||
return (Package) definedPackages.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,9 +187,33 @@ final class VMClassLoader
|
|||
*
|
||||
* @return all named packages, if any exist
|
||||
*/
|
||||
static Package[] getPackages()
|
||||
static synchronized Package[] getPackages()
|
||||
{
|
||||
return new Package[0];
|
||||
Package[] packages = new Package[definedPackages.size()];
|
||||
return (Package[]) definedPackages.values().toArray(packages);
|
||||
}
|
||||
|
||||
// Define a package for something loaded natively.
|
||||
static synchronized void definePackageForNative(String className)
|
||||
{
|
||||
int lastDot = className.lastIndexOf('.');
|
||||
if (lastDot != -1)
|
||||
{
|
||||
String packageName = className.substring(0, lastDot);
|
||||
if (getPackage(packageName) == null)
|
||||
{
|
||||
// FIXME: this assumes we're defining the core, which
|
||||
// isn't necessarily so. We could detect this and set up
|
||||
// appropriately. We could also look at a manifest file
|
||||
// compiled into the .so.
|
||||
Package p = new Package(packageName,
|
||||
"Java Platform API Specification",
|
||||
"GNU", "1.4", "gcj", "GNU",
|
||||
null, // FIXME: gcj version.
|
||||
null);
|
||||
definedPackages.put(packageName, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue