зеркало из https://github.com/mono/ikvm-fork.git
Moved readObject/writeObject to C# side.
This commit is contained in:
Родитель
1dc4ffa32b
Коммит
a4500fdb47
|
@ -276,14 +276,12 @@ public final class ExceptionHelper
|
|||
static native String getClassNameFromType(cli.System.Type type);
|
||||
static native int GetLineNumber(cli.System.Diagnostics.StackFrame frame);
|
||||
static native String GetFileName(cli.System.Diagnostics.StackFrame frame);
|
||||
static native void initThrowable(Object throwable, Object detailMessage, Object cause);
|
||||
static native Throwable MapExceptionImpl(Throwable t);
|
||||
static native cli.System.Type getTypeFromObject(Object o);
|
||||
|
||||
private static native String SafeGetEnvironmentVariable(String name);
|
||||
|
||||
// native methods implemented in map.xml
|
||||
private static native Throwable getCauseForSerialization(Throwable t);
|
||||
private static native cli.System.Exception getOriginalAndClear(Throwable t);
|
||||
private static native void setOriginal(Throwable t, cli.System.Exception org);
|
||||
private static native boolean needStackTraceInfo(Throwable t);
|
||||
|
@ -594,31 +592,6 @@ public final class ExceptionHelper
|
|||
return type.IsInstanceOfType(t);
|
||||
}
|
||||
|
||||
static void writeObject(Throwable t, ObjectOutputStream s) throws IOException
|
||||
{
|
||||
synchronized (t)
|
||||
{
|
||||
ObjectOutputStream.PutField fields = s.putFields();
|
||||
fields.put("detailMessage", t.getMessage());
|
||||
Throwable cause = t.getCause();
|
||||
if (cause == null && !(t instanceof cli.System.Exception))
|
||||
{
|
||||
cause = getCauseForSerialization(t);
|
||||
}
|
||||
fields.put("cause", cause);
|
||||
fields.put("stackTrace", t.getStackTrace());
|
||||
s.writeFields();
|
||||
}
|
||||
}
|
||||
|
||||
static void readObject(Throwable t, ObjectInputStream s) throws IOException, ClassNotFoundException
|
||||
{
|
||||
ObjectInputStream.GetField fields = s.readFields();
|
||||
initThrowable(t, fields.get("detailMessage", null), fields.get("cause", null));
|
||||
StackTraceElement[] stackTrace = (StackTraceElement[])fields.get("stackTrace", null);
|
||||
t.setStackTrace(stackTrace == null ? new StackTraceElement[0] : stackTrace);
|
||||
}
|
||||
|
||||
static Throwable MapTypeInitializeException(cli.System.TypeInitializationException t, cli.System.Type handler)
|
||||
{
|
||||
boolean wrapped = false;
|
||||
|
|
|
@ -997,7 +997,7 @@
|
|||
<body>
|
||||
<ldarg_0 />
|
||||
<ldarg_1 />
|
||||
<call class="java.lang.ExceptionHelper" name="readObject" sig="(Ljava.lang.Throwable;Ljava.io.ObjectInputStream;)V" />
|
||||
<call type="IKVM.NativeCode.java.lang.ExceptionHelper" name="readObject" sig="(Ljava.lang.Throwable;Ljava.io.ObjectInputStream;)V" />
|
||||
<ret />
|
||||
</body>
|
||||
</method>
|
||||
|
@ -1006,7 +1006,7 @@
|
|||
<body>
|
||||
<ldarg_0 />
|
||||
<ldarg_1 />
|
||||
<call class="java.lang.ExceptionHelper" name="writeObject" sig="(Ljava.lang.Throwable;Ljava.io.ObjectOutputStream;)V" />
|
||||
<call type="IKVM.NativeCode.java.lang.ExceptionHelper" name="writeObject" sig="(Ljava.lang.Throwable;Ljava.io.ObjectOutputStream;)V" />
|
||||
<ret />
|
||||
</body>
|
||||
</method>
|
||||
|
@ -2008,14 +2008,6 @@
|
|||
</implements>
|
||||
</class>
|
||||
<class name="java.lang.ExceptionHelper">
|
||||
<method name="getCauseForSerialization" sig="(Ljava.lang.Throwable;)Ljava.lang.Throwable;">
|
||||
<body>
|
||||
<ldarg_0 />
|
||||
<castclass_impl class="java.lang.Throwable" />
|
||||
<ldfld class="java.lang.Throwable" name="cause" sig="Ljava.lang.Throwable;" />
|
||||
<ret />
|
||||
</body>
|
||||
</method>
|
||||
<method name="getOriginalAndClear" sig="(Ljava.lang.Throwable;)Lcli.System.Exception;">
|
||||
<body>
|
||||
<ldarg_0 />
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace java
|
|||
namespace io
|
||||
{
|
||||
public class File { }
|
||||
public class ObjectInputStream { }
|
||||
public class ObjectOutputStream { }
|
||||
public class ObjectStreamField { }
|
||||
}
|
||||
|
||||
|
@ -35,6 +37,7 @@ namespace java
|
|||
public class Class { }
|
||||
public class ClassLoader { }
|
||||
public class SecurityManager { }
|
||||
public class StackTraceElement { }
|
||||
|
||||
namespace reflect
|
||||
{
|
||||
|
|
|
@ -26,6 +26,12 @@ using System.Reflection;
|
|||
using System.Diagnostics;
|
||||
using IKVM.Attributes;
|
||||
using IKVM.Internal;
|
||||
using ObjectInputStream = java.io.ObjectInputStream;
|
||||
using ObjectOutputStream = java.io.ObjectOutputStream;
|
||||
using StackTraceElement = java.lang.StackTraceElement;
|
||||
#if !FIRST_PASS
|
||||
using Throwable = java.lang.Throwable;
|
||||
#endif
|
||||
|
||||
namespace IKVM.NativeCode.java.lang
|
||||
{
|
||||
|
@ -110,7 +116,7 @@ namespace IKVM.NativeCode.java.lang
|
|||
return type.FullName;
|
||||
}
|
||||
|
||||
public static void initThrowable(object throwable, object detailMessage, object cause)
|
||||
private static void initThrowable(object throwable, object detailMessage, object cause)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
if(cause == throwable)
|
||||
|
@ -172,6 +178,35 @@ namespace IKVM.NativeCode.java.lang
|
|||
new global::java.io.ObjectStreamField("cause", typeof(global::java.lang.Throwable)),
|
||||
new global::java.io.ObjectStreamField("stackTrace", typeof(global::java.lang.StackTraceElement[]))
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void writeObject(Exception x, ObjectOutputStream s)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
lock (x)
|
||||
{
|
||||
ObjectOutputStream.PutField fields = s.putFields();
|
||||
fields.put("detailMessage", Throwable.instancehelper_getMessage(x));
|
||||
Exception cause = Throwable.instancehelper_getCause(x);
|
||||
if (cause == null && x is Throwable)
|
||||
{
|
||||
cause = ((Throwable)x).cause;
|
||||
}
|
||||
fields.put("cause", cause);
|
||||
fields.put("stackTrace", Throwable.instancehelper_getStackTrace(x));
|
||||
s.writeFields();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void readObject(Exception x, ObjectInputStream s)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
ObjectInputStream.GetField fields = s.readFields();
|
||||
initThrowable(x, fields.get("detailMessage", null), fields.get("cause", null));
|
||||
StackTraceElement[] stackTrace = (StackTraceElement[])fields.get("stackTrace", null);
|
||||
Throwable.instancehelper_setStackTrace(x, stackTrace == null ? new StackTraceElement[0] : stackTrace);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче