зеркало из https://github.com/mono/ikvm-fork.git
*** empty log message ***
This commit is contained in:
Родитель
7561f45469
Коммит
0f2afcc4d6
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,13 +13,13 @@
|
|||
</target>
|
||||
|
||||
<target name="trunk">
|
||||
<property name="Classpath.dir" value="${project::get-base-directory()}/../../classpath" />
|
||||
<property name="Classpath.dir" value="${project::get-base-directory()}/../../classpath-0.93" />
|
||||
<property name="allsources" value="allsources.lst" />
|
||||
<call target="IKVM.GNU.Classpath.dll" />
|
||||
</target>
|
||||
|
||||
<target name="generics">
|
||||
<property name="Classpath.dir" value="${project::get-base-directory()}/../../classpath-generics" />
|
||||
<property name="Classpath.dir" value="${project::get-base-directory()}/../../classpath-0.93-generics" />
|
||||
<property name="allsources" value="allsources-generics.lst" />
|
||||
<call target="IKVM.GNU.Classpath.dll" />
|
||||
</target>
|
||||
|
|
|
@ -50,7 +50,7 @@ class IkvmresURLConnection extends URLConnection
|
|||
}
|
||||
try
|
||||
{
|
||||
inputStream = Handler.readResourceFromAssembly(assembly, resource);
|
||||
inputStream = Handler.readResourceFromAssembly(assembly, url.getPort(), resource);
|
||||
connected = true;
|
||||
}
|
||||
catch(cli.System.IO.FileNotFoundException x)
|
||||
|
@ -107,12 +107,27 @@ public class Handler extends URLStreamHandler
|
|||
private static final String RFC2396_SEGMENT = RFC2396_PCHAR + ";";
|
||||
private static final String RFC2396_PATH_SEGMENTS = RFC2396_SEGMENT + "/";
|
||||
|
||||
static InputStream readResourceFromAssembly(String assembly, String resource)
|
||||
static InputStream readResourceFromAssembly(String assembly, int port, String resource)
|
||||
throws cli.System.IO.FileNotFoundException,
|
||||
cli.System.BadImageFormatException,
|
||||
cli.System.Security.SecurityException,
|
||||
IOException
|
||||
{
|
||||
if(assembly.equals("gen") && port != -1 && resource.endsWith(".class") && resource.indexOf('.') == resource.length() - 6)
|
||||
{
|
||||
ClassLoader loader = GetGenericClassLoaderById(port);
|
||||
try
|
||||
{
|
||||
Class c = Class.forName(resource.substring(1, resource.length() - 6).replace('/', '.'), false, loader);
|
||||
return new ByteArrayInputStream(ikvm.internal.stubgen.StubGenerator.generateStub(c));
|
||||
}
|
||||
catch(ClassNotFoundException _)
|
||||
{
|
||||
}
|
||||
catch(LinkageError _)
|
||||
{
|
||||
}
|
||||
}
|
||||
return readResourceFromAssembly(LoadAssembly(assembly), resource);
|
||||
}
|
||||
|
||||
|
@ -152,6 +167,7 @@ public class Handler extends URLStreamHandler
|
|||
private static native Class LoadClassFromAssembly(Assembly asm, String className);
|
||||
private static native Assembly LoadAssembly(String name)
|
||||
throws cli.System.IO.FileNotFoundException, cli.System.BadImageFormatException, cli.System.Security.SecurityException;
|
||||
private static native ClassLoader GetGenericClassLoaderById(int id);
|
||||
|
||||
protected URLConnection openConnection(URL url) throws IOException
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.security.ProtectionDomain;
|
|||
@Internal
|
||||
public final class AssemblyClassLoader extends ClassLoader
|
||||
{
|
||||
// NOTE assembly is null for "generics" class loader instances
|
||||
private final Assembly assembly;
|
||||
private ProtectionDomain pd;
|
||||
private boolean packagesDefined;
|
||||
|
@ -127,7 +128,28 @@ public final class AssemblyClassLoader extends ClassLoader
|
|||
}
|
||||
if(c != null)
|
||||
{
|
||||
return makeIkvmresURL(GetClassAssembly(c), name);
|
||||
classLoader = (AssemblyClassLoader)c.getClassLoader();
|
||||
if(classLoader == null)
|
||||
{
|
||||
return makeIkvmresURL(GetBootClassLoaderAssembly(), name);
|
||||
}
|
||||
else if(classLoader.assembly != null)
|
||||
{
|
||||
return makeIkvmresURL(classLoader.assembly, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// HACK we use an index to identity the generic class loader in the url
|
||||
// TODO this obviously isn't persistable, we should use a list of assemblies instead.
|
||||
try
|
||||
{
|
||||
return new URL("ikvmres", "gen", GetGenericClassLoaderId(classLoader), "/" + name);
|
||||
}
|
||||
catch(MalformedURLException x)
|
||||
{
|
||||
throw (InternalError)new InternalError().initCause(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -135,7 +157,8 @@ public final class AssemblyClassLoader extends ClassLoader
|
|||
|
||||
private static native boolean IsReflectionOnly(Assembly asm);
|
||||
private static native Assembly[] FindResourceAssemblies(Object classLoader, String name, boolean firstOnly);
|
||||
private static native Assembly GetClassAssembly(Class c);
|
||||
private static native int GetGenericClassLoaderId(AssemblyClassLoader classLoader);
|
||||
private static native Assembly GetBootClassLoaderAssembly();
|
||||
// also used by VMClassLoader
|
||||
public static native String[] GetPackages(Object classLoader);
|
||||
|
||||
|
|
|
@ -128,6 +128,8 @@ class IkvmcCompiler
|
|||
Console.Error.WriteLine(" -recurse:<filespec> Recurse directory and include matching files");
|
||||
Console.Error.WriteLine(" -nojni Do not generate JNI stub for native methods");
|
||||
Console.Error.WriteLine(" -resource:<name>=<path> Include file as Java resource");
|
||||
Console.Error.WriteLine(" -externalresource:<name>=<path>");
|
||||
Console.Error.WriteLine(" Reference file as Java resource");
|
||||
Console.Error.WriteLine(" -exclude:<filename> A file containing a list of classes to exclude");
|
||||
Console.Error.WriteLine(" -debug Generate debug info for the output file");
|
||||
Console.Error.WriteLine(" (Note that this also causes the compiler to");
|
||||
|
@ -338,6 +340,26 @@ class IkvmcCompiler
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
else if(s.StartsWith("-externalresource:"))
|
||||
{
|
||||
string[] spec = s.Substring(18).Split('=');
|
||||
if(!File.Exists(spec[1]))
|
||||
{
|
||||
Console.Error.WriteLine("Error: external resource file does not exist: {0}", spec[1]);
|
||||
return 1;
|
||||
}
|
||||
if(Path.GetFileName(spec[1]) != spec[1])
|
||||
{
|
||||
Console.Error.WriteLine("Error: external resource file may not include path specification: {0}", spec[1]);
|
||||
return 1;
|
||||
}
|
||||
if(options.externalResources == null)
|
||||
{
|
||||
options.externalResources = new Hashtable();
|
||||
}
|
||||
// TODO resource name clashes should be tested
|
||||
options.externalResources.Add(spec[0], spec[1]);
|
||||
}
|
||||
else if(s == "-nojni")
|
||||
{
|
||||
options.codegenoptions |= CodeGenOptions.NoJNI;
|
||||
|
|
|
@ -2448,6 +2448,13 @@ namespace IKVM.Internal
|
|||
}
|
||||
Tracer.Info(Tracer.Compiler, "Compiling class files (2)");
|
||||
loader.AddResources(options.resources, options.compressedResources);
|
||||
if(options.externalResources != null)
|
||||
{
|
||||
foreach(DictionaryEntry de in options.externalResources)
|
||||
{
|
||||
loader.assemblyBuilder.AddResourceFile(JVM.MangleResourceName((string)de.Key), (string)de.Value);
|
||||
}
|
||||
}
|
||||
if(options.fileversion != null)
|
||||
{
|
||||
CustomAttributeBuilder filever = new CustomAttributeBuilder(typeof(AssemblyFileVersionAttribute).GetConstructor(new Type[] { typeof(string) }), new object[] { options.fileversion });
|
||||
|
@ -2497,6 +2504,7 @@ namespace IKVM.Internal
|
|||
internal string runtimeAssembly;
|
||||
internal string[] privatePackages;
|
||||
internal string sourcepath;
|
||||
internal Hashtable externalResources;
|
||||
}
|
||||
|
||||
enum Message
|
||||
|
|
|
@ -894,6 +894,22 @@ namespace IKVM.Internal
|
|||
return matchingLoader;
|
||||
}
|
||||
|
||||
internal static int GetGenericClassLoaderId(ClassLoaderWrapper wrapper)
|
||||
{
|
||||
lock(wrapperLock)
|
||||
{
|
||||
return genericClassLoaders.IndexOf(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
internal static ClassLoaderWrapper GetGenericClassLoaderById(int id)
|
||||
{
|
||||
lock(wrapperLock)
|
||||
{
|
||||
return (ClassLoaderWrapper)genericClassLoaders[id];
|
||||
}
|
||||
}
|
||||
|
||||
// this method only supports .NET or pre-compiled Java assemblies
|
||||
internal static AssemblyClassLoader GetAssemblyClassLoader(Assembly assembly)
|
||||
{
|
||||
|
|
|
@ -360,7 +360,7 @@ namespace IKVM.Internal
|
|||
{
|
||||
get
|
||||
{
|
||||
return method != null;
|
||||
return parameterTypeWrappers != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5622,7 +5622,7 @@ namespace IKVM.Internal
|
|||
{
|
||||
// TODO at the moment we don't support constructor signature clash resolving, so we better
|
||||
// not put them in the clash table
|
||||
if(methods[i].IsLinked && methods[i].Name != "<init>")
|
||||
if(methods[i].IsLinked && methods[i].GetMethod() != null && methods[i].Name != "<init>")
|
||||
{
|
||||
string key = GenerateClashKey("method", methods[i].RealName, methods[i].ReturnTypeForDefineMethod, methods[i].GetParametersForDefineMethod());
|
||||
memberclashtable.Add(key, key);
|
||||
|
@ -9179,14 +9179,16 @@ namespace IKVM.Internal
|
|||
{
|
||||
string name;
|
||||
string sig;
|
||||
if(MakeMethodDescriptor(constructors[i], out name, out sig))
|
||||
TypeWrapper[] args;
|
||||
TypeWrapper ret;
|
||||
if(MakeMethodDescriptor(constructors[i], out name, out sig, out args, out ret))
|
||||
{
|
||||
if(fabricateDefaultCtor && !constructors[i].IsStatic && sig == "()V")
|
||||
{
|
||||
fabricateDefaultCtor = false;
|
||||
}
|
||||
// TODO handle name/signature clash
|
||||
methodsList.Add(CreateMethodWrapper(name, sig, constructors[i], false));
|
||||
methodsList.Add(CreateMethodWrapper(name, sig, args, ret, constructors[i], false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9207,7 +9209,9 @@ namespace IKVM.Internal
|
|||
{
|
||||
string name;
|
||||
string sig;
|
||||
if(MakeMethodDescriptor(methods[i], out name, out sig))
|
||||
TypeWrapper[] args;
|
||||
TypeWrapper ret;
|
||||
if(MakeMethodDescriptor(methods[i], out name, out sig, out args, out ret))
|
||||
{
|
||||
if(!methods[i].IsStatic && !methods[i].IsPrivate && BaseTypeWrapper != null)
|
||||
{
|
||||
|
@ -9218,7 +9222,7 @@ namespace IKVM.Internal
|
|||
}
|
||||
}
|
||||
// TODO handle name/signature clash
|
||||
methodsList.Add(CreateMethodWrapper(name, sig, methods[i], false));
|
||||
methodsList.Add(CreateMethodWrapper(name, sig, args, ret, methods[i], false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9240,7 +9244,9 @@ namespace IKVM.Internal
|
|||
{
|
||||
string name;
|
||||
string sig;
|
||||
if(MakeMethodDescriptor(map.InterfaceMethods[j], out name, out sig))
|
||||
TypeWrapper[] args;
|
||||
TypeWrapper ret;
|
||||
if(MakeMethodDescriptor(map.InterfaceMethods[j], out name, out sig, out args, out ret))
|
||||
{
|
||||
if(BaseTypeWrapper != null)
|
||||
{
|
||||
|
@ -9261,7 +9267,7 @@ namespace IKVM.Internal
|
|||
if(!clash.ContainsKey(name + sig))
|
||||
{
|
||||
clash.Add(name + sig, null);
|
||||
methodsList.Add(CreateMethodWrapper(name, sig, map.InterfaceMethods[j], true));
|
||||
methodsList.Add(CreateMethodWrapper(name, sig, args, ret, map.InterfaceMethods[j], true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9353,18 +9359,20 @@ namespace IKVM.Internal
|
|||
#endif // !STATIC_COMPILER
|
||||
}
|
||||
|
||||
private bool MakeMethodDescriptor(MethodBase mb, out string name, out string sig)
|
||||
private bool MakeMethodDescriptor(MethodBase mb, out string name, out string sig, out TypeWrapper[] args, out TypeWrapper ret)
|
||||
{
|
||||
if(Whidbey.IsGenericMethodDefinition(mb))
|
||||
{
|
||||
name = null;
|
||||
sig = null;
|
||||
args = null;
|
||||
ret = null;
|
||||
return false;
|
||||
}
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
sb.Append('(');
|
||||
ParameterInfo[] parameters = mb.GetParameters();
|
||||
TypeWrapper[] args = new TypeWrapper[parameters.Length];
|
||||
args = new TypeWrapper[parameters.Length];
|
||||
for(int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
Type type = parameters[i].ParameterType;
|
||||
|
@ -9372,6 +9380,8 @@ namespace IKVM.Internal
|
|||
{
|
||||
name = null;
|
||||
sig = null;
|
||||
args = null;
|
||||
ret = null;
|
||||
return false;
|
||||
}
|
||||
if(type.IsByRef)
|
||||
|
@ -9380,6 +9390,8 @@ namespace IKVM.Internal
|
|||
{
|
||||
name = null;
|
||||
sig = null;
|
||||
args = null;
|
||||
ret = null;
|
||||
return false;
|
||||
}
|
||||
type = ArrayTypeWrapper.MakeArrayType(type.GetElementType(), 1);
|
||||
|
@ -9389,6 +9401,8 @@ namespace IKVM.Internal
|
|||
// methods with byref args.
|
||||
name = null;
|
||||
sig = null;
|
||||
args = null;
|
||||
ret = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -9399,7 +9413,7 @@ namespace IKVM.Internal
|
|||
sb.Append(')');
|
||||
if(mb is ConstructorInfo)
|
||||
{
|
||||
TypeWrapper ret = PrimitiveTypeWrapper.VOID;
|
||||
ret = PrimitiveTypeWrapper.VOID;
|
||||
if(mb.IsStatic)
|
||||
{
|
||||
name = "<clinit>";
|
||||
|
@ -9419,9 +9433,10 @@ namespace IKVM.Internal
|
|||
{
|
||||
name = null;
|
||||
sig = null;
|
||||
ret = null;
|
||||
return false;
|
||||
}
|
||||
TypeWrapper ret = ClassLoaderWrapper.GetWrapperFromType(type);
|
||||
ret = ClassLoaderWrapper.GetWrapperFromType(type);
|
||||
sb.Append(ret.SigName);
|
||||
name = mb.Name;
|
||||
sig = sb.ToString();
|
||||
|
@ -9597,7 +9612,7 @@ namespace IKVM.Internal
|
|||
}
|
||||
}
|
||||
|
||||
private MethodWrapper CreateMethodWrapper(string name, string sig, MethodBase mb, bool privateInterfaceImplHack)
|
||||
private MethodWrapper CreateMethodWrapper(string name, string sig, TypeWrapper[] argTypeWrappers, TypeWrapper retTypeWrapper, MethodBase mb, bool privateInterfaceImplHack)
|
||||
{
|
||||
ExModifiers exmods = AttributeHelper.GetModifiers(mb, true);
|
||||
Modifiers mods = exmods.Modifiers;
|
||||
|
@ -9637,20 +9652,17 @@ namespace IKVM.Internal
|
|||
{
|
||||
mods |= Modifiers.Final;
|
||||
}
|
||||
// TODO pass in the argument and return types
|
||||
return new ByRefMethodWrapper(args, byrefs, this, name, sig, mb, null, null, mods, false);
|
||||
return new ByRefMethodWrapper(args, byrefs, this, name, sig, mb, retTypeWrapper, argTypeWrappers, mods, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mb is ConstructorInfo)
|
||||
{
|
||||
// TODO pass in the argument and return types
|
||||
return new SmartConstructorMethodWrapper(this, name, sig, (ConstructorInfo)mb, null, mods, MemberFlags.None);
|
||||
return new SmartConstructorMethodWrapper(this, name, sig, (ConstructorInfo)mb, argTypeWrappers, mods, MemberFlags.None);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO pass in the argument and return types
|
||||
return new SmartCallMethodWrapper(this, name, sig, (MethodInfo)mb, null, null, mods, MemberFlags.None, SimpleOpCode.Call, SimpleOpCode.Callvirt);
|
||||
return new SmartCallMethodWrapper(this, name, sig, (MethodInfo)mb, retTypeWrapper, argTypeWrappers, mods, MemberFlags.None, SimpleOpCode.Call, SimpleOpCode.Callvirt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9713,15 +9725,6 @@ namespace IKVM.Internal
|
|||
{
|
||||
tw.Finish();
|
||||
}
|
||||
// TODO instead of linking here, we should just pre-link in LazyPublishMembers
|
||||
foreach(MethodWrapper mw in GetMethods())
|
||||
{
|
||||
mw.Link();
|
||||
}
|
||||
foreach(FieldWrapper fw in GetFields())
|
||||
{
|
||||
fw.Link();
|
||||
}
|
||||
}
|
||||
|
||||
internal override string GetGenericSignature()
|
||||
|
|
|
@ -1333,8 +1333,14 @@ namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
|
|||
{
|
||||
// chop off the leading slash
|
||||
resource = resource.Substring(1);
|
||||
string mangledName = JVM.MangleResourceName(resource);
|
||||
ManifestResourceInfo info = asm.GetManifestResourceInfo(mangledName);
|
||||
if(info != null && info.FileName != null)
|
||||
{
|
||||
return asm.GetManifestResourceStream(mangledName);
|
||||
}
|
||||
#if WHIDBEY
|
||||
Stream s = asm.GetManifestResourceStream(JVM.MangleResourceName(resource));
|
||||
Stream s = asm.GetManifestResourceStream(mangledName);
|
||||
if(s == null)
|
||||
{
|
||||
Tracer.Warning(Tracer.ClassLoading, "Resource \"{0}\" not found in {1}", resource, asm.FullName);
|
||||
|
@ -1353,7 +1359,7 @@ namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
|
|||
throw new IOException("Unsupported resource encoding for resource " + resource + " found in assembly " + asm.FullName);
|
||||
}
|
||||
#else
|
||||
using(Stream s = asm.GetManifestResourceStream(JVM.MangleResourceName(resource)))
|
||||
using(Stream s = asm.GetManifestResourceStream(mangledName))
|
||||
{
|
||||
if(s == null)
|
||||
{
|
||||
|
@ -1407,6 +1413,11 @@ namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
|
|||
#endif
|
||||
return Assembly.Load(name);
|
||||
}
|
||||
|
||||
public static object GetGenericClassLoaderById(int id)
|
||||
{
|
||||
return ClassLoaderWrapper.GetGenericClassLoaderById(id).GetJavaClassLoader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1520,11 +1531,6 @@ namespace IKVM.NativeCode.ikvm.@internal
|
|||
return assemblies;
|
||||
}
|
||||
|
||||
public static Assembly GetClassAssembly(object clazz)
|
||||
{
|
||||
return ((IKVM.Internal.AssemblyClassLoader)TypeWrapper.FromClass(clazz).GetClassLoader()).Assembly;
|
||||
}
|
||||
|
||||
// NOTE the array may contain duplicates!
|
||||
public static string[] GetPackages(object classLoader)
|
||||
{
|
||||
|
@ -1558,6 +1564,16 @@ namespace IKVM.NativeCode.ikvm.@internal
|
|||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int GetGenericClassLoaderId(object classLoader)
|
||||
{
|
||||
return ClassLoaderWrapper.GetGenericClassLoaderId((ClassLoaderWrapper)JVM.Library.getWrapperFromClassLoader(classLoader));
|
||||
}
|
||||
|
||||
public static Assembly GetBootClassLoaderAssembly()
|
||||
{
|
||||
return ((IKVM.Internal.AssemblyClassLoader)ClassLoaderWrapper.GetBootstrapClassLoader()).Assembly;
|
||||
}
|
||||
}
|
||||
|
||||
namespace stubgen
|
||||
|
@ -1566,7 +1582,17 @@ namespace IKVM.NativeCode.ikvm.@internal
|
|||
{
|
||||
public static string getAssemblyName(object c)
|
||||
{
|
||||
return ((IKVM.Internal.AssemblyClassLoader)TypeWrapper.FromClass(c).GetClassLoader()).Assembly.FullName;
|
||||
ClassLoaderWrapper loader = TypeWrapper.FromClass(c).GetClassLoader();
|
||||
IKVM.Internal.AssemblyClassLoader acl = loader as IKVM.Internal.AssemblyClassLoader;
|
||||
if(acl != null)
|
||||
{
|
||||
return acl.Assembly.FullName;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
return "TODO: implement support for generic types referencing multiple assemblies in their IKVM.NET.Assembly attribute";
|
||||
}
|
||||
}
|
||||
|
||||
public static object getFieldConstantValue(object fieldWrapper)
|
||||
|
|
Загрузка…
Ссылка в новой задаче