Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ikvmc/FakeTypes.cs3
-rw-r--r--openjdk/java/lang/Enum.java35
-rw-r--r--openjdk/map.xml3
-rw-r--r--runtime/TypeWrapper.cs4
4 files changed, 43 insertions, 2 deletions
diff --git a/ikvmc/FakeTypes.cs b/ikvmc/FakeTypes.cs
index eb4f4364..6b441c8f 100644
--- a/ikvmc/FakeTypes.cs
+++ b/ikvmc/FakeTypes.cs
@@ -72,13 +72,12 @@ namespace IKVM.Internal
tb.DefineGenericParameters("T")[0].SetBaseTypeConstraint(typeof(MulticastDelegate));
genericDelegateInterfaceType = tb.CreateType();
- CreateEnumEnum(modb, loader);
-
TypeWrapper annotationTypeWrapper = loader.LoadClassByDottedName("java.lang.annotation.Annotation");
annotationTypeWrapper.Finish();
genericAttributeAnnotationType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationTypeName, annotationTypeWrapper);
genericAttributeAnnotationMultipleType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationMultipleTypeName, annotationTypeWrapper);
genericAttributeAnnotationReturnValueType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationReturnValueTypeName, annotationTypeWrapper);
+ CreateEnumEnum(modb, loader);
}
private static void CreateEnumEnum(ModuleBuilder modb, ClassLoaderWrapper loader)
diff --git a/openjdk/java/lang/Enum.java b/openjdk/java/lang/Enum.java
index 175b4021..e14a2884 100644
--- a/openjdk/java/lang/Enum.java
+++ b/openjdk/java/lang/Enum.java
@@ -30,6 +30,10 @@ import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectStreamException;
+import cli.System.Runtime.Serialization.IObjectReference;
+import cli.System.Runtime.Serialization.SerializationException;
+import cli.System.Runtime.Serialization.SerializationInfo;
+import cli.System.Runtime.Serialization.StreamingContext;
/**
* This is the common base class of all Java language enumeration types.
@@ -39,6 +43,7 @@ import java.io.ObjectStreamException;
* @see Class#getEnumConstants()
* @since 1.5
*/
+@cli.System.SerializableAttribute.Annotation
public abstract class Enum<E extends Enum<E>>
implements Comparable<E>, Serializable {
/**
@@ -231,4 +236,34 @@ public abstract class Enum<E extends Enum<E>>
private void readObjectNoData() throws ObjectStreamException {
throw new InvalidObjectException("can't deserialize enum");
}
+
+ // [IKVM] .NET serialization support starts here
+ // Note that we don't have a security demand, because the info is harmless.
+ @cli.IKVM.Attributes.HideFromJavaAttribute.Annotation
+ public final void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("enumType", getDeclaringClass());
+ info.AddValue("name", name);
+ info.SetType(ikvm.runtime.Util.getInstanceTypeFromClass(EnumSerializationProxy.class));
+ }
+}
+
+@cli.System.SerializableAttribute.Annotation
+final class EnumSerializationProxy implements IObjectReference
+{
+ private Class enumType;
+ private String name;
+
+ public Object GetRealObject(StreamingContext context)
+ {
+ try
+ {
+ return Enum.valueOf(enumType, name);
+ }
+ catch (IllegalArgumentException x)
+ {
+ ikvm.runtime.Util.throwException(new SerializationException("Enum value " + name + " not found in " + enumType, x));
+ return null;
+ }
+ }
}
diff --git a/openjdk/map.xml b/openjdk/map.xml
index 48b5df8a..e2882c6f 100644
--- a/openjdk/map.xml
+++ b/openjdk/map.xml
@@ -1364,6 +1364,9 @@
</body>
</method>
</class>
+ <class name="java.lang.Enum">
+ <implements class="cli.System.Runtime.Serialization.ISerializable" />
+ </class>
<class name="java.lang.Thread">
<field name="parkLock" sig="Ljava.lang.Object;" modifiers="" />
<field name="parkState" sig="I" modifiers="" />
diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs
index 76d1f719..355a3aaf 100644
--- a/runtime/TypeWrapper.cs
+++ b/runtime/TypeWrapper.cs
@@ -4584,6 +4584,10 @@ namespace IKVM.Internal
{
typeAttribs |= TypeAttributes.BeforeFieldInit;
}
+ if(f.IsEnum)
+ {
+ typeAttribs |= TypeAttributes.Serializable;
+ }
#if STATIC_COMPILER
bool cantNest = false;
bool setModifiers = false;