Made AssemblyClassLoader public and moved it to ikvm.runtime package.

This commit is contained in:
jfrijters 2007-10-25 12:56:18 +00:00
Родитель 79a5702779
Коммит 96094d6cee
9 изменённых файлов: 75 добавлений и 72 удалений

Просмотреть файл

@ -21,7 +21,8 @@
jeroen@frijters.net
*/
package ikvm.internal;
// HACK because of historical reasons this class' source lives in ikvm/internal instead of ikvm/runtime
package ikvm.runtime;
import cli.System.Reflection.Assembly;
import gnu.java.util.EmptyEnumeration;
@ -34,7 +35,6 @@ import java.util.Vector;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@Internal
public final class AssemblyClassLoader extends ClassLoader
{
// NOTE assembly is null for "generics" class loader instances
@ -84,6 +84,7 @@ public final class AssemblyClassLoader extends ClassLoader
return getResources(this, assembly, name);
}
@Internal
public static URL makeIkvmresURL(Assembly asm, String name)
{
String assemblyName = asm.get_FullName();
@ -101,6 +102,7 @@ public final class AssemblyClassLoader extends ClassLoader
}
}
@Internal
public static URL getResource(ClassLoader classLoader, Assembly assembly, String name)
{
if(assembly != null)
@ -161,8 +163,10 @@ public final class AssemblyClassLoader extends ClassLoader
private static native String GetGenericClassLoaderName(Object classLoader);
private static native Assembly GetAssemblyFromClassLoader(ClassLoader classLoader);
// also used by VMClassLoader
@Internal
public static native String[] GetPackages(Assembly assembly);
@Internal
public static Enumeration getResources(ClassLoader classLoader, Assembly assembly, String name) throws IOException
{
Assembly[] assemblies = FindResourceAssemblies(assembly, name, false);

Просмотреть файл

@ -25,7 +25,6 @@ package ikvm.runtime;
import cli.System.AppDomain;
import cli.System.Reflection.Assembly;
import ikvm.internal.AssemblyClassLoader;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;

Просмотреть файл

@ -24,7 +24,6 @@
package ikvm.runtime;
import cli.System.Reflection.Assembly;
import ikvm.internal.AssemblyClassLoader;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;

Просмотреть файл

@ -32,9 +32,9 @@ import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import ikvm.internal.AnnotationAttributeBase;
import ikvm.internal.AssemblyClassLoader;
import ikvm.lang.CIL;
import ikvm.lang.Internal;
import ikvm.runtime.AssemblyClassLoader;
@Internal
public class LibraryVMInterfaceImpl implements ikvm.internal.LibraryVMInterface

Просмотреть файл

@ -142,7 +142,7 @@ final class VMClassLoader
*/
static URL getResource(String name)
{
return ikvm.internal.AssemblyClassLoader.getResource(null, getBootstrapAssembly(), name);
return ikvm.runtime.AssemblyClassLoader.getResource(null, getBootstrapAssembly(), name);
}
/**
@ -154,7 +154,7 @@ final class VMClassLoader
*/
static Enumeration getResources(String name) throws IOException
{
return ikvm.internal.AssemblyClassLoader.getResources(null, getBootstrapAssembly(), name);
return ikvm.runtime.AssemblyClassLoader.getResources(null, getBootstrapAssembly(), name);
}
/**
@ -192,7 +192,7 @@ final class VMClassLoader
if(packages == null)
{
Hashtable h = new Hashtable();
String[] pkgs = ikvm.internal.AssemblyClassLoader.GetPackages(null);
String[] pkgs = ikvm.runtime.AssemblyClassLoader.GetPackages(null);
URL sealBase = null;
try
{

Просмотреть файл

@ -220,7 +220,7 @@ final class VMAccessController
// HACK to prevent bootstrap issues (on OpenJDK), we skip all statically compiled classes.
// They all have an AllPermission protection domain, so security wise it doesn't matter.
ClassLoader loader = clazz.getClassLoader();
if (loader == null || loader instanceof ikvm.internal.AssemblyClassLoader)
if (loader == null || loader instanceof ikvm.runtime.AssemblyClassLoader)
continue;
ProtectionDomain domain = clazz.getProtectionDomain();

Просмотреть файл

@ -25,6 +25,7 @@
package java.lang;
import gnu.classpath.VMSystemProperties;
import ikvm.runtime.AssemblyClassLoader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@ -43,7 +44,7 @@ class LangHelper
if (!addedSystemPackages)
{
addedSystemPackages = true;
String[] pkgs = ikvm.internal.AssemblyClassLoader.GetPackages(getBootstrapAssembly());
String[] pkgs = AssemblyClassLoader.GetPackages(getBootstrapAssembly());
String openJdkVersion = AccessController.doPrivileged(new GetPropertyAction("openjdk.version", "unknown"));
for (int i = 0; i < pkgs.length; i++)
{
@ -89,12 +90,12 @@ class LangHelper
static URL getBootstrapResource(String name)
{
return ikvm.internal.AssemblyClassLoader.getResource(null, getBootstrapAssembly(), name);
return AssemblyClassLoader.getResource(null, getBootstrapAssembly(), name);
}
static Enumeration getBootstrapResources(String name) throws IOException
{
return ikvm.internal.AssemblyClassLoader.getResources(null, getBootstrapAssembly(), name);
return AssemblyClassLoader.getResources(null, getBootstrapAssembly(), name);
}
// this method is called from the System.<clinit> method in map.xml

Просмотреть файл

@ -32,9 +32,9 @@ import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import ikvm.internal.AnnotationAttributeBase;
import ikvm.internal.AssemblyClassLoader;
import ikvm.lang.CIL;
import ikvm.lang.Internal;
import ikvm.runtime.AssemblyClassLoader;
@Internal
public class LibraryVMInterfaceImpl implements ikvm.internal.LibraryVMInterface

Просмотреть файл

@ -361,6 +361,65 @@ namespace IKVM.NativeCode.gnu.classpath
}
namespace IKVM.NativeCode.ikvm.@internal
{
namespace stubgen
{
public class StubGenerator
{
public static string getAssemblyName(object c)
{
ClassLoaderWrapper loader = TypeWrapper.FromClass(c).GetClassLoader();
IKVM.Internal.AssemblyClassLoader acl = loader as IKVM.Internal.AssemblyClassLoader;
if(acl != null)
{
return acl.Assembly.FullName;
}
else
{
return ((IKVM.Internal.GenericClassLoader)loader).GetName();
}
}
public static object getFieldConstantValue(object field)
{
return FieldWrapper.FromField(field).GetConstant();
}
public static bool isFieldDeprecated(object field)
{
FieldWrapper fieldWrapper = FieldWrapper.FromField(field);
FieldInfo fi = fieldWrapper.GetField();
if(fi != null)
{
return AttributeHelper.IsDefined(fi, typeof(ObsoleteAttribute));
}
GetterFieldWrapper getter = fieldWrapper as GetterFieldWrapper;
if(getter != null)
{
return AttributeHelper.IsDefined(getter.GetProperty(), typeof(ObsoleteAttribute));
}
return false;
}
public static bool isMethodDeprecated(object method)
{
MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(method);
MethodBase mb = mw.GetMethod();
return mb != null && AttributeHelper.IsDefined(mb, typeof(ObsoleteAttribute));
}
public static bool isClassDeprecated(object clazz)
{
Type type = TypeWrapper.FromClass(clazz).TypeAsTBD;
// we need to check type for null, because ReflectionOnly
// generated delegate inner interfaces don't really exist
return type != null && AttributeHelper.IsDefined(type, typeof(ObsoleteAttribute));
}
}
}
}
namespace IKVM.NativeCode.ikvm.runtime
{
public class AssemblyClassLoader
{
@ -473,65 +532,6 @@ namespace IKVM.NativeCode.ikvm.@internal
}
}
namespace stubgen
{
public class StubGenerator
{
public static string getAssemblyName(object c)
{
ClassLoaderWrapper loader = TypeWrapper.FromClass(c).GetClassLoader();
IKVM.Internal.AssemblyClassLoader acl = loader as IKVM.Internal.AssemblyClassLoader;
if(acl != null)
{
return acl.Assembly.FullName;
}
else
{
return ((IKVM.Internal.GenericClassLoader)loader).GetName();
}
}
public static object getFieldConstantValue(object field)
{
return FieldWrapper.FromField(field).GetConstant();
}
public static bool isFieldDeprecated(object field)
{
FieldWrapper fieldWrapper = FieldWrapper.FromField(field);
FieldInfo fi = fieldWrapper.GetField();
if(fi != null)
{
return AttributeHelper.IsDefined(fi, typeof(ObsoleteAttribute));
}
GetterFieldWrapper getter = fieldWrapper as GetterFieldWrapper;
if(getter != null)
{
return AttributeHelper.IsDefined(getter.GetProperty(), typeof(ObsoleteAttribute));
}
return false;
}
public static bool isMethodDeprecated(object method)
{
MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(method);
MethodBase mb = mw.GetMethod();
return mb != null && AttributeHelper.IsDefined(mb, typeof(ObsoleteAttribute));
}
public static bool isClassDeprecated(object clazz)
{
Type type = TypeWrapper.FromClass(clazz).TypeAsTBD;
// we need to check type for null, because ReflectionOnly
// generated delegate inner interfaces don't really exist
return type != null && AttributeHelper.IsDefined(type, typeof(ObsoleteAttribute));
}
}
}
}
namespace IKVM.NativeCode.ikvm.runtime
{
public class AppDomainAssemblyClassLoader
{
public static object loadClassFromAssembly(Assembly asm, string className)