You've already forked linux-packaging-mono
Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
33
external/ikvm/runtime/AssemblyClassLoader.cs
vendored
33
external/ikvm/runtime/AssemblyClassLoader.cs
vendored
@@ -746,8 +746,16 @@ namespace IKVM.Internal
|
||||
using (java.io.InputStream inp = url.openStream())
|
||||
{
|
||||
byte[] buf = new byte[inp.available()];
|
||||
inp.read(buf, 0, buf.Length);
|
||||
return TypeWrapper.FromClass(IKVM.NativeCode.java.lang.ClassLoader.defineClass1(GetJavaClassLoader(), name, buf, 0, buf.Length, GetProtectionDomain(), null));
|
||||
for (int pos = 0; pos < buf.Length; )
|
||||
{
|
||||
int read = inp.read(buf, pos, buf.Length - pos);
|
||||
if (read <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pos += read;
|
||||
}
|
||||
return TypeWrapper.FromClass(Java_java_lang_ClassLoader.defineClass1(GetJavaClassLoader(), name, buf, 0, buf.Length, GetProtectionDomain(), null));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -860,7 +868,7 @@ namespace IKVM.Internal
|
||||
if (!found && unmangledName.EndsWith(".class", StringComparison.Ordinal) && unmangledName.IndexOf('.') == unmangledName.Length - 6)
|
||||
{
|
||||
TypeWrapper tw = FindLoadedClass(unmangledName.Substring(0, unmangledName.Length - 6).Replace('/', '.'));
|
||||
if (tw != null && tw.GetClassLoader() == this && !tw.IsArray && !(tw is DynamicTypeWrapper))
|
||||
if (tw != null && tw.GetClassLoader() == this && !tw.IsArray && !tw.IsDynamic)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
yield return new java.io.File(VirtualFileSystem.GetAssemblyClassesPath(assemblyLoader.Assembly) + unmangledName).toURI().toURL();
|
||||
@@ -1103,28 +1111,23 @@ namespace IKVM.Internal
|
||||
LazyInitExports();
|
||||
lock (this)
|
||||
{
|
||||
Array.Resize(ref delegates, delegates.Length + 1);
|
||||
delegates[delegates.Length - 1] = acl;
|
||||
delegates = ArrayUtil.Concat(delegates, acl);
|
||||
}
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR
|
||||
internal string[] GetPackages()
|
||||
internal List<KeyValuePair<string, string[]>> GetPackageInfo()
|
||||
{
|
||||
string[] packages = new string[0];
|
||||
List<KeyValuePair<string, string[]>> list = new List<KeyValuePair<string, string[]>>();
|
||||
foreach (Module m in assemblyLoader.Assembly.GetModules(false))
|
||||
{
|
||||
object[] attr = m.GetCustomAttributes(typeof(PackageListAttribute), false);
|
||||
foreach (PackageListAttribute p in attr)
|
||||
{
|
||||
string[] mp = p.GetPackages();
|
||||
string[] tmp = new string[packages.Length + mp.Length];
|
||||
Array.Copy(packages, 0, tmp, 0, packages.Length);
|
||||
Array.Copy(mp, 0, tmp, packages.Length, mp.Length);
|
||||
packages = tmp;
|
||||
list.Add(new KeyValuePair<string, string[]>(p.jar, p.packages));
|
||||
}
|
||||
}
|
||||
return packages;
|
||||
return list;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1313,6 +1316,10 @@ namespace IKVM.Internal
|
||||
return base.GetWrapperFromAssemblyType(type);
|
||||
}
|
||||
|
||||
protected override void CheckProhibitedPackage(string className)
|
||||
{
|
||||
}
|
||||
|
||||
#if !FIRST_PASS && !STATIC_COMPILER && !STUB_GENERATOR
|
||||
internal override java.lang.ClassLoader GetJavaClassLoader()
|
||||
{
|
||||
|
25
external/ikvm/runtime/BigEndianBinaryReader.cs
vendored
25
external/ikvm/runtime/BigEndianBinaryReader.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002-2012 Jeroen Frijters
|
||||
Copyright (C) 2002-2014 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
|
||||
@@ -164,7 +164,7 @@ sealed class BigEndianBinaryReader
|
||||
case 0:
|
||||
if(c == 0)
|
||||
{
|
||||
throw new ClassFormatError("{0} (Illegal UTF8 string in constant pool)", classFile);
|
||||
goto default;
|
||||
}
|
||||
break;
|
||||
case 1: case 2: case 3: case 4: case 5: case 6: case 7:
|
||||
@@ -175,9 +175,13 @@ sealed class BigEndianBinaryReader
|
||||
char2 = buf[pos + ++i];
|
||||
if((char2 & 0xc0) != 0x80 || i >= len)
|
||||
{
|
||||
throw new ClassFormatError("{0} (Illegal UTF8 string in constant pool)", classFile);
|
||||
goto default;
|
||||
}
|
||||
c = (((c & 0x1F) << 6) | (char2 & 0x3F));
|
||||
if(c < 0x80 && c != 0)
|
||||
{
|
||||
goto default;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
// 1110 xxxx 10xx xxxx 10xx xxxx
|
||||
@@ -185,12 +189,16 @@ sealed class BigEndianBinaryReader
|
||||
char3 = buf[pos + ++i];
|
||||
if((char2 & 0xc0) != 0x80 || (char3 & 0xc0) != 0x80 || i >= len)
|
||||
{
|
||||
throw new ClassFormatError("{0} (Illegal UTF8 string in constant pool)", classFile);
|
||||
goto default;
|
||||
}
|
||||
c = (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
|
||||
if(c < 0x800)
|
||||
{
|
||||
goto default;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ClassFormatError("{0} (Illegal UTF8 string in constant pool)", classFile);
|
||||
throw new ClassFormatError("Illegal UTF8 string in constant pool in class file {0}", classFile);
|
||||
}
|
||||
ch[l++] = (char)c;
|
||||
}
|
||||
@@ -224,4 +232,11 @@ sealed class BigEndianBinaryReader
|
||||
pos += 4;
|
||||
return i;
|
||||
}
|
||||
|
||||
internal byte[] ToArray()
|
||||
{
|
||||
byte[] res = new byte[end - pos];
|
||||
Buffer.BlockCopy(buf, pos, res, 0, res.Length);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
212
external/ikvm/runtime/Boxer.cs
vendored
Normal file
212
external/ikvm/runtime/Boxer.cs
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
Copyright (C) 2011-2014 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
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
jeroen@frijters.net
|
||||
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace IKVM.Internal
|
||||
{
|
||||
static class Boxer
|
||||
{
|
||||
private static readonly TypeWrapper javaLangByte;
|
||||
private static readonly MethodWrapper byteValue;
|
||||
private static readonly MethodWrapper valueOfByte;
|
||||
private static readonly TypeWrapper javaLangBoolean;
|
||||
private static readonly MethodWrapper booleanValue;
|
||||
private static readonly MethodWrapper valueOfBoolean;
|
||||
private static readonly TypeWrapper javaLangShort;
|
||||
private static readonly MethodWrapper shortValue;
|
||||
private static readonly MethodWrapper valueOfShort;
|
||||
private static readonly TypeWrapper javaLangCharacter;
|
||||
private static readonly MethodWrapper charValue;
|
||||
private static readonly MethodWrapper valueOfCharacter;
|
||||
private static readonly TypeWrapper javaLangInteger;
|
||||
private static readonly MethodWrapper intValue;
|
||||
private static readonly MethodWrapper valueOfInteger;
|
||||
private static readonly TypeWrapper javaLangFloat;
|
||||
private static readonly MethodWrapper floatValue;
|
||||
private static readonly MethodWrapper valueOfFloat;
|
||||
private static readonly TypeWrapper javaLangLong;
|
||||
private static readonly MethodWrapper longValue;
|
||||
private static readonly MethodWrapper valueOfLong;
|
||||
private static readonly TypeWrapper javaLangDouble;
|
||||
private static readonly MethodWrapper doubleValue;
|
||||
private static readonly MethodWrapper valueOfDouble;
|
||||
|
||||
static Boxer()
|
||||
{
|
||||
ClassLoaderWrapper bootClassLoader = ClassLoaderWrapper.GetBootstrapClassLoader();
|
||||
javaLangByte = bootClassLoader.LoadClassByDottedNameFast("java.lang.Byte");
|
||||
byteValue = javaLangByte.GetMethodWrapper("byteValue", "()B", false);
|
||||
byteValue.Link();
|
||||
valueOfByte = javaLangByte.GetMethodWrapper("valueOf", "(B)Ljava.lang.Byte;", false);
|
||||
valueOfByte.Link();
|
||||
javaLangBoolean = bootClassLoader.LoadClassByDottedNameFast("java.lang.Boolean");
|
||||
booleanValue = javaLangBoolean.GetMethodWrapper("booleanValue", "()Z", false);
|
||||
booleanValue.Link();
|
||||
valueOfBoolean = javaLangBoolean.GetMethodWrapper("valueOf", "(Z)Ljava.lang.Boolean;", false);
|
||||
valueOfBoolean.Link();
|
||||
javaLangShort = bootClassLoader.LoadClassByDottedNameFast("java.lang.Short");
|
||||
shortValue = javaLangShort.GetMethodWrapper("shortValue", "()S", false);
|
||||
shortValue.Link();
|
||||
valueOfShort = javaLangShort.GetMethodWrapper("valueOf", "(S)Ljava.lang.Short;", false);
|
||||
valueOfShort.Link();
|
||||
javaLangCharacter = bootClassLoader.LoadClassByDottedNameFast("java.lang.Character");
|
||||
charValue = javaLangCharacter.GetMethodWrapper("charValue", "()C", false);
|
||||
charValue.Link();
|
||||
valueOfCharacter = javaLangCharacter.GetMethodWrapper("valueOf", "(C)Ljava.lang.Character;", false);
|
||||
valueOfCharacter.Link();
|
||||
javaLangInteger = bootClassLoader.LoadClassByDottedNameFast("java.lang.Integer");
|
||||
intValue = javaLangInteger.GetMethodWrapper("intValue", "()I", false);
|
||||
intValue.Link();
|
||||
valueOfInteger = javaLangInteger.GetMethodWrapper("valueOf", "(I)Ljava.lang.Integer;", false);
|
||||
valueOfInteger.Link();
|
||||
javaLangFloat = bootClassLoader.LoadClassByDottedNameFast("java.lang.Float");
|
||||
floatValue = javaLangFloat.GetMethodWrapper("floatValue", "()F", false);
|
||||
floatValue.Link();
|
||||
valueOfFloat = javaLangFloat.GetMethodWrapper("valueOf", "(F)Ljava.lang.Float;", false);
|
||||
valueOfFloat.Link();
|
||||
javaLangLong = bootClassLoader.LoadClassByDottedNameFast("java.lang.Long");
|
||||
longValue = javaLangLong.GetMethodWrapper("longValue", "()J", false);
|
||||
longValue.Link();
|
||||
valueOfLong = javaLangLong.GetMethodWrapper("valueOf", "(J)Ljava.lang.Long;", false);
|
||||
valueOfLong.Link();
|
||||
javaLangDouble = bootClassLoader.LoadClassByDottedNameFast("java.lang.Double");
|
||||
doubleValue = javaLangDouble.GetMethodWrapper("doubleValue", "()D", false);
|
||||
doubleValue.Link();
|
||||
valueOfDouble = javaLangDouble.GetMethodWrapper("valueOf", "(D)Ljava.lang.Double;", false);
|
||||
valueOfDouble.Link();
|
||||
}
|
||||
|
||||
internal static void EmitUnbox(CodeEmitter ilgen, TypeWrapper tw, bool cast)
|
||||
{
|
||||
if (tw == PrimitiveTypeWrapper.BYTE)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangByte.EmitCheckcast(ilgen);
|
||||
}
|
||||
byteValue.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.BOOLEAN)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangBoolean.EmitCheckcast(ilgen);
|
||||
}
|
||||
booleanValue.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.SHORT)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangShort.EmitCheckcast(ilgen);
|
||||
}
|
||||
shortValue.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.CHAR)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangCharacter.EmitCheckcast(ilgen);
|
||||
}
|
||||
charValue.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.INT)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangInteger.EmitCheckcast(ilgen);
|
||||
}
|
||||
intValue.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.FLOAT)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangFloat.EmitCheckcast(ilgen);
|
||||
}
|
||||
floatValue.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.LONG)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangLong.EmitCheckcast(ilgen);
|
||||
}
|
||||
longValue.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.DOUBLE)
|
||||
{
|
||||
if (cast)
|
||||
{
|
||||
javaLangDouble.EmitCheckcast(ilgen);
|
||||
}
|
||||
doubleValue.EmitCall(ilgen);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void EmitBox(CodeEmitter ilgen, TypeWrapper tw)
|
||||
{
|
||||
if (tw == PrimitiveTypeWrapper.BYTE)
|
||||
{
|
||||
valueOfByte.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.BOOLEAN)
|
||||
{
|
||||
valueOfBoolean.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.SHORT)
|
||||
{
|
||||
valueOfShort.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.CHAR)
|
||||
{
|
||||
valueOfCharacter.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.INT)
|
||||
{
|
||||
valueOfInteger.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.FLOAT)
|
||||
{
|
||||
valueOfFloat.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.LONG)
|
||||
{
|
||||
valueOfLong.EmitCall(ilgen);
|
||||
}
|
||||
else if (tw == PrimitiveTypeWrapper.DOUBLE)
|
||||
{
|
||||
valueOfDouble.EmitCall(ilgen);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
403
external/ikvm/runtime/ClassFile.cs
vendored
403
external/ikvm/runtime/ClassFile.cs
vendored
File diff suppressed because it is too large
Load Diff
159
external/ikvm/runtime/ClassLoaderWrapper.cs
vendored
159
external/ikvm/runtime/ClassLoaderWrapper.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002-2013 Jeroen Frijters
|
||||
Copyright (C) 2002-2014 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
|
||||
@@ -52,16 +52,18 @@ namespace IKVM.Internal
|
||||
RemoveAsserts = 16,
|
||||
NoAutomagicSerialization = 32,
|
||||
DisableDynamicBinding = 64,
|
||||
NoRefEmitHelpers = 128,
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
abstract class TypeWrapperFactory
|
||||
{
|
||||
internal abstract ModuleBuilder ModuleBuilder { get; }
|
||||
internal abstract TypeWrapper DefineClassImpl(Dictionary<string, TypeWrapper> types, ClassFile f, ClassLoaderWrapper classLoader, ProtectionDomain protectionDomain);
|
||||
internal abstract TypeWrapper DefineClassImpl(Dictionary<string, TypeWrapper> types, TypeWrapper host, ClassFile f, ClassLoaderWrapper classLoader, ProtectionDomain protectionDomain);
|
||||
internal abstract bool ReserveName(string name);
|
||||
internal abstract string AllocMangledName(DynamicTypeWrapper tw);
|
||||
internal abstract Type DefineUnloadable(string name);
|
||||
internal abstract Type DefineDelegate(int parameterCount, bool returnVoid);
|
||||
internal abstract bool HasInternalAccess { get; }
|
||||
#if CLASSGC
|
||||
internal abstract void AddInternalsVisibleTo(Assembly friend);
|
||||
@@ -293,6 +295,50 @@ namespace IKVM.Internal
|
||||
}
|
||||
}
|
||||
|
||||
internal bool EmitNoRefEmitHelpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return (codegenoptions & CodeGenOptions.NoRefEmitHelpers) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool WorkaroundAbstractMethodWidening
|
||||
{
|
||||
get
|
||||
{
|
||||
// pre-Roslyn C# compiler doesn't like widening access to abstract methods
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool WorkaroundInterfaceFields
|
||||
{
|
||||
get
|
||||
{
|
||||
// pre-Roslyn C# compiler doesn't allow access to interface fields
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool WorkaroundInterfacePrivateMethods
|
||||
{
|
||||
get
|
||||
{
|
||||
// pre-Roslyn C# compiler doesn't like interfaces that have non-public methods
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool WorkaroundInterfaceStaticMethods
|
||||
{
|
||||
get
|
||||
{
|
||||
// pre-Roslyn C# compiler doesn't allow access to interface static methods
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR
|
||||
internal bool RelaxedClassNameValidation
|
||||
{
|
||||
@@ -307,6 +353,14 @@ namespace IKVM.Internal
|
||||
}
|
||||
#endif // !STATIC_COMPILER && !STUB_GENERATOR
|
||||
|
||||
protected virtual void CheckProhibitedPackage(string className)
|
||||
{
|
||||
if (className.StartsWith("java.", StringComparison.Ordinal))
|
||||
{
|
||||
throw new JavaSecurityException("Prohibited package name: " + className.Substring(0, className.LastIndexOf('.')));
|
||||
}
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
internal TypeWrapper DefineClass(ClassFile f, ProtectionDomain protectionDomain)
|
||||
{
|
||||
@@ -334,6 +388,7 @@ namespace IKVM.Internal
|
||||
return RegisterInitiatingLoader(tw);
|
||||
}
|
||||
#endif
|
||||
CheckProhibitedPackage(f.Name);
|
||||
// check if the class already exists if we're an AssemblyClassLoader
|
||||
if(FindLoadedClassLazy(f.Name) != null)
|
||||
{
|
||||
@@ -365,7 +420,7 @@ namespace IKVM.Internal
|
||||
}
|
||||
try
|
||||
{
|
||||
return GetTypeWrapperFactory().DefineClassImpl(types, f, this, protectionDomain);
|
||||
return GetTypeWrapperFactory().DefineClassImpl(types, null, f, this, protectionDomain);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -775,15 +830,6 @@ namespace IKVM.Internal
|
||||
}
|
||||
#endif
|
||||
|
||||
internal TypeWrapper ExpressionTypeWrapper(string type)
|
||||
{
|
||||
Debug.Assert(!type.StartsWith("Lret;"));
|
||||
Debug.Assert(type != "Lnull");
|
||||
|
||||
int index = 0;
|
||||
return SigDecoderWrapper(ref index, type, false);
|
||||
}
|
||||
|
||||
// NOTE this exposes potentially unfinished types
|
||||
internal Type[] ArgTypeListFromSig(string sig)
|
||||
{
|
||||
@@ -802,7 +848,7 @@ namespace IKVM.Internal
|
||||
|
||||
private TypeWrapper SigDecoderLoadClass(string name, bool nothrow)
|
||||
{
|
||||
return nothrow ? LoadClassNoThrow(this, name) : LoadClassByDottedName(name);
|
||||
return nothrow ? LoadClassNoThrow(this, name, false) : LoadClassByDottedName(name);
|
||||
}
|
||||
|
||||
// NOTE: this will ignore anything following the sig marker (so that it can be used to decode method signatures)
|
||||
@@ -1038,16 +1084,40 @@ namespace IKVM.Internal
|
||||
{
|
||||
Assembly asm = type.Assembly;
|
||||
#if CLASSGC
|
||||
ClassLoaderWrapper loader;
|
||||
ClassLoaderWrapper loader = null;
|
||||
if(dynamicAssemblies != null && dynamicAssemblies.TryGetValue(asm, out loader))
|
||||
{
|
||||
lock(loader.typeToTypeWrapper)
|
||||
{
|
||||
return loader.typeToTypeWrapper[type];
|
||||
TypeWrapper tw;
|
||||
if(loader.typeToTypeWrapper.TryGetValue(type, out tw))
|
||||
{
|
||||
return tw;
|
||||
}
|
||||
// it must be an anonymous type then
|
||||
Debug.Assert(AnonymousTypeWrapper.IsAnonymous(type));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR
|
||||
if(AnonymousTypeWrapper.IsAnonymous(type))
|
||||
{
|
||||
Dictionary<Type, TypeWrapper> typeToTypeWrapper;
|
||||
#if CLASSGC
|
||||
typeToTypeWrapper = loader != null ? loader.typeToTypeWrapper : globalTypeToTypeWrapper;
|
||||
#else
|
||||
typeToTypeWrapper = globalTypeToTypeWrapper;
|
||||
#endif
|
||||
TypeWrapper tw = new AnonymousTypeWrapper(type);
|
||||
lock(typeToTypeWrapper)
|
||||
{
|
||||
if(!typeToTypeWrapper.TryGetValue(type, out wrapper))
|
||||
{
|
||||
typeToTypeWrapper.Add(type, wrapper = tw);
|
||||
}
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
if(ReflectUtil.IsReflectionOnly(type))
|
||||
{
|
||||
// historically we've always returned null for types that don't have a corresponding TypeWrapper (or java.lang.Class)
|
||||
@@ -1340,7 +1410,7 @@ namespace IKVM.Internal
|
||||
}
|
||||
#endif
|
||||
|
||||
internal static TypeWrapper LoadClassNoThrow(ClassLoaderWrapper classLoader, string name)
|
||||
internal static TypeWrapper LoadClassNoThrow(ClassLoaderWrapper classLoader, string name, bool issueWarning)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1355,7 +1425,10 @@ namespace IKVM.Internal
|
||||
elementTypeName = elementTypeName.Substring(skip, elementTypeName.Length - skip - 1);
|
||||
}
|
||||
#if STATIC_COMPILER
|
||||
classLoader.IssueMessage(Message.ClassNotFound, elementTypeName);
|
||||
if (issueWarning || classLoader.WarningLevelHigh)
|
||||
{
|
||||
classLoader.IssueMessage(Message.ClassNotFound, elementTypeName);
|
||||
}
|
||||
#else
|
||||
Tracer.Error(Tracer.ClassLoading, "Class not found: {0}", elementTypeName);
|
||||
#endif
|
||||
@@ -1413,6 +1486,54 @@ namespace IKVM.Internal
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
internal ClassFileParseOptions ClassFileParseOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
#if STATIC_COMPILER
|
||||
ClassFileParseOptions cfp = ClassFileParseOptions.LocalVariableTable;
|
||||
if (EmitStackTraceInfo)
|
||||
{
|
||||
cfp |= ClassFileParseOptions.LineNumberTable;
|
||||
}
|
||||
if (bootstrapClassLoader is CompilerClassLoader)
|
||||
{
|
||||
cfp |= ClassFileParseOptions.TrustedAnnotations;
|
||||
}
|
||||
return cfp;
|
||||
#else
|
||||
ClassFileParseOptions cfp = ClassFileParseOptions.LineNumberTable;
|
||||
if (EmitDebugInfo)
|
||||
{
|
||||
cfp |= ClassFileParseOptions.LocalVariableTable;
|
||||
}
|
||||
if (RelaxedClassNameValidation)
|
||||
{
|
||||
cfp |= ClassFileParseOptions.RelaxedClassNameValidation;
|
||||
}
|
||||
if (this == bootstrapClassLoader)
|
||||
{
|
||||
cfp |= ClassFileParseOptions.TrustedAnnotations;
|
||||
}
|
||||
return cfp;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if STATIC_COMPILER
|
||||
internal virtual bool WarningLevelHigh
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
internal virtual bool NoParameterReflection
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
sealed class GenericClassLoaderWrapper : ClassLoaderWrapper
|
||||
@@ -1495,7 +1616,7 @@ namespace IKVM.Internal
|
||||
if (name.EndsWith(".class", StringComparison.Ordinal) && name.IndexOf('.') == name.Length - 6)
|
||||
{
|
||||
TypeWrapper tw = FindLoadedClass(name.Substring(0, name.Length - 6).Replace('/', '.'));
|
||||
if (tw != null && !tw.IsArray && !(tw is DynamicTypeWrapper))
|
||||
if (tw != null && !tw.IsArray && !tw.IsDynamic)
|
||||
{
|
||||
ClassLoaderWrapper loader = tw.GetClassLoader();
|
||||
if (loader is GenericClassLoaderWrapper)
|
||||
@@ -1521,7 +1642,7 @@ namespace IKVM.Internal
|
||||
if (name.EndsWith(".class", StringComparison.Ordinal) && name.IndexOf('.') == name.Length - 6)
|
||||
{
|
||||
TypeWrapper tw = FindLoadedClass(name.Substring(0, name.Length - 6).Replace('/', '.'));
|
||||
if (tw != null && tw.GetClassLoader() == this && !tw.IsArray && !(tw is DynamicTypeWrapper))
|
||||
if (tw != null && tw.GetClassLoader() == this && !tw.IsArray && !tw.IsDynamic)
|
||||
{
|
||||
return new java.net.URL("ikvmres", "gen", ClassLoaderWrapper.GetGenericClassLoaderId(this), "/" + name);
|
||||
}
|
||||
|
195
external/ikvm/runtime/DotNetTypeWrapper.cs
vendored
195
external/ikvm/runtime/DotNetTypeWrapper.cs
vendored
@@ -272,7 +272,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (type.Assembly == IKVM.NativeCode.java.lang.SecurityManager.jniAssembly)
|
||||
if (type.Assembly == Java_java_lang_SecurityManager.jniAssembly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ namespace IKVM.Internal
|
||||
this.baseWrapper = baseWrapper;
|
||||
}
|
||||
|
||||
internal override TypeWrapper BaseTypeWrapper
|
||||
internal sealed override TypeWrapper BaseTypeWrapper
|
||||
{
|
||||
get { return baseWrapper; }
|
||||
}
|
||||
@@ -368,6 +368,11 @@ namespace IKVM.Internal
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal sealed override Modifiers ReflectiveModifiers
|
||||
{
|
||||
get { return Modifiers | Modifiers.Static; }
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class DelegateInnerClassTypeWrapper : FakeTypeWrapper
|
||||
@@ -450,16 +455,21 @@ namespace IKVM.Internal
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override MethodParametersEntry[] GetMethodParameters(MethodWrapper mw)
|
||||
{
|
||||
return DeclaringTypeWrapper.GetMethodParameters(DeclaringTypeWrapper.GetMethodWrapper(mw.Name, mw.Signature, false));
|
||||
}
|
||||
}
|
||||
|
||||
private class DynamicOnlyMethodWrapper : MethodWrapper, ICustomInvoke
|
||||
private class DynamicOnlyMethodWrapper : MethodWrapper
|
||||
{
|
||||
internal DynamicOnlyMethodWrapper(TypeWrapper declaringType, string name, string sig, TypeWrapper returnType, TypeWrapper[] parameterTypes, MemberFlags flags)
|
||||
: base(declaringType, name, sig, null, returnType, parameterTypes, Modifiers.Public | Modifiers.Abstract, flags)
|
||||
{
|
||||
}
|
||||
|
||||
internal override bool IsDynamicOnly
|
||||
internal sealed override bool IsDynamicOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -468,7 +478,8 @@ namespace IKVM.Internal
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
|
||||
object ICustomInvoke.Invoke(object obj, object[] args)
|
||||
[HideFromJava]
|
||||
internal sealed override object Invoke(object obj, object[] args)
|
||||
{
|
||||
// a DynamicOnlyMethodWrapper is an interface method, but now that we've been called on an actual object instance,
|
||||
// we can resolve to a real method and call that instead
|
||||
@@ -482,14 +493,9 @@ namespace IKVM.Internal
|
||||
{
|
||||
throw new java.lang.IllegalAccessError(tw.Name + "." + this.Name + this.Signature);
|
||||
}
|
||||
if (mw.HasCallerID)
|
||||
{
|
||||
// an interface method cannot require a CallerID
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
java.lang.reflect.Method m = (java.lang.reflect.Method)mw.ToMethodOrConstructor(true);
|
||||
m.@override = true;
|
||||
return m.invoke(obj, args, null);
|
||||
mw.Link();
|
||||
mw.ResolveMethod();
|
||||
return mw.Invoke(obj, args);
|
||||
}
|
||||
#endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
|
||||
}
|
||||
@@ -508,10 +514,10 @@ namespace IKVM.Internal
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR && !FIRST_PASS
|
||||
internal object GetUnspecifiedValue()
|
||||
{
|
||||
return ((EnumFieldWrapper)GetFieldWrapper("__unspecified", this.SigName)).GetValue();
|
||||
return GetFieldWrapper("__unspecified", this.SigName).GetValue(null);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -530,8 +536,8 @@ namespace IKVM.Internal
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR
|
||||
internal object GetValue()
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR && !FIRST_PASS
|
||||
internal override object GetValue(object obj)
|
||||
{
|
||||
if (val == null)
|
||||
{
|
||||
@@ -539,9 +545,13 @@ namespace IKVM.Internal
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
internal override void SetValue(object obj, object value)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
protected override void EmitGetImpl(CodeEmitter ilgen)
|
||||
{
|
||||
#if STATIC_COMPILER
|
||||
@@ -556,10 +566,10 @@ namespace IKVM.Internal
|
||||
protected override void EmitSetImpl(CodeEmitter ilgen)
|
||||
{
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
}
|
||||
|
||||
private sealed class EnumValuesMethodWrapper : MethodWrapper, ICustomInvoke
|
||||
private sealed class EnumValuesMethodWrapper : MethodWrapper
|
||||
{
|
||||
internal EnumValuesMethodWrapper(TypeWrapper declaringType)
|
||||
: base(declaringType, "values", "()[" + declaringType.SigName, null, declaringType.MakeArrayType(1), TypeWrapper.EmptyArray, Modifiers.Public | Modifiers.Static, MemberFlags.None)
|
||||
@@ -575,20 +585,20 @@ namespace IKVM.Internal
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
|
||||
object ICustomInvoke.Invoke(object obj, object[] args)
|
||||
internal override object Invoke(object obj, object[] args)
|
||||
{
|
||||
FieldWrapper[] values = this.DeclaringType.GetFields();
|
||||
object[] array = (object[])Array.CreateInstance(this.DeclaringType.TypeAsArrayType, values.Length);
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
array[i] = ((EnumFieldWrapper)values[i]).GetValue();
|
||||
array[i] = values[i].GetValue(null);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
#endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
|
||||
}
|
||||
|
||||
private sealed class EnumValueOfMethodWrapper : MethodWrapper, ICustomInvoke
|
||||
private sealed class EnumValueOfMethodWrapper : MethodWrapper
|
||||
{
|
||||
internal EnumValueOfMethodWrapper(TypeWrapper declaringType)
|
||||
: base(declaringType, "valueOf", "(Ljava.lang.String;)" + declaringType.SigName, null, declaringType, new TypeWrapper[] { CoreClasses.java.lang.String.Wrapper }, Modifiers.Public | Modifiers.Static, MemberFlags.None)
|
||||
@@ -604,14 +614,14 @@ namespace IKVM.Internal
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
|
||||
object ICustomInvoke.Invoke(object obj, object[] args)
|
||||
internal override object Invoke(object obj, object[] args)
|
||||
{
|
||||
FieldWrapper[] values = this.DeclaringType.GetFields();
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
if (values[i].Name.Equals(args[0]))
|
||||
{
|
||||
return ((EnumFieldWrapper)values[i]).GetValue();
|
||||
return values[i].GetValue(null);
|
||||
}
|
||||
}
|
||||
throw new java.lang.IllegalArgumentException("" + args[0]);
|
||||
@@ -1800,7 +1810,7 @@ namespace IKVM.Internal
|
||||
this.iface = iface;
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
internal override bool EmitIntrinsic(EmitIntrinsicContext context)
|
||||
{
|
||||
TypeWrapper targetType = context.GetStackTypeWrapper(0, 0);
|
||||
@@ -1851,7 +1861,7 @@ namespace IKVM.Internal
|
||||
ilgen.Emit(OpCodes.Call, ByteCodeHelperMethods.DynamicCreateDelegate);
|
||||
ilgen.Emit(OpCodes.Castclass, delegateConstructor.DeclaringType);
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
}
|
||||
|
||||
private sealed class ByRefMethodWrapper : SmartMethodWrapper
|
||||
@@ -1870,7 +1880,7 @@ namespace IKVM.Internal
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
protected override void CallImpl(CodeEmitter ilgen)
|
||||
{
|
||||
ConvertByRefArgs(ilgen);
|
||||
@@ -1912,7 +1922,7 @@ namespace IKVM.Internal
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
}
|
||||
|
||||
private sealed class EnumWrapMethodWrapper : MethodWrapper
|
||||
@@ -1922,14 +1932,21 @@ namespace IKVM.Internal
|
||||
{
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
internal override void EmitCall(CodeEmitter ilgen)
|
||||
{
|
||||
// We don't actually need to do anything here!
|
||||
// The compiler will insert a boxing operation after calling us and that will
|
||||
// result in our argument being boxed (since that's still sitting on the stack).
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR && !FIRST_PASS
|
||||
internal override object Invoke(object obj, object[] args)
|
||||
{
|
||||
return Enum.ToObject(DeclaringType.TypeAsTBD, args[0]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal sealed class EnumValueFieldWrapper : FieldWrapper
|
||||
@@ -1942,7 +1959,7 @@ namespace IKVM.Internal
|
||||
underlyingType = EnumHelper.GetUnderlyingType(tw.type);
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
protected override void EmitGetImpl(CodeEmitter ilgen)
|
||||
{
|
||||
// NOTE if the reference on the stack is null, we *want* the NullReferenceException, so we don't use TypeWrapper.EmitUnbox
|
||||
@@ -1960,7 +1977,19 @@ namespace IKVM.Internal
|
||||
ilgen.Emit(OpCodes.Stobj, underlyingType);
|
||||
ilgen.ReleaseTempLocal(temp);
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
|
||||
#if !STUB_GENERATOR && !STATIC_COMPILER && !FIRST_PASS
|
||||
internal override object GetValue(object obj)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
internal override void SetValue(object obj, object value)
|
||||
{
|
||||
obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)[0].SetValue(obj, value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private sealed class ValueTypeDefaultCtor : MethodWrapper
|
||||
@@ -1970,14 +1999,21 @@ namespace IKVM.Internal
|
||||
{
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
internal override void EmitNewobj(CodeEmitter ilgen)
|
||||
{
|
||||
CodeEmitterLocal local = ilgen.DeclareLocal(DeclaringType.TypeAsTBD);
|
||||
ilgen.Emit(OpCodes.Ldloc, local);
|
||||
ilgen.Emit(OpCodes.Box, DeclaringType.TypeAsTBD);
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR && !FIRST_PASS
|
||||
internal override object CreateInstance(object[] args)
|
||||
{
|
||||
return Activator.CreateInstance(DeclaringType.TypeAsTBD);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private sealed class FinalizeMethodWrapper : MethodWrapper
|
||||
@@ -1987,7 +2023,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
internal override void EmitCall(CodeEmitter ilgen)
|
||||
{
|
||||
ilgen.Emit(OpCodes.Pop);
|
||||
@@ -1997,7 +2033,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
ilgen.Emit(OpCodes.Pop);
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
}
|
||||
|
||||
private sealed class CloneMethodWrapper : MethodWrapper
|
||||
@@ -2007,7 +2043,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
internal override void EmitCall(CodeEmitter ilgen)
|
||||
{
|
||||
ilgen.Emit(OpCodes.Dup);
|
||||
@@ -2027,7 +2063,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
EmitCall(ilgen);
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
}
|
||||
|
||||
protected override void LazyPublishMembers()
|
||||
@@ -2269,9 +2305,7 @@ namespace IKVM.Internal
|
||||
&& !typeof(java.io.Serializable.__Interface).IsAssignableFrom(type)
|
||||
&& !methodsList.ContainsKey("writeReplace()Ljava.lang.Object;"))
|
||||
{
|
||||
methodsList.Add("writeReplace()Ljava.lang.Object;", new SimpleCallMethodWrapper(this, "writeReplace", "()Ljava.lang.Object;",
|
||||
typeof(ikvm.@internal.Serialization).GetMethod("writeReplace"), CoreClasses.java.lang.Object.Wrapper, TypeWrapper.EmptyArray,
|
||||
Modifiers.Private, MemberFlags.None, SimpleOpCode.Call, SimpleOpCode.Call));
|
||||
methodsList.Add("writeReplace()Ljava.lang.Object;", new ExceptionWriteReplaceMethodWrapper(this));
|
||||
}
|
||||
#endif // !STATIC_COMPILER && !STUB_GENERATOR && !FIRST_PASS
|
||||
|
||||
@@ -2281,6 +2315,31 @@ namespace IKVM.Internal
|
||||
}
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR && !FIRST_PASS
|
||||
private sealed class ExceptionWriteReplaceMethodWrapper : MethodWrapper
|
||||
{
|
||||
internal ExceptionWriteReplaceMethodWrapper(TypeWrapper declaringType)
|
||||
: base(declaringType, "writeReplace", "()Ljava.lang.Object;", null, CoreClasses.java.lang.Object.Wrapper, TypeWrapper.EmptyArray, Modifiers.Private, MemberFlags.None)
|
||||
{
|
||||
}
|
||||
|
||||
internal override bool IsDynamicOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override object Invoke(object obj, object[] args)
|
||||
{
|
||||
Exception x = (Exception)obj;
|
||||
com.sun.xml.@internal.ws.developer.ServerSideException sse
|
||||
= new com.sun.xml.@internal.ws.developer.ServerSideException(ikvm.extensions.ExtensionMethods.getClass(x).getName(), x.Message);
|
||||
sse.initCause(x.InnerException);
|
||||
sse.setStackTrace(ikvm.extensions.ExtensionMethods.getStackTrace(x));
|
||||
return sse;
|
||||
}
|
||||
}
|
||||
#endif // !STATIC_COMPILER && !STUB_GENERATOR && !FIRST_PASS
|
||||
|
||||
private void InterfaceMethodStubHelper(Dictionary<string, MethodWrapper> methodsList, MethodBase method, string name, string sig, TypeWrapper[] args, TypeWrapper ret)
|
||||
{
|
||||
string key = name + sig;
|
||||
@@ -2317,7 +2376,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
internal override void EmitCall(CodeEmitter ilgen)
|
||||
{
|
||||
// we direct EmitCall to EmitCallvirt, because we always want to end up at the instancehelper method
|
||||
@@ -2329,7 +2388,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
m.EmitCallvirt(ilgen);
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
}
|
||||
|
||||
internal static bool IsUnsupportedAbstractMethod(MethodBase mb)
|
||||
@@ -2362,7 +2421,11 @@ namespace IKVM.Internal
|
||||
}
|
||||
type = type.GetElementType();
|
||||
}
|
||||
#if STATIC_COMPILER || STUB_GENERATOR
|
||||
return type.__IsFunctionPointer;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
private bool MakeMethodDescriptor(MethodBase mb, out string name, out string sig, out TypeWrapper[] args, out TypeWrapper ret)
|
||||
@@ -2493,12 +2556,12 @@ namespace IKVM.Internal
|
||||
foreach (ParameterInfo p in invoke.GetParameters())
|
||||
{
|
||||
// we don't support delegates with pointer parameters
|
||||
if (p.ParameterType.IsPointer)
|
||||
if (IsPointerType(p.ParameterType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return !IsPointerType(invoke.ReturnType);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -2668,7 +2731,7 @@ namespace IKVM.Internal
|
||||
}
|
||||
}
|
||||
|
||||
#if !STUB_GENERATOR
|
||||
#if EMITTERS
|
||||
internal override void EmitInstanceOf(CodeEmitter ilgen)
|
||||
{
|
||||
if (IsRemapped)
|
||||
@@ -2698,7 +2761,7 @@ namespace IKVM.Internal
|
||||
}
|
||||
ilgen.EmitCastclass(type);
|
||||
}
|
||||
#endif // !STUB_GENERATOR
|
||||
#endif // EMITTERS
|
||||
|
||||
internal override void Finish()
|
||||
{
|
||||
@@ -2726,6 +2789,38 @@ namespace IKVM.Internal
|
||||
finished = true;
|
||||
}
|
||||
|
||||
internal override MethodParametersEntry[] GetMethodParameters(MethodWrapper mw)
|
||||
{
|
||||
MethodBase mb = mw.GetMethod();
|
||||
if (mb == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ParameterInfo[] parameters = mb.GetParameters();
|
||||
if (parameters.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
MethodParametersEntry[] mp = new MethodParametersEntry[parameters.Length];
|
||||
bool hasName = false;
|
||||
for (int i = 0; i < mp.Length; i++)
|
||||
{
|
||||
string name = parameters[i].Name;
|
||||
bool empty = String.IsNullOrEmpty(name);
|
||||
if (empty)
|
||||
{
|
||||
name = "arg" + i;
|
||||
}
|
||||
mp[i].name = name;
|
||||
hasName |= !empty;
|
||||
}
|
||||
if (!hasName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !STUB_GENERATOR
|
||||
internal override object[] GetDeclaredAnnotations()
|
||||
{
|
||||
@@ -2780,6 +2875,10 @@ namespace IKVM.Internal
|
||||
// (i.e. injected into the assembly)
|
||||
internal override bool IsPackageAccessibleFrom(TypeWrapper wrapper)
|
||||
{
|
||||
if (wrapper == DeclaringTypeWrapper)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!base.IsPackageAccessibleFrom(wrapper))
|
||||
{
|
||||
return false;
|
||||
|
126
external/ikvm/runtime/DynamicClassLoader.cs
vendored
126
external/ikvm/runtime/DynamicClassLoader.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002-2013 Jeroen Frijters
|
||||
Copyright (C) 2002-2014 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
|
||||
@@ -62,6 +62,7 @@ namespace IKVM.Internal
|
||||
#endif // STATIC_COMPILER
|
||||
private Dictionary<string, TypeBuilder> unloadables;
|
||||
private TypeBuilder unloadableContainer;
|
||||
private Type[] delegates;
|
||||
#if !STATIC_COMPILER && !CLASSGC
|
||||
private static DynamicClassLoader instance = new DynamicClassLoader(CreateModuleBuilder(), false);
|
||||
#endif
|
||||
@@ -222,21 +223,29 @@ namespace IKVM.Internal
|
||||
return mangledTypeName;
|
||||
}
|
||||
|
||||
internal sealed override TypeWrapper DefineClassImpl(Dictionary<string, TypeWrapper> types, ClassFile f, ClassLoaderWrapper classLoader, ProtectionDomain protectionDomain)
|
||||
internal sealed override TypeWrapper DefineClassImpl(Dictionary<string, TypeWrapper> types, TypeWrapper host, ClassFile f, ClassLoaderWrapper classLoader, ProtectionDomain protectionDomain)
|
||||
{
|
||||
#if STATIC_COMPILER
|
||||
AotTypeWrapper type = new AotTypeWrapper(f, (CompilerClassLoader)classLoader);
|
||||
type.CreateStep1();
|
||||
types[f.Name] = type;
|
||||
return type;
|
||||
#elif FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
// this step can throw a retargettable exception, if the class is incorrect
|
||||
DynamicTypeWrapper type = new DynamicTypeWrapper(f, classLoader, protectionDomain);
|
||||
DynamicTypeWrapper type = new DynamicTypeWrapper(host, f, classLoader, protectionDomain);
|
||||
// This step actually creates the TypeBuilder. It is not allowed to throw any exceptions,
|
||||
// if an exception does occur, it is due to a programming error in the IKVM or CLR runtime
|
||||
// and will cause a CriticalFailure and exit the process.
|
||||
type.CreateStep1();
|
||||
type.CreateStep2();
|
||||
if(types == null)
|
||||
{
|
||||
// we're defining an anonymous class, so we don't need any locking
|
||||
TieClassAndWrapper(type, protectionDomain);
|
||||
return type;
|
||||
}
|
||||
lock(types)
|
||||
{
|
||||
// in very extreme conditions another thread may have beaten us to it
|
||||
@@ -248,16 +257,7 @@ namespace IKVM.Internal
|
||||
if(race == null)
|
||||
{
|
||||
types[f.Name] = type;
|
||||
#if !FIRST_PASS
|
||||
java.lang.Class clazz = new java.lang.Class(null);
|
||||
#if __MonoCS__
|
||||
TypeWrapper.SetTypeWrapperHack(clazz, type);
|
||||
#else
|
||||
clazz.typeWrapper = type;
|
||||
#endif
|
||||
clazz.pd = protectionDomain;
|
||||
type.SetClassObject(clazz);
|
||||
#endif
|
||||
TieClassAndWrapper(type, protectionDomain);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -268,42 +268,37 @@ namespace IKVM.Internal
|
||||
#endif // STATIC_COMPILER
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !FIRST_PASS
|
||||
private static java.lang.Class TieClassAndWrapper(TypeWrapper type, ProtectionDomain protectionDomain)
|
||||
{
|
||||
java.lang.Class clazz = new java.lang.Class(null);
|
||||
#if __MonoCS__
|
||||
TypeWrapper.SetTypeWrapperHack(clazz, type);
|
||||
#else
|
||||
clazz.typeWrapper = type;
|
||||
#endif
|
||||
clazz.pd = protectionDomain;
|
||||
type.SetClassObject(clazz);
|
||||
return clazz;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if STATIC_COMPILER
|
||||
internal TypeBuilder DefineProxy(TypeWrapper proxyClass, TypeWrapper[] interfaces)
|
||||
internal TypeBuilder DefineProxy(string name, TypeAttributes typeAttributes, Type parent, Type[] interfaces)
|
||||
{
|
||||
if (proxiesContainer == null)
|
||||
{
|
||||
proxiesContainer = moduleBuilder.DefineType("__<Proxies>", TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Abstract);
|
||||
proxiesContainer = moduleBuilder.DefineType(TypeNameUtil.ProxiesContainer, TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Abstract);
|
||||
AttributeHelper.HideFromJava(proxiesContainer);
|
||||
AttributeHelper.SetEditorBrowsableNever(proxiesContainer);
|
||||
proxies = new List<TypeBuilder>();
|
||||
}
|
||||
Type[] ifaces = new Type[interfaces.Length];
|
||||
for (int i = 0; i < ifaces.Length; i++)
|
||||
{
|
||||
ifaces[i] = interfaces[i].TypeAsBaseType;
|
||||
}
|
||||
TypeBuilder tb = proxiesContainer.DefineNestedType(GetProxyNestedName(interfaces), TypeAttributes.NestedPublic | TypeAttributes.Class | TypeAttributes.Sealed, proxyClass.TypeAsBaseType, ifaces);
|
||||
TypeBuilder tb = proxiesContainer.DefineNestedType(name, typeAttributes, parent, interfaces);
|
||||
proxies.Add(tb);
|
||||
return tb;
|
||||
}
|
||||
#endif
|
||||
|
||||
private static string GetProxyNestedName(TypeWrapper[] interfaces)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
foreach (TypeWrapper tw in interfaces)
|
||||
{
|
||||
sb.Append(tw.Name.Length).Append('|').Append(tw.Name);
|
||||
}
|
||||
return TypeNameUtil.MangleNestedTypeName(sb.ToString());
|
||||
}
|
||||
|
||||
internal static string GetProxyName(TypeWrapper[] interfaces)
|
||||
{
|
||||
return "__<Proxies>+" + GetProxyNestedName(interfaces);
|
||||
}
|
||||
|
||||
internal override Type DefineUnloadable(string name)
|
||||
{
|
||||
lock(this)
|
||||
@@ -328,6 +323,47 @@ namespace IKVM.Internal
|
||||
}
|
||||
}
|
||||
|
||||
internal override Type DefineDelegate(int parameterCount, bool returnVoid)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (delegates == null)
|
||||
{
|
||||
delegates = new Type[512];
|
||||
}
|
||||
int index = parameterCount + (returnVoid ? 256 : 0);
|
||||
Type type = delegates[index];
|
||||
if (type != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
TypeBuilder tb = moduleBuilder.DefineType(returnVoid ? "__<>NVIV`" + parameterCount : "__<>NVI`" + (parameterCount + 1), TypeAttributes.NotPublic | TypeAttributes.Sealed, Types.MulticastDelegate);
|
||||
string[] names = new string[parameterCount + (returnVoid ? 0 : 1)];
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
{
|
||||
names[i] = "P" + i;
|
||||
}
|
||||
if (!returnVoid)
|
||||
{
|
||||
names[names.Length - 1] = "R";
|
||||
}
|
||||
Type[] genericParameters = tb.DefineGenericParameters(names);
|
||||
Type[] parameterTypes = genericParameters;
|
||||
if (!returnVoid)
|
||||
{
|
||||
parameterTypes = new Type[genericParameters.Length - 1];
|
||||
Array.Copy(genericParameters, parameterTypes, parameterTypes.Length);
|
||||
}
|
||||
tb.DefineMethod(ConstructorInfo.ConstructorName, MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, Types.Void, new Type[] { Types.Object, Types.IntPtr })
|
||||
.SetImplementationFlags(MethodImplAttributes.Runtime);
|
||||
MethodBuilder mb = tb.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.NewSlot | MethodAttributes.Virtual, returnVoid ? Types.Void : genericParameters[genericParameters.Length - 1], parameterTypes);
|
||||
mb.SetImplementationFlags(MethodImplAttributes.Runtime);
|
||||
type = tb.CreateType();
|
||||
delegates[index] = type;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool HasInternalAccess
|
||||
{
|
||||
get { return hasInternalAccess; }
|
||||
@@ -403,7 +439,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
AssemblyName name = new AssemblyName();
|
||||
name.Name = "jniproxy";
|
||||
jniProxyAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave, null, null, null, null, null, true);
|
||||
jniProxyAssemblyBuilder = DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave, null);
|
||||
return jniProxyAssemblyBuilder.DefineDynamicModule("jniproxy.dll", "jniproxy.dll");
|
||||
}
|
||||
#endif
|
||||
@@ -544,12 +580,7 @@ namespace IKVM.Internal
|
||||
attribs.Add(new CustomAttributeBuilder(typeof(System.Security.SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes), new object[0]));
|
||||
}
|
||||
#endif
|
||||
AssemblyBuilder assemblyBuilder =
|
||||
#if NET_4_0
|
||||
AppDomain.CurrentDomain.DefineDynamicAssembly(name, access, null, true, attribs);
|
||||
#else
|
||||
AppDomain.CurrentDomain.DefineDynamicAssembly(name, access, null, null, null, null, null, true, attribs);
|
||||
#endif
|
||||
AssemblyBuilder assemblyBuilder = DefineDynamicAssembly(name, access, attribs);
|
||||
AttributeHelper.SetRuntimeCompatibilityAttribute(assemblyBuilder);
|
||||
bool debug = JVM.EmitSymbols;
|
||||
CustomAttributeBuilder debugAttr = new CustomAttributeBuilder(typeof(DebuggableAttribute).GetConstructor(new Type[] { typeof(bool), typeof(bool) }), new object[] { true, debug });
|
||||
@@ -558,6 +589,15 @@ namespace IKVM.Internal
|
||||
moduleBuilder.SetCustomAttribute(new CustomAttributeBuilder(typeof(IKVM.Attributes.JavaModuleAttribute).GetConstructor(Type.EmptyTypes), new object[0]));
|
||||
return moduleBuilder;
|
||||
}
|
||||
|
||||
private static AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
|
||||
{
|
||||
#if NET_4_0
|
||||
return AppDomain.CurrentDomain.DefineDynamicAssembly(name, access, null, true, assemblyAttributes);
|
||||
#else
|
||||
return AppDomain.CurrentDomain.DefineDynamicAssembly(name, access, null, null, null, null, null, true, assemblyAttributes);
|
||||
#endif
|
||||
}
|
||||
#endif // !STATIC_COMPILER
|
||||
}
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
ad0861972ed1ac0e9caf2cde6149145bd346f957
|
||||
c40b0a040f514f61c3bce5ca397280b4247710bf
|
32
external/ikvm/runtime/ExceptionHelper.cs
vendored
32
external/ikvm/runtime/ExceptionHelper.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002-2013 Jeroen Frijters
|
||||
Copyright (C) 2002-2014 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
|
||||
@@ -197,13 +197,14 @@ namespace IKVM.Internal
|
||||
{
|
||||
StackFrame frame = st.GetFrame(i);
|
||||
MethodBase m = frame.GetMethod();
|
||||
if (m == null || m.DeclaringType == null)
|
||||
if (m == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Type type = m.DeclaringType;
|
||||
if (cleanStackTrace &&
|
||||
(typeof(MethodBase).IsAssignableFrom(type)
|
||||
(type == null
|
||||
|| typeof(MethodBase).IsAssignableFrom(type)
|
||||
|| type == typeof(RuntimeMethodHandle)
|
||||
|| (type == typeof(Throwable) && m.Name == "instancehelper_fillInStackTrace")
|
||||
|| (m.Name == "ToJava" && typeof(RetargetableJavaException).IsAssignableFrom(type))
|
||||
@@ -298,6 +299,14 @@ namespace IKVM.Internal
|
||||
{
|
||||
return mb.Name.Substring(NamePrefix.DefaultMethod.Length);
|
||||
}
|
||||
else if(mb.Name.StartsWith(NamePrefix.Bridge, StringComparison.Ordinal))
|
||||
{
|
||||
return mb.Name.Substring(NamePrefix.Bridge.Length);
|
||||
}
|
||||
else if(mb.IsSpecialName)
|
||||
{
|
||||
return UnicodeUtil.UnescapeInvalidSurrogates(mb.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mb.Name;
|
||||
@@ -309,12 +318,17 @@ namespace IKVM.Internal
|
||||
#if FIRST_PASS
|
||||
return false;
|
||||
#else
|
||||
return Java_sun_reflect_Reflection.IsHideFromJava(mb) || (mb.DeclaringType == typeof(ikvm.runtime.Util) && mb.Name == "mapException");
|
||||
return (Java_sun_reflect_Reflection.GetHideFromJavaFlags(mb) & HideFromJavaFlags.StackTrace) != 0
|
||||
|| (mb.DeclaringType == typeof(ikvm.runtime.Util) && mb.Name == "mapException");
|
||||
#endif
|
||||
}
|
||||
|
||||
private static string getClassNameFromType(Type type)
|
||||
{
|
||||
if(type == null)
|
||||
{
|
||||
return "<Module>";
|
||||
}
|
||||
if(ClassLoaderWrapper.IsRemappedType(type))
|
||||
{
|
||||
return DotNetTypeWrapper.GetName(type);
|
||||
@@ -326,6 +340,12 @@ namespace IKVM.Internal
|
||||
{
|
||||
return DotNetTypeWrapper.GetName(type);
|
||||
}
|
||||
#if !FIRST_PASS
|
||||
if(tw.IsUnsafeAnonymous)
|
||||
{
|
||||
return tw.ClassObject.getName();
|
||||
}
|
||||
#endif
|
||||
return tw.Name;
|
||||
}
|
||||
return type.FullName;
|
||||
@@ -337,7 +357,7 @@ namespace IKVM.Internal
|
||||
if(ilOffset != StackFrame.OFFSET_UNKNOWN)
|
||||
{
|
||||
MethodBase mb = frame.GetMethod();
|
||||
if(mb != null)
|
||||
if(mb != null && mb.DeclaringType != null)
|
||||
{
|
||||
if(ClassLoaderWrapper.IsRemappedType(mb.DeclaringType))
|
||||
{
|
||||
@@ -356,7 +376,7 @@ namespace IKVM.Internal
|
||||
private static string GetFileName(StackFrame frame)
|
||||
{
|
||||
MethodBase mb = frame.GetMethod();
|
||||
if(mb != null)
|
||||
if(mb != null && mb.DeclaringType != null)
|
||||
{
|
||||
if(ClassLoaderWrapper.IsRemappedType(mb.DeclaringType))
|
||||
{
|
||||
|
20
external/ikvm/runtime/IKVM.Runtime.8.csproj
vendored
20
external/ikvm/runtime/IKVM.Runtime.8.csproj
vendored
@@ -36,7 +36,7 @@
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;EMITTERS</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -87,6 +87,7 @@
|
||||
<Compile Include="AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Assertions.cs" />
|
||||
<Compile Include="atomic.cs" />
|
||||
<Compile Include="attributes.cs">
|
||||
<SubType>Code</SubType>
|
||||
@@ -94,6 +95,7 @@
|
||||
<Compile Include="BigEndianBinaryReader.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Boxer.cs" />
|
||||
<Compile Include="ByteCode.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -120,6 +122,7 @@
|
||||
<Compile Include="DynamicClassLoader.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DynamicMethodUtils.cs" />
|
||||
<Compile Include="DynamicTypeWrapper.cs" />
|
||||
<Compile Include="ExceptionHelper.cs">
|
||||
<SubType>Code</SubType>
|
||||
@@ -141,15 +144,28 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="JsrInliner.cs" />
|
||||
<Compile Include="LambdaMetafactory.cs" />
|
||||
<Compile Include="LocalVars.cs" />
|
||||
<Compile Include="MemberWrapper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="openjdk.cs" />
|
||||
<Compile Include="MethodHandleUtil.cs" />
|
||||
<Compile Include="openjdk\java.io.cs" />
|
||||
<Compile Include="openjdk\java.lang.cs" />
|
||||
<Compile Include="openjdk\java.lang.invoke.cs" />
|
||||
<Compile Include="openjdk\java.lang.reflect.cs" />
|
||||
<Compile Include="openjdk\java.net.cs" />
|
||||
<Compile Include="openjdk\java.nio.cs" />
|
||||
<Compile Include="openjdk\java.security.cs" />
|
||||
<Compile Include="openjdk\java.util.cs" />
|
||||
<Compile Include="openjdk\java.util.prefs.cs" />
|
||||
<Compile Include="openjdk\misc.cs" />
|
||||
<Compile Include="openjdk\sun.management.cs" />
|
||||
<Compile Include="openjdk\sun.misc.cs" />
|
||||
<Compile Include="openjdk\sun.nio.ch.cs" />
|
||||
<Compile Include="openjdk\sun.reflect.cs" />
|
||||
<Compile Include="openjdk\sun.security.krb5.cs" />
|
||||
<Compile Include="openjdk\sun.util.locale.provider.cs" />
|
||||
<Compile Include="PassiveWeakDictionary.cs" />
|
||||
<Compile Include="profiler.cs">
|
||||
<SubType>Code</SubType>
|
||||
|
17
external/ikvm/runtime/JavaException.cs
vendored
17
external/ikvm/runtime/JavaException.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Jeroen Frijters
|
||||
Copyright (C) 2002-2014 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
|
||||
@@ -216,3 +216,18 @@ sealed class UnsupportedClassVersionError : ClassFormatError
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
sealed class JavaSecurityException : RetargetableJavaException
|
||||
{
|
||||
internal JavaSecurityException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
|
||||
internal override Exception ToJava()
|
||||
{
|
||||
return new java.lang.SecurityException(Message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
1024
external/ikvm/runtime/LambdaMetafactory.cs
vendored
Normal file
1024
external/ikvm/runtime/LambdaMetafactory.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
17
external/ikvm/runtime/Serialization.cs
vendored
17
external/ikvm/runtime/Serialization.cs
vendored
@@ -52,6 +52,11 @@ namespace IKVM.Internal
|
||||
psetSerializationFormatter.AddPermission(new SecurityPermission(SecurityPermissionFlag.SerializationFormatter));
|
||||
}
|
||||
|
||||
internal static bool IsISerializable(TypeWrapper wrapper)
|
||||
{
|
||||
return wrapper == iserializable;
|
||||
}
|
||||
|
||||
private static bool IsSafeForAutomagicSerialization(TypeWrapper wrapper)
|
||||
{
|
||||
if (wrapper.TypeAsBaseType.IsSerializable)
|
||||
@@ -147,15 +152,21 @@ namespace IKVM.Internal
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void MarkSerializable(TypeBuilder tb)
|
||||
internal static void MarkSerializable(TypeBuilder tb)
|
||||
{
|
||||
tb.SetCustomAttribute(serializableAttribute);
|
||||
}
|
||||
|
||||
private static void AddGetObjectData(TypeBuilder tb)
|
||||
internal static void AddGetObjectData(TypeBuilder tb)
|
||||
{
|
||||
string name = tb.IsSealed
|
||||
? "System.Runtime.Serialization.ISerializable.GetObjectData"
|
||||
: "GetObjectData";
|
||||
MethodAttributes attr = tb.IsSealed
|
||||
? MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.Final
|
||||
: MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.CheckAccessOnOverride;
|
||||
tb.AddInterfaceImplementation(JVM.Import(typeof(ISerializable)));
|
||||
MethodBuilder getObjectData = tb.DefineMethod("GetObjectData", MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.NewSlot, null,
|
||||
MethodBuilder getObjectData = tb.DefineMethod(name, attr, null,
|
||||
new Type[] { JVM.Import(typeof(SerializationInfo)), JVM.Import(typeof(StreamingContext)) });
|
||||
getObjectData.SetCustomAttribute(securityCriticalAttribute);
|
||||
AttributeHelper.HideFromJava(getObjectData);
|
||||
|
@@ -1 +1 @@
|
||||
3ed1d9cc7e683c9f379f858859a155d3b4c778a1
|
||||
fabd1aa5c712bc82971cd56b6f8a9d6cf648740c
|
214
external/ikvm/runtime/attributes.cs
vendored
214
external/ikvm/runtime/attributes.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002-2011 Jeroen Frijters
|
||||
Copyright (C) 2002-2014 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
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using IKVM.Internal;
|
||||
#if STATIC_COMPILER || STUB_GENERATOR
|
||||
using IKVM.Reflection;
|
||||
using Type = IKVM.Reflection.Type;
|
||||
@@ -388,7 +390,7 @@ namespace IKVM.Attributes
|
||||
|
||||
public JavaModuleAttribute(string[] classMap)
|
||||
{
|
||||
this.classMap = classMap;
|
||||
this.classMap = UnicodeUtil.UnescapeInvalidSurrogates(classMap);
|
||||
}
|
||||
|
||||
public string[] GetClassMap()
|
||||
@@ -418,11 +420,33 @@ namespace IKVM.Attributes
|
||||
[AttributeUsage(AttributeTargets.All)]
|
||||
public sealed class HideFromJavaAttribute : Attribute
|
||||
{
|
||||
private readonly HideFromJavaFlags flags;
|
||||
|
||||
public HideFromJavaAttribute()
|
||||
{
|
||||
flags = HideFromJavaFlags.All;
|
||||
}
|
||||
|
||||
public HideFromJavaAttribute(HideFromJavaFlags flags)
|
||||
{
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public HideFromJavaFlags Flags
|
||||
{
|
||||
get { return flags; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public sealed class HideFromReflectionAttribute : Attribute
|
||||
[Flags]
|
||||
public enum HideFromJavaFlags : byte
|
||||
{
|
||||
All = Code | Reflection | StackWalk | StackTrace,
|
||||
None = 0,
|
||||
Code = 1,
|
||||
Reflection = 2,
|
||||
StackWalk = 4, // used for LambdaForm$Compiled
|
||||
StackTrace = 8, // used for LambdaForm$Hidden
|
||||
}
|
||||
|
||||
[Flags]
|
||||
@@ -493,8 +517,8 @@ namespace IKVM.Attributes
|
||||
|
||||
public NameSigAttribute(string name, string sig)
|
||||
{
|
||||
this.name = name;
|
||||
this.sig = sig;
|
||||
this.name = UnicodeUtil.UnescapeInvalidSurrogates(name);
|
||||
this.sig = UnicodeUtil.UnescapeInvalidSurrogates(sig);
|
||||
}
|
||||
|
||||
public string Name
|
||||
@@ -523,7 +547,7 @@ namespace IKVM.Attributes
|
||||
// this constructor is used by ikvmc, the other constructors are for use in other .NET languages
|
||||
public ThrowsAttribute(string[] classes)
|
||||
{
|
||||
this.classes = classes;
|
||||
this.classes = UnicodeUtil.UnescapeInvalidSurrogates(classes);
|
||||
}
|
||||
|
||||
public ThrowsAttribute(Type type)
|
||||
@@ -555,7 +579,7 @@ namespace IKVM.Attributes
|
||||
// NOTE this is not CLS compliant, so maybe we should have a couple of overloads
|
||||
public ImplementsAttribute(string[] interfaces)
|
||||
{
|
||||
this.interfaces = interfaces;
|
||||
this.interfaces = UnicodeUtil.UnescapeInvalidSurrogates(interfaces);
|
||||
}
|
||||
|
||||
public string[] Interfaces
|
||||
@@ -577,7 +601,7 @@ namespace IKVM.Attributes
|
||||
|
||||
public InnerClassAttribute(string innerClassName, Modifiers modifiers)
|
||||
{
|
||||
this.innerClassName = innerClassName;
|
||||
this.innerClassName = UnicodeUtil.UnescapeInvalidSurrogates(innerClassName);
|
||||
this.modifiers = modifiers;
|
||||
}
|
||||
|
||||
@@ -605,7 +629,7 @@ namespace IKVM.Attributes
|
||||
|
||||
public NonNestedInnerClassAttribute(string innerClassName)
|
||||
{
|
||||
this.innerClassName = innerClassName;
|
||||
this.innerClassName = UnicodeUtil.UnescapeInvalidSurrogates(innerClassName);
|
||||
}
|
||||
|
||||
public string InnerClassName
|
||||
@@ -624,7 +648,7 @@ namespace IKVM.Attributes
|
||||
|
||||
public NonNestedOuterClassAttribute(string outerClassName)
|
||||
{
|
||||
this.outerClassName = outerClassName;
|
||||
this.outerClassName = UnicodeUtil.UnescapeInvalidSurrogates(outerClassName);
|
||||
}
|
||||
|
||||
public string OuterClassName
|
||||
@@ -662,7 +686,7 @@ namespace IKVM.Attributes
|
||||
|
||||
public SignatureAttribute(string signature)
|
||||
{
|
||||
this.signature = signature;
|
||||
this.signature = UnicodeUtil.UnescapeInvalidSurrogates(signature);
|
||||
}
|
||||
|
||||
public string Signature
|
||||
@@ -683,9 +707,9 @@ namespace IKVM.Attributes
|
||||
|
||||
public EnclosingMethodAttribute(string className, string methodName, string methodSig)
|
||||
{
|
||||
this.className = className;
|
||||
this.methodName = methodName;
|
||||
this.methodSig = methodSig;
|
||||
this.className = UnicodeUtil.UnescapeInvalidSurrogates(className);
|
||||
this.methodName = UnicodeUtil.UnescapeInvalidSurrogates(methodName);
|
||||
this.methodSig = UnicodeUtil.UnescapeInvalidSurrogates(methodSig);
|
||||
}
|
||||
|
||||
internal EnclosingMethodAttribute SetClassName(Type type)
|
||||
@@ -749,7 +773,7 @@ namespace IKVM.Attributes
|
||||
// new object[] { (byte)'?', "<exceptionClass>", "<exceptionMessage>" }
|
||||
public AnnotationDefaultAttribute(object defaultValue)
|
||||
{
|
||||
this.defaultValue = defaultValue;
|
||||
this.defaultValue = Unescape(defaultValue);
|
||||
}
|
||||
|
||||
public object Value
|
||||
@@ -759,6 +783,36 @@ namespace IKVM.Attributes
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
internal static object Escape(object obj)
|
||||
{
|
||||
return EscapeOrUnescape(obj, true);
|
||||
}
|
||||
|
||||
internal static object Unescape(object obj)
|
||||
{
|
||||
return EscapeOrUnescape(obj, false);
|
||||
}
|
||||
|
||||
private static object EscapeOrUnescape(object obj, bool escape)
|
||||
{
|
||||
string str = obj as string;
|
||||
if (str != null)
|
||||
{
|
||||
return escape
|
||||
? UnicodeUtil.EscapeInvalidSurrogates(str)
|
||||
: UnicodeUtil.UnescapeInvalidSurrogates(str);
|
||||
}
|
||||
object[] arr = obj as object[];
|
||||
if (arr != null)
|
||||
{
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
arr[i] = EscapeOrUnescape(arr[i], escape);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Interface)]
|
||||
@@ -768,7 +822,7 @@ namespace IKVM.Attributes
|
||||
|
||||
public AnnotationAttributeAttribute(string attributeType)
|
||||
{
|
||||
this.attributeType = attributeType;
|
||||
this.attributeType = UnicodeUtil.UnescapeInvalidSurrogates(attributeType);
|
||||
}
|
||||
|
||||
public string AttributeType
|
||||
@@ -780,14 +834,16 @@ namespace IKVM.Attributes
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Module)]
|
||||
[AttributeUsage(AttributeTargets.Module, AllowMultiple = true)]
|
||||
public sealed class PackageListAttribute : Attribute
|
||||
{
|
||||
private string[] packages;
|
||||
internal string jar;
|
||||
internal string[] packages;
|
||||
|
||||
public PackageListAttribute(string[] packages)
|
||||
public PackageListAttribute(string jar, string[] packages)
|
||||
{
|
||||
this.packages = packages;
|
||||
this.jar = jar;
|
||||
this.packages = UnicodeUtil.UnescapeInvalidSurrogates(packages);
|
||||
}
|
||||
|
||||
public string[] GetPackages()
|
||||
@@ -826,7 +882,7 @@ namespace IKVM.Attributes
|
||||
|
||||
public DynamicAnnotationAttribute(object[] definition)
|
||||
{
|
||||
this.definition = definition;
|
||||
this.definition = (object[])AnnotationDefaultAttribute.Unescape(definition);
|
||||
}
|
||||
|
||||
public object[] Definition
|
||||
@@ -835,6 +891,120 @@ namespace IKVM.Attributes
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor)]
|
||||
public sealed class MethodParametersAttribute : Attribute
|
||||
{
|
||||
private readonly Modifiers[] modifiers;
|
||||
|
||||
public MethodParametersAttribute(Modifiers[] modifiers)
|
||||
{
|
||||
this.modifiers = modifiers;
|
||||
}
|
||||
|
||||
public Modifiers[] Modifiers
|
||||
{
|
||||
get { return modifiers; }
|
||||
}
|
||||
|
||||
public bool IsMalformed
|
||||
{
|
||||
get { return modifiers == null; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
|
||||
public sealed class ConstantPoolAttribute : Attribute
|
||||
{
|
||||
internal readonly object[] constantPool;
|
||||
|
||||
public ConstantPoolAttribute(object[] constantPool)
|
||||
{
|
||||
this.constantPool = Decompress(constantPool);
|
||||
}
|
||||
|
||||
internal static object[] Decompress(object[] constantPool)
|
||||
{
|
||||
List<object> list = new List<object>();
|
||||
foreach (object obj in constantPool)
|
||||
{
|
||||
int emptySlots = obj as byte? ?? obj as ushort? ?? 0;
|
||||
if (emptySlots == 0)
|
||||
{
|
||||
list.Add(Unescape(obj));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < emptySlots; i++)
|
||||
{
|
||||
list.Add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static object Unescape(object obj)
|
||||
{
|
||||
string str = obj as string;
|
||||
if (str != null)
|
||||
{
|
||||
obj = UnicodeUtil.UnescapeInvalidSurrogates(str);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
internal static object[] Compress(object[] constantPool, bool[] inUse)
|
||||
{
|
||||
int length = constantPool.Length;
|
||||
while (!inUse[length - 1])
|
||||
{
|
||||
length--;
|
||||
}
|
||||
int write = 0;
|
||||
for (int read = 0; read < length; read++)
|
||||
{
|
||||
int start = read;
|
||||
while (!inUse[read])
|
||||
{
|
||||
read++;
|
||||
}
|
||||
int emptySlots = read - start;
|
||||
if (emptySlots > 255)
|
||||
{
|
||||
constantPool[write++] = (ushort)emptySlots;
|
||||
}
|
||||
else if (emptySlots > 0)
|
||||
{
|
||||
constantPool[write++] = (byte)emptySlots;
|
||||
}
|
||||
constantPool[write++] = Escape(constantPool[read]);
|
||||
}
|
||||
Array.Resize(ref constantPool, write);
|
||||
return constantPool;
|
||||
}
|
||||
|
||||
private static object Escape(object obj)
|
||||
{
|
||||
string str = obj as string;
|
||||
if (str != null)
|
||||
{
|
||||
obj = UnicodeUtil.EscapeInvalidSurrogates(str);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field)]
|
||||
public sealed class RuntimeVisibleTypeAnnotationsAttribute : Attribute
|
||||
{
|
||||
internal readonly byte[] data;
|
||||
|
||||
public RuntimeVisibleTypeAnnotationsAttribute(byte[] data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
// used in custom modifier for access stubs
|
||||
public static class AccessStub { }
|
||||
}
|
||||
|
124
external/ikvm/runtime/common.cs
vendored
124
external/ikvm/runtime/common.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002-2007, 2010 Jeroen Frijters
|
||||
Copyright (C) 2002-2014 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
|
||||
@@ -25,6 +25,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using IKVM.Attributes;
|
||||
using IKVM.Runtime;
|
||||
using IKVM.Internal;
|
||||
@@ -49,7 +50,7 @@ namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
|
||||
MemoryStream mem = new MemoryStream();
|
||||
#if !FIRST_PASS
|
||||
bool includeNonPublicInterfaces = !"true".Equals(global::java.lang.Props.props.getProperty("ikvm.stubgen.skipNonPublicInterfaces"), StringComparison.OrdinalIgnoreCase);
|
||||
IKVM.StubGen.StubGenerator.WriteClass(mem, TypeWrapper.FromClass(c), includeNonPublicInterfaces, false, false, false);
|
||||
IKVM.StubGen.StubGenerator.WriteClass(mem, TypeWrapper.FromClass(c), includeNonPublicInterfaces, false, false, true);
|
||||
#endif
|
||||
return mem.ToArray();
|
||||
}
|
||||
@@ -119,6 +120,53 @@ namespace IKVM.NativeCode.java.lang
|
||||
{
|
||||
return VirtualFileSystem.GetAssemblyClassesPath(JVM.CoreAssembly);
|
||||
}
|
||||
|
||||
public static string getStdoutEncoding()
|
||||
{
|
||||
return IsWindowsConsole(true) ? GetConsoleEncoding() : null;
|
||||
}
|
||||
|
||||
public static string getStderrEncoding()
|
||||
{
|
||||
return IsWindowsConsole(false) ? GetConsoleEncoding() : null;
|
||||
}
|
||||
|
||||
private static bool IsWindowsConsole(bool stdout)
|
||||
{
|
||||
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// these properties are available starting with .NET 4.5
|
||||
PropertyInfo pi = typeof(Console).GetProperty(stdout ? "IsOutputRedirected" : "IsErrorRedirected");
|
||||
if (pi != null)
|
||||
{
|
||||
return !(bool)pi.GetValue(null, null);
|
||||
}
|
||||
const int STD_OUTPUT_HANDLE = -11;
|
||||
const int STD_ERROR_HANDLE = -12;
|
||||
IntPtr handle = GetStdHandle(stdout ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const int FILE_TYPE_CHAR = 2;
|
||||
return GetFileType(handle) == FILE_TYPE_CHAR;
|
||||
}
|
||||
|
||||
private static string GetConsoleEncoding()
|
||||
{
|
||||
int codepage = Console.InputEncoding.CodePage;
|
||||
return codepage >= 847 && codepage <= 950
|
||||
? "ms" + codepage
|
||||
: "cp" + codepage;
|
||||
}
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern int GetFileType(IntPtr hFile);
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern IntPtr GetStdHandle(int nStdHandle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +192,11 @@ namespace IKVM.NativeCode.ikvm.@internal
|
||||
|
||||
static class AnnotationAttributeBase
|
||||
{
|
||||
public static object[] unescapeInvalidSurrogates(object[] def)
|
||||
{
|
||||
return (object[])AnnotationDefaultAttribute.Unescape(def);
|
||||
}
|
||||
|
||||
public static object newAnnotationInvocationHandler(jlClass type, object memberValues)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
@@ -271,25 +324,6 @@ namespace IKVM.NativeCode.ikvm.runtime
|
||||
return null;
|
||||
}
|
||||
|
||||
private static global::java.util.jar.Manifest GetManifest(global::java.lang.ClassLoader _this)
|
||||
{
|
||||
try
|
||||
{
|
||||
global::java.net.URL url = findResource(_this, "META-INF/MANIFEST.MF");
|
||||
if (url != null)
|
||||
{
|
||||
return new global::java.util.jar.Manifest(url.openStream());
|
||||
}
|
||||
}
|
||||
catch (global::java.net.MalformedURLException)
|
||||
{
|
||||
}
|
||||
catch (global::java.io.IOException)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetAttributeValue(global::java.util.jar.Attributes.Name name, global::java.util.jar.Attributes first, global::java.util.jar.Attributes second)
|
||||
{
|
||||
string result = null;
|
||||
@@ -310,31 +344,37 @@ namespace IKVM.NativeCode.ikvm.runtime
|
||||
#if !FIRST_PASS
|
||||
AssemblyClassLoader_ wrapper = (AssemblyClassLoader_)ClassLoaderWrapper.GetClassLoaderWrapper(_this);
|
||||
global::java.net.URL sealBase = GetCodeBase(wrapper.MainAssembly);
|
||||
global::java.util.jar.Manifest manifest = GetManifest(_this);
|
||||
global::java.util.jar.Attributes attr = null;
|
||||
if (manifest != null)
|
||||
foreach (KeyValuePair<string, string[]> packages in wrapper.GetPackageInfo())
|
||||
{
|
||||
attr = manifest.getMainAttributes();
|
||||
}
|
||||
string[] packages = wrapper.GetPackages();
|
||||
for (int i = 0; i < packages.Length; i++)
|
||||
{
|
||||
string name = packages[i];
|
||||
if (_this.getPackage(name) == null)
|
||||
global::java.util.jar.Manifest manifest = null;
|
||||
global::java.util.jar.Attributes attr = null;
|
||||
if (packages.Key != null)
|
||||
{
|
||||
global::java.util.jar.Attributes entryAttr = null;
|
||||
if (manifest != null)
|
||||
global::java.util.jar.JarFile jarFile = new global::java.util.jar.JarFile(VirtualFileSystem.GetAssemblyResourcesPath(wrapper.MainAssembly) + packages.Key);
|
||||
manifest = jarFile.getManifest();
|
||||
}
|
||||
if (manifest != null)
|
||||
{
|
||||
attr = manifest.getMainAttributes();
|
||||
}
|
||||
foreach (string name in packages.Value)
|
||||
{
|
||||
if (_this.getPackage(name) == null)
|
||||
{
|
||||
entryAttr = manifest.getAttributes(name.Replace('.', '/') + '/');
|
||||
global::java.util.jar.Attributes entryAttr = null;
|
||||
if (manifest != null)
|
||||
{
|
||||
entryAttr = manifest.getAttributes(name.Replace('.', '/') + '/');
|
||||
}
|
||||
_this.definePackage(name,
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_TITLE, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_VERSION, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_VENDOR, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_TITLE, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_VERSION, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_VENDOR, entryAttr, attr),
|
||||
"true".Equals(GetAttributeValue(global::java.util.jar.Attributes.Name.SEALED, entryAttr, attr), StringComparison.OrdinalIgnoreCase) ? sealBase : null);
|
||||
}
|
||||
_this.definePackage(name,
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_TITLE, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_VERSION, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_VENDOR, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_TITLE, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_VERSION, entryAttr, attr),
|
||||
GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_VENDOR, entryAttr, attr),
|
||||
"true".Equals(GetAttributeValue(global::java.util.jar.Attributes.Name.SEALED, entryAttr, attr), StringComparison.OrdinalIgnoreCase) ? sealBase : null);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -1 +1 @@
|
||||
8b8a30e4b47038b6fae92d434aa386871005e4fb
|
||||
e38729f8e1419779787415d4fd6aa39532dbfcf7
|
1371
external/ikvm/runtime/openjdk/java.io.cs
vendored
Normal file
1371
external/ikvm/runtime/openjdk/java.io.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
179
external/ikvm/runtime/openjdk/java.lang.cs
vendored
179
external/ikvm/runtime/openjdk/java.lang.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2007-2013 Jeroen Frijters
|
||||
Copyright (C) 2007-2014 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
|
||||
@@ -96,6 +96,57 @@ static class Java_java_lang_Class
|
||||
#endif
|
||||
}
|
||||
|
||||
public static byte[] getRawTypeAnnotations(java.lang.Class thisClass)
|
||||
{
|
||||
return TypeWrapper.FromClass(thisClass).GetRawTypeAnnotations();
|
||||
}
|
||||
|
||||
#if !FIRST_PASS
|
||||
private sealed class ConstantPoolImpl : sun.reflect.ConstantPool
|
||||
{
|
||||
private readonly object[] constantPool;
|
||||
|
||||
internal ConstantPoolImpl(object[] constantPool)
|
||||
{
|
||||
this.constantPool = constantPool;
|
||||
}
|
||||
|
||||
public override string getUTF8At(int index)
|
||||
{
|
||||
return (string)constantPool[index];
|
||||
}
|
||||
|
||||
public override int getIntAt(int index)
|
||||
{
|
||||
return (int)constantPool[index];
|
||||
}
|
||||
|
||||
public override long getLongAt(int index)
|
||||
{
|
||||
return (long)constantPool[index];
|
||||
}
|
||||
|
||||
public override float getFloatAt(int index)
|
||||
{
|
||||
return (float)constantPool[index];
|
||||
}
|
||||
|
||||
public override double getDoubleAt(int index)
|
||||
{
|
||||
return (double)constantPool[index];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public static object getConstantPool(java.lang.Class thisClass)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
return new ConstantPoolImpl(TypeWrapper.FromClass(thisClass).GetConstantPool());
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool isInstance(java.lang.Class thisClass, object obj)
|
||||
{
|
||||
return TypeWrapper.FromClass(thisClass).IsInstance(obj);
|
||||
@@ -169,6 +220,14 @@ static class Java_java_lang_Class
|
||||
return "void";
|
||||
}
|
||||
}
|
||||
if (tw.IsUnsafeAnonymous)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
// for OpenJDK compatibility and debugging convenience we modify the class name to
|
||||
// include the identity hashcode of the class object
|
||||
return tw.Name + "/" + java.lang.System.identityHashCode(thisClass);
|
||||
#endif
|
||||
}
|
||||
return tw.Name;
|
||||
}
|
||||
|
||||
@@ -188,7 +247,7 @@ static class Java_java_lang_Class
|
||||
return super != null ? super.ClassObject : null;
|
||||
}
|
||||
|
||||
public static java.lang.Class[] getInterfaces(java.lang.Class thisClass)
|
||||
public static java.lang.Class[] getInterfaces0(java.lang.Class thisClass)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
@@ -252,7 +311,7 @@ static class Java_java_lang_Class
|
||||
}
|
||||
}
|
||||
|
||||
public static java.lang.Class getDeclaringClass(java.lang.Class thisClass)
|
||||
public static java.lang.Class getDeclaringClass0(java.lang.Class thisClass)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -286,9 +345,9 @@ static class Java_java_lang_Class
|
||||
return null;
|
||||
#else
|
||||
TypeWrapper wrapper = TypeWrapper.FromClass(thisClass);
|
||||
while (wrapper.IsArray)
|
||||
if (wrapper.IsArray)
|
||||
{
|
||||
wrapper = wrapper.ElementTypeWrapper;
|
||||
return null;
|
||||
}
|
||||
java.security.ProtectionDomain pd = wrapper.ClassObject.pd;
|
||||
if (pd == null)
|
||||
@@ -300,18 +359,17 @@ static class Java_java_lang_Class
|
||||
{
|
||||
pd = acl.GetProtectionDomain();
|
||||
}
|
||||
else if (wrapper is AnonymousTypeWrapper)
|
||||
{
|
||||
// dynamically compiled intrinsified lamdba anonymous types end up here and should get their
|
||||
// protection domain from the host class
|
||||
pd = ClassLoaderWrapper.GetWrapperFromType(wrapper.TypeAsTBD.DeclaringType).ClassObject.pd;
|
||||
}
|
||||
}
|
||||
return pd;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setProtectionDomain0(java.lang.Class thisClass, java.security.ProtectionDomain pd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
thisClass.pd = pd;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static java.lang.Class getPrimitiveClass(string name)
|
||||
{
|
||||
// note that this method isn't used anymore (because it is an intrinsic (during core class library compilation))
|
||||
@@ -341,7 +399,7 @@ static class Java_java_lang_Class
|
||||
}
|
||||
}
|
||||
|
||||
public static string getGenericSignature(java.lang.Class thisClass)
|
||||
public static string getGenericSignature0(java.lang.Class thisClass)
|
||||
{
|
||||
TypeWrapper tw = TypeWrapper.FromClass(thisClass);
|
||||
tw.Finish();
|
||||
@@ -620,16 +678,7 @@ static class Java_java_lang_ClassLoader
|
||||
try
|
||||
{
|
||||
ClassLoaderWrapper classLoaderWrapper = ClassLoaderWrapper.GetClassLoaderWrapper(thisClassLoader);
|
||||
ClassFileParseOptions cfp = ClassFileParseOptions.LineNumberTable;
|
||||
if (classLoaderWrapper.EmitDebugInfo)
|
||||
{
|
||||
cfp |= ClassFileParseOptions.LocalVariableTable;
|
||||
}
|
||||
if (classLoaderWrapper.RelaxedClassNameValidation)
|
||||
{
|
||||
cfp |= ClassFileParseOptions.RelaxedClassNameValidation;
|
||||
}
|
||||
ClassFile classFile = new ClassFile(b, off, len, name, cfp);
|
||||
ClassFile classFile = new ClassFile(b, off, len, name, classLoaderWrapper.ClassFileParseOptions, null);
|
||||
if (name != null && classFile.Name != name)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
@@ -703,13 +752,13 @@ static class Java_java_lang_ClassLoader
|
||||
|
||||
static class Java_java_lang_ClassLoader_00024NativeLibrary
|
||||
{
|
||||
public static void load(object thisNativeLibrary, string name)
|
||||
public static void load(object thisNativeLibrary, string name, bool isBuiltin)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
if (VirtualFileSystem.IsVirtualFS(name))
|
||||
{
|
||||
// we fake success for native libraries loaded from VFS
|
||||
((java.lang.ClassLoader.NativeLibrary)thisNativeLibrary).handle = -1;
|
||||
((java.lang.ClassLoader.NativeLibrary)thisNativeLibrary).loaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -725,7 +774,8 @@ static class Java_java_lang_ClassLoader_00024NativeLibrary
|
||||
private static void doLoad(object thisNativeLibrary, string name)
|
||||
{
|
||||
java.lang.ClassLoader.NativeLibrary lib = (java.lang.ClassLoader.NativeLibrary)thisNativeLibrary;
|
||||
lib.handle = IKVM.Runtime.JniHelper.LoadLibrary(name, TypeWrapper.FromClass(lib.fromClass).GetClassLoader());
|
||||
lib.handle = IKVM.Runtime.JniHelper.LoadLibrary(name, TypeWrapper.FromClass(java.lang.ClassLoader.NativeLibrary.getFromClass()).GetClassLoader());
|
||||
lib.loaded = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -736,17 +786,22 @@ static class Java_java_lang_ClassLoader_00024NativeLibrary
|
||||
}
|
||||
|
||||
[SecuritySafeCritical]
|
||||
public static void unload(object thisNativeLibrary)
|
||||
public static void unload(object thisNativeLibrary, string name, bool isBuiltin)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
java.lang.ClassLoader.NativeLibrary lib = (java.lang.ClassLoader.NativeLibrary)thisNativeLibrary;
|
||||
long handle = Interlocked.Exchange(ref lib.handle, 0);
|
||||
if (handle != 0)
|
||||
{
|
||||
IKVM.Runtime.JniHelper.UnloadLibrary(handle, TypeWrapper.FromClass(lib.fromClass).GetClassLoader());
|
||||
IKVM.Runtime.JniHelper.UnloadLibrary(handle, TypeWrapper.FromClass(java.lang.ClassLoader.NativeLibrary.getFromClass()).GetClassLoader());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string findBuiltinLib(string name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_Compiler
|
||||
@@ -823,9 +878,12 @@ static class Java_java_lang_Package
|
||||
{
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
string path = VirtualFileSystem.GetAssemblyResourcesPath(JVM.CoreAssembly) + "resources.jar";
|
||||
foreach (string pkg in ClassLoaderWrapper.GetBootstrapClassLoader().GetPackages())
|
||||
foreach (KeyValuePair<string, string[]> pkgs in ClassLoaderWrapper.GetBootstrapClassLoader().GetPackageInfo())
|
||||
{
|
||||
dict[pkg.Replace('.', '/') + "/"] = path;
|
||||
foreach (string pkg in pkgs.Value)
|
||||
{
|
||||
dict[pkg.Replace('.', '/') + "/"] = path;
|
||||
}
|
||||
}
|
||||
Interlocked.CompareExchange(ref systemPackages, dict, null);
|
||||
}
|
||||
@@ -927,18 +985,11 @@ static class Java_java_lang_SecurityManager
|
||||
{
|
||||
StackFrame frame = trace.GetFrame(i);
|
||||
MethodBase method = frame.GetMethod();
|
||||
Type type = method.DeclaringType;
|
||||
// NOTE these checks should be the same as the ones in Reflection.getCallerClass
|
||||
if (Java_sun_reflect_Reflection.IsHideFromJava(method)
|
||||
|| type == null
|
||||
|| type.Assembly == typeof(object).Assembly
|
||||
|| type.Assembly == typeof(Java_java_lang_SecurityManager).Assembly
|
||||
|| type.Assembly == jniAssembly
|
||||
|| type == typeof(java.lang.reflect.Constructor)
|
||||
|| type == typeof(java.lang.reflect.Method))
|
||||
if (Java_sun_reflect_Reflection.IsHideFromStackWalk(method))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Type type = method.DeclaringType;
|
||||
if (type == typeof(java.lang.SecurityManager))
|
||||
{
|
||||
continue;
|
||||
@@ -1068,20 +1119,6 @@ static class Java_java_lang_StrictMath
|
||||
#endif
|
||||
}
|
||||
|
||||
public static double ceil(double d)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return ikvm.@internal.JMath.ceil(d);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static double floor(double d)
|
||||
{
|
||||
return fdlibm.floor(d);
|
||||
}
|
||||
|
||||
public static double atan2(double y, double x)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
@@ -1111,15 +1148,6 @@ static class Java_java_lang_StrictMath
|
||||
return Math.Tanh(d);
|
||||
}
|
||||
|
||||
public static double rint(double d)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return ikvm.@internal.JMath.rint(d);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static double hypot(double a, double b)
|
||||
{
|
||||
return fdlibm.__ieee754_hypot(a, b);
|
||||
@@ -1223,9 +1251,14 @@ static class Java_java_lang_ProcessImpl
|
||||
{
|
||||
public static string mapVfsExecutable(string path)
|
||||
{
|
||||
if (VirtualFileSystem.IsVirtualFS(path))
|
||||
string unquoted = path;
|
||||
if (unquoted.Length > 2 && unquoted[0] == '"' && unquoted[unquoted.Length - 1] == '"')
|
||||
{
|
||||
return VirtualFileSystem.MapExecutable(path);
|
||||
unquoted = unquoted.Substring(1, unquoted.Length - 2);
|
||||
}
|
||||
if (VirtualFileSystem.IsVirtualFS(unquoted))
|
||||
{
|
||||
return VirtualFileSystem.MapExecutable(unquoted);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
@@ -1250,7 +1283,7 @@ static class Java_java_lang_ProcessImpl
|
||||
for (; ; )
|
||||
{
|
||||
string str = cmdstr.Substring(0, pos);
|
||||
if (Path.IsPathRooted(str))
|
||||
if (IsPathRooted(str))
|
||||
{
|
||||
if (Exists(str))
|
||||
{
|
||||
@@ -1303,6 +1336,18 @@ static class Java_java_lang_ProcessImpl
|
||||
return list;
|
||||
}
|
||||
|
||||
private static bool IsPathRooted(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Path.IsPathRooted(path);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Exists(string file)
|
||||
{
|
||||
try
|
||||
@@ -1319,6 +1364,10 @@ static class Java_java_lang_ProcessImpl
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (mapVfsExecutable(file) != file)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
|
@@ -689,6 +689,8 @@ static class Java_java_lang_reflect_Proxy
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// we need to explicitly register the type, because the type isn't visible by normal means
|
||||
tw.GetClassLoader().SetWrapperForType(type, tw);
|
||||
TypeWrapper[] wrappers2 = tw.Interfaces;
|
||||
if (wrappers.Length != wrappers.Length)
|
||||
{
|
||||
@@ -705,29 +707,50 @@ static class Java_java_lang_reflect_Proxy
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_reflect_Field
|
||||
static class Java_java_lang_reflect_Executable
|
||||
{
|
||||
public static object getDeclaredAnnotationsImpl(java.lang.reflect.Field thisField)
|
||||
{
|
||||
FieldWrapper fw = FieldWrapper.FromField(thisField);
|
||||
return Java_java_lang_Class.AnnotationsToMap(fw.DeclaringType.GetClassLoader(), fw.DeclaringType.GetFieldAnnotations(fw));
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_reflect_Method
|
||||
{
|
||||
public static object getDeclaredAnnotationsImpl(object methodOrConstructor)
|
||||
{
|
||||
MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(methodOrConstructor);
|
||||
return Java_java_lang_Class.AnnotationsToMap(mw.DeclaringType.GetClassLoader(), mw.DeclaringType.GetMethodAnnotations(mw));
|
||||
}
|
||||
|
||||
public static object[][] getParameterAnnotationsImpl(object methodOrConstructor)
|
||||
public static object[] getParameters0(java.lang.reflect.Executable _this)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(methodOrConstructor);
|
||||
MethodWrapper mw = MethodWrapper.FromExecutable(_this);
|
||||
MethodParametersEntry[] methodParameters = mw.DeclaringType.GetMethodParameters(mw);
|
||||
if (methodParameters == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (methodParameters == MethodParametersEntry.Malformed)
|
||||
{
|
||||
throw new java.lang.reflect.MalformedParametersException("Invalid constant pool index");
|
||||
}
|
||||
java.lang.reflect.Parameter[] parameters = new java.lang.reflect.Parameter[methodParameters.Length];
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
parameters[i] = new java.lang.reflect.Parameter(methodParameters[i].name ?? "", methodParameters[i].flags, _this, i);
|
||||
}
|
||||
return parameters;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static byte[] getTypeAnnotationBytes0(java.lang.reflect.Executable _this)
|
||||
{
|
||||
MethodWrapper mw = MethodWrapper.FromExecutable(_this);
|
||||
return mw.DeclaringType.GetMethodRawTypeAnnotations(mw);
|
||||
}
|
||||
|
||||
public static object declaredAnnotationsImpl(java.lang.reflect.Executable executable)
|
||||
{
|
||||
MethodWrapper mw = MethodWrapper.FromExecutable(executable);
|
||||
return Java_java_lang_Class.AnnotationsToMap(mw.DeclaringType.GetClassLoader(), mw.DeclaringType.GetMethodAnnotations(mw));
|
||||
}
|
||||
|
||||
public static object[][] sharedGetParameterAnnotationsImpl(java.lang.reflect.Executable executable)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
MethodWrapper mw = MethodWrapper.FromExecutable(executable);
|
||||
object[][] objAnn = mw.DeclaringType.GetParameterAnnotations(mw);
|
||||
if (objAnn == null)
|
||||
{
|
||||
@@ -758,10 +781,28 @@ static class Java_java_lang_reflect_Method
|
||||
return ann;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_reflect_Field
|
||||
{
|
||||
public static object getDeclaredAnnotationsImpl(java.lang.reflect.Field thisField)
|
||||
{
|
||||
FieldWrapper fw = FieldWrapper.FromField(thisField);
|
||||
return Java_java_lang_Class.AnnotationsToMap(fw.DeclaringType.GetClassLoader(), fw.DeclaringType.GetFieldAnnotations(fw));
|
||||
}
|
||||
|
||||
public static byte[] getTypeAnnotationBytes0(java.lang.reflect.Field thisField)
|
||||
{
|
||||
FieldWrapper fw = FieldWrapper.FromField(thisField);
|
||||
return fw.DeclaringType.GetFieldRawTypeAnnotations(fw);
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_reflect_Method
|
||||
{
|
||||
public static object getDefaultValue(java.lang.reflect.Method thisMethod)
|
||||
{
|
||||
MethodWrapper mw = MethodWrapper.FromMethod(thisMethod);
|
||||
MethodWrapper mw = MethodWrapper.FromExecutable(thisMethod);
|
||||
return mw.DeclaringType.GetAnnotationDefault(mw);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user