diff options
author | jfrijters <jfrijters> | 2004-12-02 11:43:05 +0300 |
---|---|---|
committer | jfrijters <jfrijters> | 2004-12-02 11:43:05 +0300 |
commit | b8229f78cc743367867392a523d8b3a856a2fc27 (patch) | |
tree | 7d16eac06578fdd207b5ee08d8f2817142f6f487 | |
parent | ef5c340d43cefb6cd46888c6ddbbcc4772e400cf (diff) |
*** empty log message ***
-rw-r--r-- | classpath/allsources.lst | 46 | ||||
-rw-r--r-- | classpath/java/lang/ExceptionHelper.java | 1 | ||||
-rw-r--r-- | classpath/map.xml | 16 | ||||
-rw-r--r-- | ikvm.build | 6 | ||||
-rw-r--r-- | jvm/JVM.il (renamed from classpath/gnu/java/net/protocol/ftp/Handler.java) | 44 | ||||
-rw-r--r-- | jvm/jvm.build | 8 | ||||
-rw-r--r-- | runtime/TypeWrapper.cs | 50 | ||||
-rw-r--r-- | runtime/jvm.il | 2 | ||||
-rw-r--r-- | tools/asmref.cs | 38 | ||||
-rw-r--r-- | tools/tools.build | 10 |
10 files changed, 200 insertions, 21 deletions
diff --git a/classpath/allsources.lst b/classpath/allsources.lst index 2c577f3c..6adfb762 100644 --- a/classpath/allsources.lst +++ b/classpath/allsources.lst @@ -3,7 +3,6 @@ ikvm/lang/CIL.java gnu/classpath/Configuration.java gnu/classpath/RawData.java gnu/java/nio/channels/FileChannelImpl.java -gnu/java/net/protocol/ftp/Handler.java gnu/java/net/protocol/ikvmres/Handler.java gnu/java/net/PlainSocketImpl.java gnu/java/net/PlainDatagramSocketImpl.java @@ -242,8 +241,51 @@ sun/misc/Ref.java ../../classpath/gnu/java/net/HeaderFieldHelper.java ../../classpath/gnu/java/net/protocol/file/Connection.java ../../classpath/gnu/java/net/protocol/file/Handler.java -../../classpath/gnu/java/net/protocol/http/Connection.java +../../classpath/gnu/java/net/BASE64.java +../../classpath/gnu/java/net/CRLFInputStream.java +../../classpath/gnu/java/net/CRLFOutputStream.java +../../classpath/gnu/java/net/EmptyX509TrustManager.java +../../classpath/gnu/java/net/GetLocalHostAction.java +../../classpath/gnu/java/net/GetSystemPropertyAction.java +../../classpath/gnu/java/net/LineInputStream.java +../../classpath/gnu/java/net/protocol/ftp/ActiveModeDTP.java +../../classpath/gnu/java/net/protocol/ftp/BlockInputStream.java +../../classpath/gnu/java/net/protocol/ftp/BlockOutputStream.java +../../classpath/gnu/java/net/protocol/ftp/CompressedInputStream.java +../../classpath/gnu/java/net/protocol/ftp/CompressedOutputStream.java +../../classpath/gnu/java/net/protocol/ftp/DTP.java +../../classpath/gnu/java/net/protocol/ftp/DTPInputStream.java +../../classpath/gnu/java/net/protocol/ftp/DTPOutputStream.java +../../classpath/gnu/java/net/protocol/ftp/FTPConnection.java +../../classpath/gnu/java/net/protocol/ftp/FTPException.java +../../classpath/gnu/java/net/protocol/ftp/FTPResponse.java +../../classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java +../../classpath/gnu/java/net/protocol/ftp/Handler.java +../../classpath/gnu/java/net/protocol/ftp/PassiveModeDTP.java +../../classpath/gnu/java/net/protocol/ftp/StreamInputStream.java +../../classpath/gnu/java/net/protocol/ftp/StreamOutputStream.java +../../classpath/gnu/java/net/protocol/http/Authenticator.java +../../classpath/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.java +../../classpath/gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java +../../classpath/gnu/java/net/protocol/http/ChunkedInputStream.java +../../classpath/gnu/java/net/protocol/http/Cookie.java +../../classpath/gnu/java/net/protocol/http/CookieManager.java +../../classpath/gnu/java/net/protocol/http/Credentials.java +../../classpath/gnu/java/net/protocol/http/HTTPConnection.java +../../classpath/gnu/java/net/protocol/http/HTTPDateFormat.java +../../classpath/gnu/java/net/protocol/http/HTTPURLConnection.java ../../classpath/gnu/java/net/protocol/http/Handler.java +../../classpath/gnu/java/net/protocol/http/Headers.java +../../classpath/gnu/java/net/protocol/http/Request.java +../../classpath/gnu/java/net/protocol/http/RequestBodyWriter.java +../../classpath/gnu/java/net/protocol/http/Response.java +../../classpath/gnu/java/net/protocol/http/ResponseBodyReader.java +../../classpath/gnu/java/net/protocol/http/ResponseHeaderHandler.java +../../classpath/gnu/java/net/protocol/http/SimpleCookieManager.java +../../classpath/gnu/java/net/protocol/http/event/ConnectionEvent.java +../../classpath/gnu/java/net/protocol/http/event/ConnectionListener.java +../../classpath/gnu/java/net/protocol/http/event/RequestEvent.java +../../classpath/gnu/java/net/protocol/http/event/RequestListener.java ../../classpath/gnu/java/net/protocol/jar/Connection.java ../../classpath/gnu/java/net/protocol/jar/Handler.java ../../classpath/gnu/java/net/URLParseError.java diff --git a/classpath/java/lang/ExceptionHelper.java b/classpath/java/lang/ExceptionHelper.java index 00756634..3c545862 100644 --- a/classpath/java/lang/ExceptionHelper.java +++ b/classpath/java/lang/ExceptionHelper.java @@ -171,6 +171,7 @@ public final class ExceptionHelper (System_Reflection_MethodBase.IsAssignableFrom(m.get_DeclaringType()) || m.get_DeclaringType().get_FullName().startsWith("java.lang.ExceptionHelper") || m.get_DeclaringType().get_FullName().equals("System.RuntimeMethodHandle") + || m.get_DeclaringType().get_FullName().equals("java.lang.LibraryVMInterfaceImpl") || IsHideFromJava(m) || IsPrivateScope(m))) // NOTE we assume that privatescope methods are always stubs that we should exclude { diff --git a/classpath/map.xml b/classpath/map.xml index 56836885..1de089e3 100644 --- a/classpath/map.xml +++ b/classpath/map.xml @@ -895,6 +895,22 @@ </body> </method> </class> + <class name="java.nio.channels.Channels"> + <method name="newInputStream" sig="(Lgnu.java.nio.channels.FileChannelImpl;)Ljava.io.FileInputStream;"> + <body> + <ldarg_0 /> + <newobj class="java.io.FileInputStream" name="<init>" sig="(Lgnu.java.nio.channels.FileChannelImpl;)V" /> + <ret /> + </body> + </method> + <method name="newOutputStream" sig="(Lgnu.java.nio.channels.FileChannelImpl;)Ljava.io.FileOutputStream;"> + <body> + <ldarg_0 /> + <newobj class="java.io.FileOutputStream" name="<init>" sig="(Lgnu.java.nio.channels.FileChannelImpl;)V" /> + <ret /> + </body> + </method> + </class> <class name="java.nio.DirectByteBufferImpl"> <method name="get" sig="()B"> <body> @@ -1,15 +1,17 @@ <?xml version="1.0"?> <project name="ikvm" default="all"> <target name="all"> + <nant buildfile="tools/tools.build" /> <nant buildfile="runtime/runtime.build" /> <nant buildfile="native/native.build" /> <nant buildfile="ikvmc/ikvmc.build" /> <nant buildfile="classpath/classpath.build" /> <nant buildfile="ikvm/ikvm.build" /> + <nant buildfile="ikvmstub/ikvmstub.build" /> <if propertytrue="nant.platform.win32"> <nant buildfile="awt/awt.build" /> + <nant buildfile="jvm/jvm.build" /> </if> - <nant buildfile="ikvmstub/ikvmstub.build" /> </target> <target name="clean"> <delete failonerror="false"> @@ -22,6 +24,8 @@ <includes name="bin/ikvm.exe" /> <includes name="bin/ikvmc.exe" /> <includes name="bin/ikvmstub.exe" /> + <includes name="bin/JVM.DLL" /> + <includes name="tools/asmref.exe" /> </fileset> </delete> </target> diff --git a/classpath/gnu/java/net/protocol/ftp/Handler.java b/jvm/JVM.il index 8f9c9529..daa0fa34 100644 --- a/classpath/gnu/java/net/protocol/ftp/Handler.java +++ b/jvm/JVM.il @@ -21,21 +21,39 @@ jeroen@frijters.net */ +.assembly JVM {} +.module JVM.DLL +.corflags 0x00000002 +.vtfixup [3] int32 fromunmanaged at VTable +.data VTable = int32[3] -package gnu.java.net.protocol.ftp; - -import java.net.*; -import java.io.*; +.method public static int32 JNI_CreateJavaVM(void* ppvm, void* ppenv, void* args) +{ + .vtentry 1:1 + .export [1] as JNI_CreateJavaVM + ldarg.0 + ldarg.1 + ldarg.2 + call int32 [IKVM.Runtime]IKVM.Runtime.JNI::CreateJavaVM(void*, void*, void*) + ret +} -public class Handler extends URLStreamHandler +.method public static int32 JNI_GetDefaultJavaVMInitArgs(void *vm_args) { - protected URLConnection openConnection(URL url) throws IOException - { - throw new IOException("ftp protocol not implemented"); - } + .vtentry 1:2 + .export [2] as JNI_GetDefaultJavaVMInitArgs + ldarg.0 + call int32 [IKVM.Runtime]IKVM.Runtime.JNI::GetDefaultJavaVMInitArgs(void*) + ret +} - protected void parseURL(URL url, String url_string, int start, int end) - { - throw new gnu.java.net.URLParseError("ftp protocol not implemented"); - } +.method public static int32 JNI_GetCreatedJavaVMs(void* ppvmBuf, int32 bufLen, int32* nVMs) +{ + .vtentry 1:3 + .export [3] as JNI_GetCreatedJavaVMs + ldarg.0 + ldarg.1 + ldarg.2 + call int32 [IKVM.Runtime]IKVM.Runtime.JNI::GetCreatedJavaVMs(void*, int32, int32*) + ret } diff --git a/jvm/jvm.build b/jvm/jvm.build new file mode 100644 index 00000000..7e5b743a --- /dev/null +++ b/jvm/jvm.build @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<project name="JVM" default="JVM"> + <target name="JVM"> + <exec program="../tools/asmref" useruntimeengine="true" commandline="mscorlib" output="jvm_h1.il" /> + <exec program="../tools/asmref" useruntimeengine="true" commandline="../bin/IKVM.Runtime.dll" output="jvm_h2.il" /> + <exec program="ilasm" commandline="/dll /out:../bin/JVM.DLL jvm_h1.il jvm_h2.il JVM.il" /> + </target> +</project> diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs index c15d4bb6..382e774c 100644 --- a/runtime/TypeWrapper.cs +++ b/runtime/TypeWrapper.cs @@ -3782,20 +3782,54 @@ sealed class DynamicTypeWrapper : TypeWrapper { if(baseMce.RealName == "Finalize") { - //baseMethod = null; + // We're overriding Finalize (that was renamed to finalize by DotNetTypeWrapper) + // in a non-Java base class. attribs |= MethodAttributes.NewSlot; needFinalize = true; needDispatch = true; } else if(baseMce.DeclaringType == CoreClasses.java.lang.Object.Wrapper) { + // This type is the first type in the hierarchy to introduce a finalize method + // (other than the one in java.lang.Object obviously), so we need to override + // the real Finalize method and emit a dispatch call to our finalize method. needFinalize = true; needDispatch = true; } else if(m.IsFinal) { + // One of our base classes already has a finalize method, so we already are + // hooked into the real Finalize, but we need to override it again, to make it + // final (so that non-Java types cannot override it either). needFinalize = true; needDispatch = false; + // If the base class finalize was optimized away, we need a dispatch call after all. + Type baseFinalizeType = typeBuilder.BaseType.GetMethod("Finalize", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null).DeclaringType; + if(baseFinalizeType == typeof(object)) + { + needDispatch = true; + } + } + else + { + // One of our base classes already has a finalize method, but it may have been an empty + // method so that the hookup to the real Finalize was optimized away, we need to check + // for that. + Type baseFinalizeType = typeBuilder.BaseType.GetMethod("Finalize", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null).DeclaringType; + if(baseFinalizeType == typeof(object)) + { + needFinalize = true; + needDispatch = true; + } + } + if(needFinalize && + (!m.IsFinal || classFile.IsFinal) && + m.Instructions.Length > 0 && + m.Instructions[0].NormalizedOpCode == NormalizedByteCode.__return) + { + // we've got an empty finalize method, so we don't need to override the real finalizer + // (not having a finalizer makes a huge perf difference) + needFinalize = false; } } if(unloadableOverrideStub) @@ -3811,7 +3845,7 @@ sealed class DynamicTypeWrapper : TypeWrapper { GenerateUnloadableOverrideStub(baseMce, mb, methods[index].ReturnTypeForDefineMethod, methods[index].GetParametersForDefineMethod()); } - else if(baseMce != null && (explicitOverride || baseMce.RealName != name)) + else if(baseMce != null && (explicitOverride || baseMce.RealName != name) && !needFinalize) { // assert that the method we're overriding is in fact virtual and not final! Debug.Assert(baseMce.GetMethod().IsVirtual && !baseMce.GetMethod().IsFinal); @@ -5578,7 +5612,17 @@ sealed class DotNetTypeWrapper : LazyTypeWrapper interfaces = new TypeWrapper[interfaceTypes.Length]; for(int i = 0; i < interfaces.Length; i++) { - interfaces[i] = ClassLoaderWrapper.GetWrapperFromType(interfaceTypes[i]); + if(interfaceTypes[i].DeclaringType != null && + interfaceTypes[i].IsDefined(typeof(HideFromJavaAttribute), false) && + interfaceTypes[i].Name == "__Interface") + { + // we have to return the declaring type for ghost interfaces + interfaces[i] = ClassLoaderWrapper.GetWrapperFromType(interfaceTypes[i].DeclaringType); + } + else + { + interfaces[i] = ClassLoaderWrapper.GetWrapperFromType(interfaceTypes[i]); + } } } return interfaces; diff --git a/runtime/jvm.il b/runtime/jvm.il index 1127c2c6..daa0fa34 100644 --- a/runtime/jvm.il +++ b/runtime/jvm.il @@ -21,8 +21,6 @@ jeroen@frijters.net */ -.assembly extern mscorlib {} -.assembly extern IKVM.Runtime {} .assembly JVM {} .module JVM.DLL .corflags 0x00000002 diff --git a/tools/asmref.cs b/tools/asmref.cs new file mode 100644 index 00000000..909e6f4d --- /dev/null +++ b/tools/asmref.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using System.Reflection; +using System.Text; + +class asmref +{ + static void Main(string[] args) + { + foreach(string s in args) + { + AssemblyName asm; + if(File.Exists(s)) + { + asm = Assembly.LoadFile(new FileInfo(s).FullName).GetName(); + } + else + { + asm = Assembly.LoadWithPartialName(s).GetName(); + } + + Console.WriteLine(".assembly extern {0}", asm.Name); + Console.WriteLine("{"); + if(asm.GetPublicKeyToken() != null) + { + StringBuilder sb = new StringBuilder(); + foreach(byte b in asm.GetPublicKeyToken()) + { + sb.AppendFormat("{0:X2} ", b); + } + Console.WriteLine(" .publickeytoken = ({0})", sb.ToString()); + } + Version v = asm.Version; + Console.WriteLine(" .ver {0}:{1}:{2}:{3}", v.Major, v.Minor, v.Build, v.Revision); + Console.WriteLine("}"); + } + } +} diff --git a/tools/tools.build b/tools/tools.build new file mode 100644 index 00000000..145617b7 --- /dev/null +++ b/tools/tools.build @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<project name="tools" default="tools"> + <target name="tools"> + <csc target="exe" output="asmref.exe" optimize="true"> + <sources> + <includes name="asmref.cs" /> + </sources> + </csc> + </target> +</project> |