IKVM.NET_第四篇_用户指南_概述
本文内容
- 简介
- 概述
- 系统要求
简介
IKVM.NET是针对.NET和Mono的一个Java虚拟机。虽然IKVM.NET仍然处于开发阶段,但是在运行复杂的应用程序和工具时,如Eclipse、JmDNS、JGroups、Jetty,它的反响还不错。本指南是针对IKVM.NET 0.36版本。
概述
有两种方式使用IKVM.NET:
1) 动态方式:在这个模式下,Java类和jar包在.NET TM运行时直接被用来执行Java应用程序。Java字节码被直接解释成.NET CIL,无需进一步步骤。完整的Java类装载器就支持这种模式。
2) 静态方式:为了能使Java代码能被.NET应用程序使用,只要把Java代码编译成..DLL文件,并在.NET应用程序中引用,就能像使用.NET对象一样使用Java对象。静态模式不支持完整的Java类装载器机制,对于静态编译的代码,创建一个类装载器,并且动态加载类是可以的。
IKVM.NET提供字节码解释和验证以及装载类等等的虚拟机技术,它依赖于实现JDK库的OpenJDK工程。
IKVM.NET是由以下组件组成:
- IKVM.Runtime.dll是虚拟机运行时和所有支持的代码,它包含:
1) 字节码即时编译技术(Just in time ,JIT)编译器/验证器:JIT把Java字节码编译成CIL;
2) 重映射对象模型:就是把.NET的System.Object、System.String和System.Exception映射到Java的java.lang.Object、java.lang.String和java.lang.Throwable;
3) 可管理的Classpath 本地方法的重实现。
其实这三个组件,我的理解是,如果将Java转换成.DLL文件,需要做到三点:一是如何将字节码转换成公共中间语言(CIL);二是如何将Java基础类转换成.NET的基础类;三是命名空间问题。
- IKVM.OpenJDK.ClassLibrary.dll:它是一个Java类库的编译版本,加上IKVM.NET特定的代码。
- IKVM.AWT.WinForms.dll:AWT非常有限的实现。
- ikvm.exe:同JDK中的java.exe应用程序一样,使用动态模式。
- ikvmc.exe:静态编译器。用来将Java类和jar包编译成.NET装配文件(.DLL)。
- ikvmstub.exe:从.NET装配文件产生stub类文件的工具, 供Java使用。
系统要求
你必须安装下面.NET框架中的一个:
微软.NET 框架1.1(或 更高)SDK(Windows平台)
Mono 1.2(或 更改)(Windows or Linux平台)
IKVM.NET User's Guide
1) Introduction
2) Overview
3) System Requirements
+++ Introduction
++ IKVM.NET is a Java Virtual Machine (JVM) for the .NET and Mono runtimes. At a time when most people in the computer industry consider Java and .NET as mutually exclusive technologies, IKVM.NET stands in the unique position of bringing them together. Initially born out of frustration with the limitations of tools like JUMP and J#, IKVM.NET was created when Jeroen Frijters set out to create a way to migrate an existing JavaTM database application to .NETTM.
++ IKVM.NET has gone through a variety of designs and name changes to emerge as a sophisticated collection of tools offering a variety of integration patterns between the Java and .NET languages and platforms. It is still under development but people have reported success in running sophisticated applications and tools including Eclipse, JmDNS, JGroups, Jetty (with a few changes), etc.
++ This manual is written for IKVM.NET version 0.36.
+++ Overview
++ There are two main ways of using IKVM.NET:
1) Dynamically: In this mode, Java classes and jars are used directly to execute Java applications on the .NETTM runtime. Java bytecode is translated on the fly into CIL and no further steps are necessary. The full Java class loader model is supported in this mode.
2) Statically: In order to allow Java code to be used by .NET applications, it must be compiled down to a DLL and used directly. The bytecode is translated to CIL and stored in this form. The assemblies can be referenced directly by the .NET applications and the "Java" objects can be used as if they were .NET objects. While the static mode does not support the full Java class loader mechanism, it is possible for statically-compiled code to create a class loader and load classes dynamically.
++ IKVM.NET provides the VM-related technologies for byte-code translation and verification, classloading, etc. It is dependent upon the OpenJDK project for implementations of the JDK libraries.
++ IKVM.NET is comprised by the following components:
+ IKVM.Runtime.dll: The VM runtime and all supporting code. It contains (among other things):
1) Byte Code JIT compiler/verifier: Just-in-time compiles Java Byte Code to CIL.
2) Object model remapping infrastructure: Makes System.Object, System.String and System.Exception appear to Java code as java.lang.Object, java.lang.String and java.lang.Throwable.
3) Managed .NET re-implementations of the native methods in Classpath.
+ IKVM.OpenJDK.ClassLibrary.dll: This is a compiled version of the Java class libraries, plus some additional IKVM.NET specific code.
+ IKVM.AWT.WinForms.dll: Very limited and broken implementation of a few AWT peers. This is a low priority issue until the platform stabilizes and works sufficiently well.
+ ikvm.exe: Starter executable, comparable to java.exe ("dynamic mode").
+ ikvmc.exe: Static compiler. Used to compile Java classes and jars into a .NET assembly ("static mode")
+ ikvmstub.exe A tool that generates stub class files from a .NET assembly, so that Java code can be compiled against .NET code. IKVM.NET understands the stubs and replaces the references to the stubs by references to the actual .NET types.
+++ System Requirements
You must have one of the following .NET frameworks installed:
Microsoft .NET Framework 1.1 (or later) SDK (Windows platform)
Mono 1.2 (or later) (Windows or Linux)