- Added java.io.Serializable and java.lang.Cloneable to the core classes.

- Replaced LoadClassCritical("ikvm.internal.CallerID") with a core class reference.
This commit is contained in:
jfrijters 2013-02-14 16:09:04 +00:00
Родитель 77423ae5b1
Коммит be07a80f6a
5 изменённых файлов: 27 добавлений и 9 удалений

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

@ -42,6 +42,17 @@ namespace IKVM.Internal
internal static class java
{
internal static class io
{
internal static class Serializable
{
// NOTE we have a dummy static initializer, to make sure we don't get the beforeFieldInit attribute
// (we don't want the classes to be loaded prematurely, because they might not be available then)
static Serializable() { }
internal static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.io.Serializable");
}
}
internal static class lang
{
internal static class Object
@ -68,6 +79,14 @@ namespace IKVM.Internal
internal static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Class");
}
internal static class Cloneable
{
// NOTE we have a dummy static initializer, to make sure we don't get the beforeFieldInit attribute
// (we don't want the classes to be loaded prematurely, because they might not be available then)
static Cloneable() {}
internal static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Cloneable");
}
internal static class Throwable
{
// NOTE we have a dummy static initializer, to make sure we don't get the beforeFieldInit attribute

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

@ -2006,7 +2006,7 @@ namespace IKVM.Internal
internal override void EmitCall(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Dup);
ilgen.Emit(OpCodes.Isinst, ClassLoaderWrapper.LoadClassCritical("java.lang.Cloneable").TypeAsBaseType);
ilgen.Emit(OpCodes.Isinst, CoreClasses.java.lang.Cloneable.Wrapper.TypeAsBaseType);
CodeEmitterLabel label1 = ilgen.DefineLabel();
ilgen.EmitBrtrue(label1);
CodeEmitterLabel label2 = ilgen.DefineLabel();

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

@ -412,7 +412,7 @@ namespace IKVM.Internal
{
get
{
return this.IsSubTypeOf(ClassLoaderWrapper.LoadClassCritical("java.io.Serializable"));
return this.IsSubTypeOf(CoreClasses.java.io.Serializable.Wrapper);
}
}
@ -4814,7 +4814,7 @@ namespace IKVM.Internal
// are public and so we can get away with replacing all other types with object.
argTypes[i + instance] = (args[i].IsPrimitive || args[i].IsGhost || args[i].IsNonPrimitiveValueType) ? args[i].TypeAsSignatureType : typeof(object);
}
argTypes[argTypes.Length - 1] = ClassLoaderWrapper.LoadClassCritical("ikvm.internal.CallerID").TypeAsSignatureType;
argTypes[argTypes.Length - 1] = CoreClasses.ikvm.@internal.CallerID.Wrapper.TypeAsSignatureType;
Type retType = (mw.ReturnType.IsPrimitive || mw.ReturnType.IsGhost || mw.ReturnType.IsNonPrimitiveValueType) ? mw.ReturnType.TypeAsSignatureType : typeof(object);
MethodBuilder mb = tb.DefineMethod("method", MethodAttributes.Public | MethodAttributes.Static, retType, argTypes);
AttributeHelper.HideFromJava(mb);

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

@ -43,7 +43,6 @@ namespace IKVM.Internal
private static readonly CustomAttributeBuilder securityCriticalAttribute = new CustomAttributeBuilder(JVM.Import(typeof(SecurityCriticalAttribute)).GetConstructor(Type.EmptyTypes), new object[0]);
private static readonly TypeWrapper iserializable = ClassLoaderWrapper.GetWrapperFromType(JVM.Import(typeof(ISerializable)));
private static readonly TypeWrapper iobjectreference = ClassLoaderWrapper.GetWrapperFromType(JVM.Import(typeof(IObjectReference)));
private static readonly TypeWrapper serializable = ClassLoaderWrapper.LoadClassCritical("java.io.Serializable");
private static readonly TypeWrapper externalizable = ClassLoaderWrapper.LoadClassCritical("java.io.Externalizable");
private static readonly PermissionSet psetSerializationFormatter;
@ -85,7 +84,7 @@ namespace IKVM.Internal
{
MarkSerializable(typeBuilder);
}
else if (wrapper.IsSubTypeOf(serializable) && IsSafeForAutomagicSerialization(wrapper))
else if (wrapper.IsSubTypeOf(CoreClasses.java.io.Serializable.Wrapper) && IsSafeForAutomagicSerialization(wrapper))
{
if (wrapper.IsSubTypeOf(externalizable))
{
@ -95,7 +94,7 @@ namespace IKVM.Internal
MarkSerializable(typeBuilder);
ctor.Link();
serializationCtor = AddConstructor(typeBuilder, ctor, null, true);
if (!wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
if (!wrapper.BaseTypeWrapper.IsSubTypeOf(CoreClasses.java.io.Serializable.Wrapper))
{
AddGetObjectData(typeBuilder);
}
@ -105,7 +104,7 @@ namespace IKVM.Internal
}
}
}
else if (wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
else if (wrapper.BaseTypeWrapper.IsSubTypeOf(CoreClasses.java.io.Serializable.Wrapper))
{
MethodBase baseCtor = wrapper.GetBaseSerializationConstructor();
if (baseCtor != null && (baseCtor.IsFamily || baseCtor.IsFamilyOrAssembly))

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

@ -4809,8 +4809,8 @@ namespace IKVM.Internal
if(interfaces == null)
{
TypeWrapper[] tw = new TypeWrapper[2];
tw[0] = ClassLoaderWrapper.LoadClassCritical("java.lang.Cloneable");
tw[1] = ClassLoaderWrapper.LoadClassCritical("java.io.Serializable");
tw[0] = CoreClasses.java.lang.Cloneable.Wrapper;
tw[1] = CoreClasses.java.io.Serializable.Wrapper;
interfaces = tw;
}
return interfaces;