您的位置:首页 > 其它

IKVM.NET_第九篇_开发者指南_概念

2010-07-04 16:10 405 查看
本文介绍一些IKVM.NET能力和限制的重要概念,内容如下:
1)加载字节码
2)支持调试
+++ 加载字节码
IKVM.NET完全支持在ikvm Java虚拟机上以及已经使用ikvmc应用程序转换成.NET 公共中间语言(CIL)的Java应用程序上动态加载Java字节码。
++ 动态地解释Java应用程序加载字节码
当你使用ikvm运行一个Java应用程序时,ikvm查找并加载Java字节码,就像任何Java虚拟机一样。
++ ikvmc编译的Java应用程序上加载字节码
当你使用ikvmc应用程序把一个Java应用程序转换成.NET公共中间语言(CIL)时,这个转换的代码作为“native”.NET代码执行。每个.NET装配(DLL文件)都将拥有它自己的Java字节码装载器实例,特别是ikvm.runtime.AssemblyClassLoader装载器。这个类装载器将通过下面方式装载类:
1) 首先查找相应的装配文件。若类在装配中,它就找到了。
2) 再搜索这个装配直接引用的装配。也就是这个DLL文件引用的其他DLL文件。
+++ 支持调试
使用ikvmc的“-debug”选项把Java应用程序转换成公共中间语言时,通过标准的.NET/Mono调试工具,可以调试该Java应用程序。

IKVM.NET Concepts
This section discusses several important concepts about the capabilities and limitations of IKVM.NET.
1) Class Loading
2) Debugging Support
+++ Class Loading
IKVM.NET fully supports dynamic Java class loading, both in Java applications running in the ikvm JVM, as well as in Java applications which have been converted to .NET CIL using ikvmc.
++ Class Loading in Dynamically Interpreted Java Applications
When you run a Java application using ikvm, ikvm finds and loads Java .class files much like other Java VM's.
++ Class Loading in ikvmc-compiled Java Applications
When you convert a Java application to CIL using ikvmc, it executes as "native" .NET code. Each .NET assembly will have its own Java class loader instance (typically of the type ikvm.runtime.AssemblyClassLoader). This class loader will load classes using the following algorithm:
1) The corresponding assembly is searched first. Thus, if the class exists in the assembly, it will be found there.
2) All assemblies directly referenced by corresponding assembly are searched.
For more details see these two articles: Class Loading Architecture, Writing a Custom Assembly Class Loader
+++ Debugging Support
Java applications converted to CIL using ikvmc with the -debug option can be debugged using standard .NET / Mono debugging tools. Remember to compile the Java source code using the appropriate debug option (javac: -g or jikes: -g:lines,vars,source).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: