зеркало из https://github.com/mono/ikvm-fork.git
*** empty log message ***
This commit is contained in:
Родитель
46d900b234
Коммит
c5a3ee90b3
|
@ -38,11 +38,6 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
#if WHIDBEY
|
||||
// We rely on string literals being interned and starting with .NET 2.0 this is no longer the default
|
||||
[assembly: CompilationRelaxations(0)]
|
||||
#endif
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
|
|
|
@ -38,11 +38,6 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
#if WHIDBEY
|
||||
// We rely on string literals being interned and starting with .NET 2.0 this is no longer the default
|
||||
[assembly: CompilationRelaxations(0)]
|
||||
#endif
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
|
|
|
@ -41,6 +41,22 @@ namespace IKVM.Internal
|
|||
LinkageError
|
||||
}
|
||||
|
||||
sealed class StringConstants
|
||||
{
|
||||
private StringConstants() {}
|
||||
|
||||
internal static readonly string CLINIT = string.Intern("<clinit>");
|
||||
internal static readonly string INIT = string.Intern("<init>");
|
||||
internal static readonly string SIG_VOID = string.Intern("()V");
|
||||
|
||||
internal static readonly string JAVA_LANG_SYSTEM = string.Intern("java.lang.System");
|
||||
internal static readonly string JAVA_LANG_VMSYSTEM = string.Intern("java.lang.VMSystem");
|
||||
internal static readonly string ARRAYCOPY = string.Intern("arraycopy");
|
||||
internal static readonly string SIG_ARRAYCOPY = string.Intern("(Ljava.lang.Object;ILjava.lang.Object;II)V");
|
||||
internal static readonly string FINALIZE = string.Intern("finalize");
|
||||
internal static readonly string CLONE = string.Intern("clone");
|
||||
}
|
||||
|
||||
sealed class ClassFile
|
||||
{
|
||||
private ConstantPoolItem[] constantpool;
|
||||
|
@ -297,14 +313,17 @@ namespace IKVM.Internal
|
|||
methods[i] = new Method(this, br);
|
||||
string name = methods[i].Name;
|
||||
string sig = methods[i].Signature;
|
||||
if(!IsValidMethodName(name) && !ReferenceEquals(name, "<init>") && !ReferenceEquals(name, "<clinit>"))
|
||||
if(!IsValidMethodName(name))
|
||||
{
|
||||
if(!ReferenceEquals(name, StringConstants.INIT) && !ReferenceEquals(name, StringConstants.CLINIT))
|
||||
{
|
||||
throw new ClassFormatError("{0} (Illegal method name \"{1}\")", Name, name);
|
||||
}
|
||||
if((ReferenceEquals(name, "<init>") || ReferenceEquals(name, "<clinit>")) && !sig.EndsWith("V"))
|
||||
if(!sig.EndsWith("V"))
|
||||
{
|
||||
throw new ClassFormatError("{0} (Method \"{1}\" has illegal signature \"{2}\")", Name, name, sig);
|
||||
}
|
||||
}
|
||||
for(int j = 0; j < i; j++)
|
||||
{
|
||||
if(ReferenceEquals(methods[j].Name, name) && ReferenceEquals(methods[j].Signature, sig))
|
||||
|
@ -1475,17 +1494,17 @@ namespace IKVM.Internal
|
|||
{
|
||||
throw new ClassFormatError("Method {0} has invalid signature {1}", name, descriptor);
|
||||
}
|
||||
if(ReferenceEquals(name, "<init>") || ReferenceEquals(name, "<clinit>"))
|
||||
if(!IsValidMethodName(name))
|
||||
{
|
||||
if(!ReferenceEquals(name, StringConstants.INIT) && !ReferenceEquals(name, StringConstants.CLINIT))
|
||||
{
|
||||
throw new ClassFormatError("Invalid method name \"{0}\"", name);
|
||||
}
|
||||
if(!descriptor.EndsWith("V"))
|
||||
{
|
||||
throw new ClassFormatError("Method {0} has invalid signature {1}", name, descriptor);
|
||||
}
|
||||
}
|
||||
else if(!IsValidMethodName(name))
|
||||
{
|
||||
throw new ClassFormatError("Invalid method name \"{0}\"", name);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Link(TypeWrapper thisType, Hashtable classCache)
|
||||
|
@ -1544,12 +1563,12 @@ namespace IKVM.Internal
|
|||
TypeWrapper wrapper = GetClassType();
|
||||
if(!wrapper.IsUnloadable)
|
||||
{
|
||||
method = wrapper.GetMethodWrapper(Name, Signature, !ReferenceEquals(Name, "<init>"));
|
||||
method = wrapper.GetMethodWrapper(Name, Signature, !ReferenceEquals(Name, StringConstants.INIT));
|
||||
if(method != null)
|
||||
{
|
||||
method.Link();
|
||||
}
|
||||
if(Name != "<init>" &&
|
||||
if(Name != StringConstants.INIT &&
|
||||
(thisType.Modifiers & (Modifiers.Interface | Modifiers.Super)) == Modifiers.Super &&
|
||||
thisType != wrapper && thisType.IsSubTypeOf(wrapper))
|
||||
{
|
||||
|
@ -2048,7 +2067,7 @@ namespace IKVM.Internal
|
|||
internal Method(ClassFile classFile, BigEndianBinaryReader br) : base(classFile, br)
|
||||
{
|
||||
// vmspec 4.6 says that all flags, except ACC_STRICT are ignored on <clinit>
|
||||
if(ReferenceEquals(Name, "<clinit>") && ReferenceEquals(Signature, "()V"))
|
||||
if(ReferenceEquals(Name, StringConstants.CLINIT) && ReferenceEquals(Signature, StringConstants.SIG_VOID))
|
||||
{
|
||||
access_flags &= Modifiers.Strictfp;
|
||||
access_flags |= (Modifiers.Static | Modifiers.Private);
|
||||
|
@ -2057,7 +2076,7 @@ namespace IKVM.Internal
|
|||
{
|
||||
// LAMESPEC: vmspec 4.6 says that abstract methods can not be strictfp (and this makes sense), but
|
||||
// javac (pre 1.5) is broken and marks abstract methods as strictfp (if you put the strictfp on the class)
|
||||
if((ReferenceEquals(Name, "<init>") && (IsStatic || IsSynchronized || IsFinal || IsAbstract || IsNative))
|
||||
if((ReferenceEquals(Name, StringConstants.INIT) && (IsStatic || IsSynchronized || IsFinal || IsAbstract || IsNative))
|
||||
|| (IsPrivate && IsPublic) || (IsPrivate && IsProtected) || (IsPublic && IsProtected)
|
||||
|| (IsAbstract && (IsFinal || IsNative || IsPrivate || IsStatic || IsSynchronized))
|
||||
|| (classFile.IsInterface && (!IsPublic || !IsAbstract)))
|
||||
|
@ -2195,7 +2214,7 @@ namespace IKVM.Internal
|
|||
{
|
||||
if(code.IsEmpty)
|
||||
{
|
||||
if(ReferenceEquals(this.Name, "<clinit>"))
|
||||
if(ReferenceEquals(this.Name, StringConstants.CLINIT))
|
||||
{
|
||||
code.verifyError = string.Format("Class {0}, method {1} signature {2}: No Code attribute", classFile.Name, this.Name, this.Signature);
|
||||
return;
|
||||
|
@ -2226,7 +2245,7 @@ namespace IKVM.Internal
|
|||
{
|
||||
get
|
||||
{
|
||||
return ReferenceEquals(Name, "<clinit>") && ReferenceEquals(Signature, "()V");
|
||||
return ReferenceEquals(Name, StringConstants.CLINIT) && ReferenceEquals(Signature, StringConstants.SIG_VOID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -559,9 +559,6 @@ namespace IKVM.Internal
|
|||
protected virtual TypeWrapper LoadClassImpl(string name, bool throwClassNotFoundException)
|
||||
{
|
||||
#if !STATIC_COMPILER
|
||||
// NOTE just like Java does (I think), we take the classloader lock before calling the loadClass method
|
||||
lock(javaClassLoader)
|
||||
{
|
||||
Profiler.Enter("ClassLoader.loadClass");
|
||||
TypeWrapper type;
|
||||
try
|
||||
|
@ -582,7 +579,6 @@ namespace IKVM.Internal
|
|||
Profiler.Leave("ClassLoader.loadClass");
|
||||
}
|
||||
return type;
|
||||
}
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
|
|
|
@ -377,22 +377,16 @@ namespace IKVM.Runtime
|
|||
|
||||
sealed class JniHelper
|
||||
{
|
||||
//[DllImport("ikvm-native", EntryPoint="_ikvm_LoadLibrary@4")]
|
||||
[DllImport("ikvm-native")]
|
||||
private static extern IntPtr ikvm_LoadLibrary(string filename);
|
||||
//[DllImport("ikvm-native", EntryPoint="_ikvm_FreeLibrary@4")]
|
||||
[DllImport("ikvm-native")]
|
||||
private static extern void ikvm_FreeLibrary(IntPtr handle);
|
||||
//[DllImport("ikvm-native", EntryPoint="_ikvm_GetProcAddress@12")]
|
||||
[DllImport("ikvm-native")]
|
||||
internal static extern IntPtr ikvm_GetProcAddress(IntPtr handle, string name, int argc);
|
||||
//[DllImport("ikvm-native", EntryPoint="_ikvm_CallOnLoad@12")]
|
||||
[DllImport("ikvm-native")]
|
||||
private unsafe static extern int ikvm_CallOnLoad(IntPtr method, void* jvm, void* reserved);
|
||||
//[DllImport("ikvm-native", EntryPoint="_ikvm_GetJNIEnvVTable@0")]
|
||||
[DllImport("ikvm-native")]
|
||||
internal unsafe static extern void** ikvm_GetJNIEnvVTable();
|
||||
//[DllImport("ikvm-native", EntryPoint="_ikvm_MarshalDelegate@4")]
|
||||
[DllImport("ikvm-native")]
|
||||
internal unsafe static extern void* ikvm_MarshalDelegate(Delegate d);
|
||||
|
||||
|
@ -911,12 +905,7 @@ namespace IKVM.Runtime
|
|||
{
|
||||
JNI.jvmCreated = true;
|
||||
pJavaVM = (JavaVM*)(void*)JniMem.Alloc(IntPtr.Size * (1 + vtableDelegates.Length));
|
||||
//#if __MonoCS__
|
||||
// // MONOBUG mcs requires this bogus fixed construct (and Microsoft doesn't allow it)
|
||||
// fixed(void** p = &pJavaVM->firstVtableEntry) { pJavaVM->vtable = p; }
|
||||
//#else
|
||||
pJavaVM->vtable = &pJavaVM->firstVtableEntry;
|
||||
//#endif
|
||||
for(int i = 0; i < vtableDelegates.Length; i++)
|
||||
{
|
||||
pJavaVM->vtable[i] = JniHelper.ikvm_MarshalDelegate(vtableDelegates[i]);
|
||||
|
@ -3402,12 +3391,6 @@ namespace IKVM.Runtime
|
|||
{
|
||||
internal static IntPtr Alloc(int cb)
|
||||
{
|
||||
// MONOBUG Marshal.AllocHGlobal returns a null pointer if we try to allocate zero bytes
|
||||
// (as of Mono 1.0.2 this shouldn't be necessary anymore)
|
||||
if(cb == 0)
|
||||
{
|
||||
cb = 1;
|
||||
}
|
||||
return Marshal.AllocHGlobal(cb);
|
||||
}
|
||||
|
||||
|
|
|
@ -614,7 +614,7 @@ namespace IKVM.Internal
|
|||
}
|
||||
else
|
||||
{
|
||||
if(ReferenceEquals(Name, "<init>"))
|
||||
if(ReferenceEquals(Name, StringConstants.INIT))
|
||||
{
|
||||
if(method is MethodInfo)
|
||||
{
|
||||
|
|
|
@ -3292,7 +3292,7 @@ namespace IKVM.Internal
|
|||
{
|
||||
methods[i] = new MethodWrapper.GhostMethodWrapper(wrapper, m.Name, m.Signature, null, null, null, m.Modifiers, flags);
|
||||
}
|
||||
else if(ReferenceEquals(m.Name, "<init>"))
|
||||
else if(ReferenceEquals(m.Name, StringConstants.INIT))
|
||||
{
|
||||
methods[i] = new SmartConstructorMethodWrapper(wrapper, m.Name, m.Signature, null, null, m.Modifiers, flags);
|
||||
}
|
||||
|
@ -3354,7 +3354,7 @@ namespace IKVM.Internal
|
|||
fields[i] = new ConstantFieldWrapper(wrapper, null, fld.Name, fld.Signature, fld.Modifiers, null, fld.ConstantValue, MemberFlags.LiteralField);
|
||||
}
|
||||
else if(fld.IsFinal && (JVM.IsStaticCompiler && (fld.IsPublic || fld.IsProtected))
|
||||
&& !wrapper.IsInterface && (!JVM.StrictFinalFieldSemantics || ReferenceEquals(wrapper.Name, "java.lang.System")))
|
||||
&& !wrapper.IsInterface && (!JVM.StrictFinalFieldSemantics || ReferenceEquals(wrapper.Name, StringConstants.JAVA_LANG_SYSTEM)))
|
||||
{
|
||||
fields[i] = new GetterFieldWrapper(wrapper, null, null, fld.Name, fld.Signature, new ExModifiers(fld.Modifiers, fld.IsInternal), null);
|
||||
}
|
||||
|
@ -5689,7 +5689,7 @@ namespace IKVM.Internal
|
|||
{
|
||||
attribs |= MethodAttributes.Assembly;
|
||||
}
|
||||
if(ReferenceEquals(m.Name, "<init>"))
|
||||
if(ReferenceEquals(m.Name, StringConstants.INIT))
|
||||
{
|
||||
if(setNameSig)
|
||||
{
|
||||
|
@ -5788,7 +5788,7 @@ namespace IKVM.Internal
|
|||
bool needDispatch = false;
|
||||
bool finalizeClash = false;
|
||||
MethodInfo baseFinalize = null;
|
||||
if(baseMce != null && ReferenceEquals(m.Name, "finalize") && ReferenceEquals(m.Signature, "()V"))
|
||||
if(baseMce != null && ReferenceEquals(m.Name, StringConstants.FINALIZE) && ReferenceEquals(m.Signature, StringConstants.SIG_VOID))
|
||||
{
|
||||
baseFinalize = GetBaseFinalizeMethod(typeBuilder.BaseType, out finalizeClash);
|
||||
if(baseMce.RealName == "Finalize")
|
||||
|
|
|
@ -1614,9 +1614,9 @@ class Compiler
|
|||
// are of a known array type, we can redirect to an optimized version of arraycopy.
|
||||
// Note that we also have to handle VMSystem.arraycopy, because StringBuffer directly calls
|
||||
// this method to avoid prematurely initialising System.
|
||||
if((ReferenceEquals(cpi.Class, "java.lang.System") || ReferenceEquals(cpi.Class, "java.lang.VMSystem"))
|
||||
&& ReferenceEquals(cpi.Name, "arraycopy")
|
||||
&& ReferenceEquals(cpi.Signature, "(Ljava.lang.Object;ILjava.lang.Object;II)V")
|
||||
if((ReferenceEquals(cpi.Class, StringConstants.JAVA_LANG_SYSTEM) || ReferenceEquals(cpi.Class, StringConstants.JAVA_LANG_VMSYSTEM))
|
||||
&& ReferenceEquals(cpi.Name, StringConstants.ARRAYCOPY)
|
||||
&& ReferenceEquals(cpi.Signature, StringConstants.SIG_ARRAYCOPY)
|
||||
&& cpi.GetClassType().GetClassLoader() == ClassLoaderWrapper.GetBootstrapClassLoader())
|
||||
{
|
||||
TypeWrapper dst_type = ma.GetStackTypeWrapper(i, 2);
|
||||
|
@ -1689,7 +1689,7 @@ class Compiler
|
|||
|
||||
// if the stack values don't match the argument types (for interface argument types)
|
||||
// we must emit code to cast the stack value to the interface type
|
||||
if(isinvokespecial && ReferenceEquals(cpi.Name, "<init>") && VerifierTypeWrapper.IsNew(type))
|
||||
if(isinvokespecial && ReferenceEquals(cpi.Name, StringConstants.INIT) && VerifierTypeWrapper.IsNew(type))
|
||||
{
|
||||
TypeWrapper[] args = cpi.GetArgTypes();
|
||||
CastInterfaceArgs(method, args, i, false);
|
||||
|
@ -1711,7 +1711,7 @@ class Compiler
|
|||
CastInterfaceArgs(method, args, i, true);
|
||||
}
|
||||
|
||||
if(isinvokespecial && ReferenceEquals(cpi.Name, "<init>"))
|
||||
if(isinvokespecial && ReferenceEquals(cpi.Name, StringConstants.INIT))
|
||||
{
|
||||
if(VerifierTypeWrapper.IsNew(type))
|
||||
{
|
||||
|
|
|
@ -1530,7 +1530,7 @@ class MethodAnalyzer
|
|||
{
|
||||
thisType = VerifierTypeWrapper.MakeThis(wrapper);
|
||||
// this reference. If we're a constructor, the this reference is uninitialized.
|
||||
if(ReferenceEquals(method.Name, "<init>"))
|
||||
if(ReferenceEquals(method.Name, StringConstants.INIT))
|
||||
{
|
||||
state[0].SetLocalType(firstNonArgLocalIndex++, VerifierTypeWrapper.UninitializedThis, -1);
|
||||
state[0].SetUnitializedThis(true);
|
||||
|
@ -1937,7 +1937,7 @@ class MethodAnalyzer
|
|||
if(instr.NormalizedOpCode != NormalizedByteCode.__invokestatic)
|
||||
{
|
||||
TypeWrapper type = s.PopType();
|
||||
if(ReferenceEquals(cpi.Name, "<init>"))
|
||||
if(ReferenceEquals(cpi.Name, StringConstants.INIT))
|
||||
{
|
||||
// after we've invoked the constructor, the uninitialized references
|
||||
// are now initialized
|
||||
|
@ -2954,11 +2954,11 @@ class MethodAnalyzer
|
|||
{
|
||||
throw new VerifyError("Illegal constant pool index");
|
||||
}
|
||||
if(instr.NormalizedOpCode != NormalizedByteCode.__invokespecial && ReferenceEquals(cpi.Name, "<init>"))
|
||||
if(instr.NormalizedOpCode != NormalizedByteCode.__invokespecial && ReferenceEquals(cpi.Name, StringConstants.INIT))
|
||||
{
|
||||
throw new VerifyError("Must call initializers using invokespecial");
|
||||
}
|
||||
if(ReferenceEquals(cpi.Name, "<clinit>"))
|
||||
if(ReferenceEquals(cpi.Name, StringConstants.CLINIT))
|
||||
{
|
||||
throw new VerifyError("Illegal call to internal method");
|
||||
}
|
||||
|
@ -2992,7 +2992,7 @@ class MethodAnalyzer
|
|||
else
|
||||
{
|
||||
thisType = SigTypeToClassName(stack.PeekType(), cpi.GetClassType(), wrapper);
|
||||
if(ReferenceEquals(cpi.Name, "<init>"))
|
||||
if(ReferenceEquals(cpi.Name, StringConstants.INIT))
|
||||
{
|
||||
TypeWrapper type = stack.PopType();
|
||||
isnew = VerifierTypeWrapper.IsNew(type);
|
||||
|
@ -3105,7 +3105,7 @@ class MethodAnalyzer
|
|||
// (bug in javac, see http://developer.java.sun.com/developer/bugParade/bugs/4329886.html)
|
||||
if(cpi.GetClassType() == CoreClasses.java.lang.Object.Wrapper
|
||||
&& thisType.IsArray
|
||||
&& ReferenceEquals(cpi.Name, "clone"))
|
||||
&& ReferenceEquals(cpi.Name, StringConstants.CLONE))
|
||||
{
|
||||
// Patch the instruction, so that the compiler doesn't need to do this test again.
|
||||
instr.PatchOpCode(NormalizedByteCode.__clone_array);
|
||||
|
|
Загрузка…
Ссылка в новой задаче