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/Compiler.cs6
-rw-r--r--native/jni.c4
-rw-r--r--native/jni.h4
-rw-r--r--runtime/JniInterface.cs45
-rw-r--r--runtime/MemberWrapper.cs51
-rw-r--r--runtime/verifier.cs9
6 files changed, 49 insertions, 70 deletions
diff --git a/ikvmc/Compiler.cs b/ikvmc/Compiler.cs
index 1d60aab8..83f98df0 100644
--- a/ikvmc/Compiler.cs
+++ b/ikvmc/Compiler.cs
@@ -464,7 +464,11 @@ class Compiler
{
foreach(ZipEntry ze in zf)
{
- if(ze.Name.ToLower().EndsWith(".class"))
+ if(ze.IsDirectory)
+ {
+ // skip
+ }
+ else if(ze.Name.ToLower().EndsWith(".class"))
{
classes.Add(ReadFromZip(zf, ze));
}
diff --git a/native/jni.c b/native/jni.c
index 64f93d7c..cfd362d3 100644
--- a/native/jni.c
+++ b/native/jni.c
@@ -195,12 +195,12 @@ static void* JNIEnv_vtable[] =
0, // jmethodID JNICALL FromReflectedMethod(jobject method);
0, // jfieldID JNICALL FromReflectedField(jobject field);
- 0, // jobject JNICALL ToReflectedMethod(jclass clazz, jmethodID methodID);
+ 0, // jobject JNICALL ToReflectedMethod(jclass clazz, jmethodID methodID, jboolean isStatic);
0, // jclass JNICALL GetSuperclass(jclass sub);
0, // jboolean JNICALL IsAssignableFrom(jclass sub, jclass sup);
- 0, // jobject JNICALL ToReflectedField(jclass clazz, jfieldID fieldID);
+ 0, // jobject JNICALL ToReflectedField(jclass clazz, jfieldID fieldID, jboolean isStatic);
0, // jint JNICALL Throw(jthrowable obj);
0, // jint JNICALL ThrowNew(jclass clazz, const char *msg);
diff --git a/native/jni.h b/native/jni.h
index 280ac1e8..f235288b 100644
--- a/native/jni.h
+++ b/native/jni.h
@@ -110,12 +110,12 @@ struct JNIEnv_methods
jmethodID (JNICALL *FromReflectedMethod)(JNIEnv* pEnv, jobject method);
jfieldID (JNICALL *FromReflectedField)(JNIEnv* pEnv, jobject field);
- jobject (JNICALL *ToReflectedMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID);
+ jobject (JNICALL *ToReflectedMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jboolean isStatic);
jclass (JNICALL *GetSuperclass)(JNIEnv* pEnv, jclass sub);
jboolean (JNICALL *IsAssignableFrom)(JNIEnv* pEnv, jclass sub, jclass sup);
- jobject (JNICALL *ToReflectedField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
+ jobject (JNICALL *ToReflectedField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jboolean isStatic);
jint (JNICALL *Throw)(JNIEnv* pEnv, jthrowable obj);
jint (JNICALL *ThrowNew)(JNIEnv* pEnv, jclass clazz, const char *msg);
diff --git a/runtime/JniInterface.cs b/runtime/JniInterface.cs
index fc0cd83a..1536bf48 100644
--- a/runtime/JniInterface.cs
+++ b/runtime/JniInterface.cs
@@ -231,11 +231,6 @@ namespace IKVM.Runtime
public static IntPtr GetFuncPtr(RuntimeMethodHandle method, string clazz, string name, string sig)
{
MethodBase mb = MethodBase.GetMethodFromHandle(method);
- // MONOBUG Mono 1.0 doesn't implement MethodBase.GetMethodFromHandle
- if(mb == null)
- {
- mb = new StackFrame(1).GetMethod();
- }
ClassLoaderWrapper loader = ClassLoaderWrapper.GetWrapperFromType(mb.DeclaringType).GetClassLoader();
int sp = 0;
for(int i = 1; sig[i] != ')'; i++)
@@ -542,6 +537,7 @@ namespace IKVM.Runtime
delegate int pf_int_int(JNIEnv* pEnv, int p1);
delegate IntPtr pf_IntPtr_IntPtr_long(JNIEnv* pEnv, IntPtr p1, long p2);
delegate long pf_long_IntPtr(JNIEnv* pEnv, IntPtr p1);
+ delegate IntPtr pf_IntPtr_IntPtr_IntPtr_sbyte(JNIEnv* pEnv, IntPtr p1, IntPtr p2, sbyte p3);
internal static void* vtable;
@@ -579,12 +575,12 @@ namespace IKVM.Runtime
new pf_IntPtr_IntPtr(JNIEnv.FromReflectedMethod), //virtual jmethodID JNICALL FromReflectedMethod(jobject method);
new pf_IntPtr_IntPtr(JNIEnv.FromReflectedField), //virtual jfieldID JNICALL FromReflectedField(jobject field);
- new pf_IntPtr_IntPtr_IntPtr(JNIEnv.ToReflectedMethod), //virtual jobject JNICALL ToReflectedMethod(jclass clazz, jmethodID methodID);
+ new pf_IntPtr_IntPtr_IntPtr_sbyte(JNIEnv.ToReflectedMethod), //virtual jobject JNICALL ToReflectedMethod(jclass clazz, jmethodID methodID, jboolean isStatic);
new pf_IntPtr_IntPtr(JNIEnv.GetSuperclass), //virtual jclass JNICALL GetSuperclass(jclass sub);
new pf_sbyte_IntPtr_IntPtr(JNIEnv.IsAssignableFrom), //virtual jboolean JNICALL IsAssignableFrom(jclass sub, jclass sup);
- new pf_IntPtr_IntPtr_IntPtr(JNIEnv.ToReflectedField), //virtual jobject JNICALL ToReflectedField(jclass clazz, jfieldID fieldID);
+ new pf_IntPtr_IntPtr_IntPtr_sbyte(JNIEnv.ToReflectedField), //virtual jobject JNICALL ToReflectedField(jclass clazz, jfieldID fieldID, jboolean isStatic);
new pf_int_IntPtr(JNIEnv.Throw), //virtual jint JNICALL Throw(jthrowable obj);
new pf_int_IntPtr_pbyte(JNIEnv.ThrowNew), //virtual jint JNICALL ThrowNew(jclass clazz, const char *msg);
@@ -1248,32 +1244,10 @@ namespace IKVM.Runtime
if(pEnv->currentMethod.Value != IntPtr.Zero)
{
MethodBase mb = MethodBase.GetMethodFromHandle(pEnv->currentMethod);
- if(mb != null)
- {
- ClassLoaderWrapper loader = ClassLoaderWrapper.GetWrapperFromType(mb.DeclaringType).GetClassLoader();
- if(loader.GetJavaClassLoader() != null)
- {
- return loader;
- }
- }
- else
+ ClassLoaderWrapper loader = ClassLoaderWrapper.GetWrapperFromType(mb.DeclaringType).GetClassLoader();
+ if(loader.GetJavaClassLoader() != null)
{
- // MONOBUG Mono 1.0 doesn't implement MethodBase.GetMethodFromHandle, so we do a stack walk
- // to try and find the caller
- StackTrace st = new StackTrace();
- for(int i = 0; i < st.FrameCount; i++)
- {
- StackFrame frame = st.GetFrame(i);
- Type type = frame.GetMethod().DeclaringType;
- if(type != null && frame.GetMethod().MethodHandle.Value == pEnv->currentMethod.Value)
- {
- ClassLoaderWrapper loader = ClassLoaderWrapper.GetWrapperFromType(type).GetClassLoader();
- if(loader.GetJavaClassLoader() != null)
- {
- return loader;
- }
- }
- }
+ return loader;
}
}
if(pEnv->classLoader.Target != null)
@@ -1330,7 +1304,7 @@ namespace IKVM.Runtime
return ((FieldWrapper)JVM.Library.getWrapperFromField(pEnv->UnwrapRef(field))).Cookie;
}
- internal static jobject ToReflectedMethod(JNIEnv* pEnv, jclass clazz_ignored, jmethodID method)
+ internal static jobject ToReflectedMethod(JNIEnv* pEnv, jclass clazz_ignored, jmethodID method, jboolean isStatic)
{
MethodWrapper mw = MethodWrapper.FromCookie(method);
object clazz = mw.DeclaringType.ClassObject;
@@ -1357,7 +1331,7 @@ namespace IKVM.Runtime
return w1.IsAssignableTo(w2) ? JNI_TRUE : JNI_FALSE;
}
- internal static jobject ToReflectedField(JNIEnv* pEnv, jclass clazz_ignored, jfieldID field)
+ internal static jobject ToReflectedField(JNIEnv* pEnv, jclass clazz_ignored, jfieldID field, jboolean isStatic)
{
FieldWrapper fw = FieldWrapper.FromCookie(field);
object clazz = fw.DeclaringType.ClassObject;
@@ -3206,8 +3180,7 @@ namespace IKVM.Runtime
{
for(int i = 0; i < GlobalRefs.weakRefs.Length; i++)
{
- // MONOBUG GCHandle.IsAllocated is horribly broken, so we also check the value of the handle
- if(!GlobalRefs.weakRefs[i].IsAllocated || (IntPtr)GlobalRefs.weakRefs[i] == IntPtr.Zero)
+ if(!GlobalRefs.weakRefs[i].IsAllocated)
{
GlobalRefs.weakRefs[i] = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection);
return (IntPtr)(- (i | (1 << 30)));
diff --git a/runtime/MemberWrapper.cs b/runtime/MemberWrapper.cs
index f9575d7d..e095999b 100644
--- a/runtime/MemberWrapper.cs
+++ b/runtime/MemberWrapper.cs
@@ -38,7 +38,8 @@ enum MemberFlags : short
None = 0,
HideFromReflection = 1,
ExplicitOverride = 2,
- LiteralField = 4
+ LiteralField = 4,
+ MirandaMethod = 8
}
class MemberWrapper
@@ -56,25 +57,33 @@ class MemberWrapper
this.flags = flags;
}
+ // NOTE since we don't support unloading code, there is no need to have a finalizer
+#if CLASS_GC
~MemberWrapper()
{
- // NOTE when we're being unloaded, we shouldn't clean up the handle, because JNI
- // code running in a finalize can use this handle later on (since finalization is
+ // NOTE when the AppDomain is being unloaded, we shouldn't clean up the handle, because
+ // JNI code running in a finalize can use this handle later on (since finalization is
// unordered). Note that this isn't a leak since the AppDomain is going away anyway.
if(!Environment.HasShutdownStarted && handle.IsAllocated)
{
- handle.Free();
+ FreeHandle();
}
}
+ private void FreeHandle()
+ {
+ // this has a LinkDemand, so it has to be in a separate method
+ handle.Free();
+ }
+#endif
+
internal IntPtr Cookie
{
get
{
lock(this)
{
- // MONOBUG GCHandle.IsAllocated is horribly broken, so we also check the value of the handle
- if(!handle.IsAllocated || (IntPtr)handle == IntPtr.Zero)
+ if(!handle.IsAllocated)
{
handle = System.Runtime.InteropServices.GCHandle.Alloc(this, System.Runtime.InteropServices.GCHandleType.Weak);
}
@@ -133,6 +142,14 @@ class MemberWrapper
}
}
+ internal bool IsMirandaMethod
+ {
+ get
+ {
+ return (flags & MemberFlags.MirandaMethod) != 0;
+ }
+ }
+
internal Modifiers Modifiers
{
get
@@ -246,7 +263,7 @@ abstract class MethodWrapper : MemberWrapper
}
}
- internal static MethodWrapper Create(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, bool hideFromReflection)
+ internal static MethodWrapper Create(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
{
Debug.Assert(declaringType != null && name!= null && sig != null && method != null);
@@ -262,15 +279,15 @@ abstract class MethodWrapper : MemberWrapper
}
method = declaringType.TypeAsBaseType.GetMethod(method.Name, types);
}
- return new GhostMethodWrapper(declaringType, name, sig, method, returnType, parameterTypes, modifiers, hideFromReflection ? MemberFlags.HideFromReflection : MemberFlags.None);
+ return new GhostMethodWrapper(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags);
}
else if(method is ConstructorInfo)
{
- return new SmartConstructorMethodWrapper(declaringType, name, sig, (ConstructorInfo)method, parameterTypes, modifiers, hideFromReflection);
+ return new SmartConstructorMethodWrapper(declaringType, name, sig, (ConstructorInfo)method, parameterTypes, modifiers, flags);
}
else
{
- return new SmartCallMethodWrapper(declaringType, name, sig, (MethodInfo)method, returnType, parameterTypes, modifiers, hideFromReflection, SimpleOpCode.Call, method.IsStatic ? SimpleOpCode.Call : SimpleOpCode.Callvirt);
+ return new SmartCallMethodWrapper(declaringType, name, sig, (MethodInfo)method, returnType, parameterTypes, modifiers, flags, SimpleOpCode.Call, method.IsStatic ? SimpleOpCode.Call : SimpleOpCode.Callvirt);
}
}
@@ -929,8 +946,8 @@ sealed class SimpleCallMethodWrapper : MethodWrapper
private SimpleOpCode call;
private SimpleOpCode callvirt;
- internal SimpleCallMethodWrapper(TypeWrapper declaringType, string name, string sig, MethodInfo method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, bool hideFromReflection, SimpleOpCode call, SimpleOpCode callvirt)
- : base(declaringType, name, sig, method, returnType, parameterTypes, modifiers, hideFromReflection ? MemberFlags.HideFromReflection : MemberFlags.None)
+ internal SimpleCallMethodWrapper(TypeWrapper declaringType, string name, string sig, MethodInfo method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags, SimpleOpCode call, SimpleOpCode callvirt)
+ : base(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags)
{
this.call = call;
this.callvirt = callvirt;
@@ -952,11 +969,6 @@ sealed class SmartCallMethodWrapper : SmartMethodWrapper
private SimpleOpCode call;
private SimpleOpCode callvirt;
- internal SmartCallMethodWrapper(TypeWrapper declaringType, string name, string sig, MethodInfo method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, bool hideFromReflection, SimpleOpCode call, SimpleOpCode callvirt)
- : this(declaringType, name, sig, method, returnType, parameterTypes, modifiers, hideFromReflection ? MemberFlags.HideFromReflection : MemberFlags.None, call, callvirt)
- {
- }
-
internal SmartCallMethodWrapper(TypeWrapper declaringType, string name, string sig, MethodInfo method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags, SimpleOpCode call, SimpleOpCode callvirt)
: base(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags)
{
@@ -982,11 +994,6 @@ sealed class SmartConstructorMethodWrapper : SmartMethodWrapper
{
}
- internal SmartConstructorMethodWrapper(TypeWrapper declaringType, string name, string sig, ConstructorInfo method, TypeWrapper[] parameterTypes, Modifiers modifiers, bool hideFromReflection)
- : base(declaringType, name, sig, method, PrimitiveTypeWrapper.VOID, parameterTypes, modifiers, hideFromReflection ? MemberFlags.HideFromReflection : MemberFlags.None)
- {
- }
-
protected override void CallImpl(ILGenerator ilgen)
{
ilgen.Emit(OpCodes.Call, (ConstructorInfo)GetMethod());
diff --git a/runtime/verifier.cs b/runtime/verifier.cs
index 8344ecf5..2194d503 100644
--- a/runtime/verifier.cs
+++ b/runtime/verifier.cs
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002, 2003, 2004 Jeroen Frijters
+ Copyright (C) 2002, 2003, 2004, 2005 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -1790,12 +1790,7 @@ class MethodAnalyzer
TypeWrapper type = GetConstantPoolClassType(instr.Arg1);
if(type.IsUnloadable)
{
- string name = type.Name;
- if(name[0] != '[')
- {
- name = "L" + name + ";";
- }
- s.PushType(new UnloadableTypeWrapper(name));
+ s.PushType(new UnloadableTypeWrapper("[" + type.SigName));
}
else
{