移植JAVA虚拟机CVM到ARM平台(收藏)

    技术2022-05-20  47

    J2ME CDC(Connected Device Configuration,连接式设备配置集)使用CVM,面向那些具有更强计算能力的嵌入式设备,包含了Java类库的核心部分,是应用Java技术在嵌入式设备上进行开发所需类库的最小集合。它具有如下优点:高级网络特性:CDC位基于套接字的网络编程技术提供了最新Java API满足Jini技术的需求:基于CDC远程方法调用(RMI)可选包可实现对基于完全Jini技术的设备支持。方便的移植:CDC的Foundation Profile(基础描述集)核心类库包括了广为使用的java.lang、java.net、java.io、java.util、java.security和java.text包清除了deprecated方法:程序更安全、易于理解可以利用更高级的包进行扩展,比如说Personal Basis Profile(PBP个人基础描述集)和Personal Profile(PP个人描述集)等。CDC向小型设备展现了大量的Java 2技术,与Jini技术的结合提高了设备的灵活性,以及能够不断进化发展的能力,实现即插即用,分布计算等等。CDC对资源的要求:内存:2MB ROM、512KB RAM处理器:32位CPU网络连接能力:至少支持UDP,附加的profile可添加对TCP/IP的完全支持用户界面:没有支持图形用户的GUI,可添加描述集实现。

    一、选用sun的phoneme   https://phoneme.dev.java.net/二、下载   http://download.java.net/mobileembedded/phoneme/advanced/phoneme_advanced-mr2-dev-src-b97-20_nov_2008.zip三、解压   unzip phoneme_advanced-mr2-dev-src-b97-20_nov_2008.zip四、修改makefile   cd phoneme_advanced_mr2/cdc/build/linux-arm-generic   gedit GNUmakefile   修改 CVM_TARGET_TOOLS_PREFIX=/usr/local/arm/4.3.2/bin/arm-linux- 为自己的交叉编译器的地址    修改 USE_AAPCS ?= false 为 true五、输出PATH   export PATH=/usr/local/arm/4.3.2/bin/:$PATH                     为自己的交叉编译器的地址六、编译    make 七、如果是使用ubuntu的朋友,可能要安装sun-java6-jdk和另外的一两个工具   Java SDK安装配置   http://wiki.ubuntu.org.cn/Java安装配置   另外的一两个工具可以通过 apt-get install 来安装(出错时会提醒的了,具体我忘了,没有记录)八、出错   ../../src/linux-arm/javavm/runtime/segvhandler_arch.c:45:26: error: asm/ucontext.h: No such file or directory   ../../src/linux-arm/javavm/runtime/segvhandler_arch.c:In function 'handleSegv':   ../../src/linux-arm/javavm/runtime/segvhandler_arch.c:224: error: dereferencing pointer to incomplete type   ../../src/linux-arm/javavm/runtime/segvhandler_arch.c:285: error: dereferencing pointer to incomplete type   ../../src/linux-arm/javavm/runtime/segvhandler_arch.c:285: error: dereferencing pointer to incomplete type   ../../src/linux-arm/javavm/runtime/segvhandler_arch.c:286: error: dereferencing pointer to incomplete type   ../../src/linux-arm/javavm/runtime/segvhandler_arch.c:294: error: dereferencing pointer to incomplete type   修改 segvhandler_arch.c 文件   gedit ../../src/linux-arm/javavm/runtime/segvhandler_arch.c   修改   #define ucontext asm_ucontext   #include <asm/ucontext.h>   为   //#define ucontext asm_ucontext     //注释掉这句   #include <ucontext.h>            //去掉arm/九、编译    make    编译成功!   ls    可以看到在当前目录有   bin   lib   testclasses.zip十、测试   1)、拷贝上面三个文件与文件夹到开发板/home/j2me目录    2)、在开发板/etc/init.d/rcS文件里加入如下        JAVA_HOME=/home/j2me        export PATH=$JAVA_HOME/bin:$PATH        export CLASSPATH=.:$JAVA_HOME/lib   3)、经典的HelloWorld       cd /home/j2me/bin       ./cvm -cp ../testclasses HelloWorld           可以看到输出了 HelloWorld.    4)、来个全面测试        ./cvm -cp ../testclasses.zip Test        *Number of command line arguments: 0        Starting test1        ...recurse        ...recurse        ...recurse        ...link        ...link        ...link        Starting test1 again        ...recurse        ...recurse        ...recurse        ...link        ...link        ...link        test6: Caught inner java.lang.NullPointerException        test6: Caught outer java.lang.NullPointerException        Testing Array Copy        *TestE exception thrown because "I'm feeling Testy"        *<clinit> threw java.lang.ExceptionInInitializerError        *<clinit> threw java.lang.NoClassDefFoundError: StaticE        c1 = class [LTest;        c2 = class [[LTest;        c3 = class [LC;        c4 = class [[LC;        c1.modifiers = 1041        c2.modifiers = 1041        c3.modifiers = 1040        c4.modifiers = 1040        *FloatMIN =1.4E-45        *FloatMAX =3.4028235E38        FloatMIN (the int bits) =1        FloatMAX (the int bits) =2139095039        java.lang.IllegalArgumentException: too many dimensions            at java.lang.reflect.Array.multiNewArray(Native Method)            at java.lang.reflect.Array.newInstance(Unknown Source)            at Test.testDeepArrayConstruction(Unknown Source)            at Test.main(Unknown Source)            at sun.misc.CVM.runMain(Unknown Source)        Constructed an object of type         [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[LTest;        finally!        Requesting GC with a latency request of 2 seconds        (Turning GC tracing on)        Sleeping 5 seconds, and waiting for GC's        Woke up! Cancelling latency request        .............        *CONGRATULATIONS: test Test completed with 411 tests passed and 0 failures        *Output lines starting with a * should be checked for correctness        *They can be compared to src/share/javavm/test/TestExpectedResult        *CONGRATULATIONS: test Test completed with 411 tests passed and 0 failures        这句话意味着什么,我就不说了~~ 恭喜你!

     

    ---------------------------------------

    我的补充:GNUmakefile里有两个USE_AAPCS ,都要改成false否则运行时报Java VM panic: AAPCS calling convention used; compilation must use -DAAPCS


    最新回复(0)