掌握Java底层原理,java虚拟机技术。
开发一个安全JVM。
下载参考源码:
sourceforge.net/projects/jamvm/files/jamvm/
环境:debian7.7, tips:
1)从debian.ustc.edu.cn下载镜像(netinst.iso)
2)安装(选择中国位置、国内镜像->sourse.list)、仅安装default applications
3)重启进入命令行执行 apt-get x-window-system-core gnome-core
4)运行startx进入桌面
【因为登录的时候一下直接登了root用户,所以下面的东西都是以root身份装的。。也不知道合不合适,就酱了>.<】
安装编译器:以下之一
1)gcj(暂时先试了这个)(版本4.7,还有g++)
2)ecj(没成)
3)jikes (没试)
jamvm1.0所附的版本(0.04 modified)类好像不全。目前用classpath0.98 (jamvm1.5.4只能用0.98以后版本)
1)解压源码进入文件夹:./configure --disable-examples --without-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi (--disable-Werror)
(一些选项是与GUI相关,关掉)
存在问题:
1)jamvm1.0.0原代码对一些指针有类似 *(float *)p++ = *q; 操作,则++算符没有有效的左值。
可能是C编译器版本的问题。将类似的操作更正(很多)。但1.0.0安装没生成classes.zip。
java/lang/NoClassDefFoundError: java/lang/Thread
export BOOTCLASSPATH=/usr/local/jamvm/share/jamvm/classes.zip:/usr/local/classpath/share/classpath/glibj.zip
②glibj.zip解压缩到其目录下,差不多能解决。
4) [Loaded gnu/java/nio/VMChannel from /usr/local/classpath/share/classpath/glibj.zip]
[Linking class gnu/java/nio/VMChannel]
[Dynamic-linking native method gnu.java.nio.VMChannel.initIDs ... JNI]
Segmentation fault
参考(十分感谢!):http://blog.csdn.net/lihancheng/article/details/31408611
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
$ sudo cp include/ffi_common.h /usr/local/include/
$cd i686-pc-linux-gnu/
$ cd include/
$ sudo cp ffi.h /usr/local/include
$ cd ../../src/x86 (这里有不同,因为我看到libffi-3.0.10/i686-pc-linux-gnu/include下有ffitarget连接到../../src/x86/ffitarget.h)
$ sudo cp ffitarget.h /usr/local/include
解压缩jamvm-1.5.4源码并进入文件夹
$CPPFLAGS="-I/usr/local/include" ./configure -enable-ffi (这里的两个命令写在了一行,因为我做的时候发现分开写就写不进Makefile里了。而且注意CPPFLAGS后面是“-I” 。。。)
$ make
$ sudo make install
运行jamvm又找不到命令,于是再手动连接/usr/bin下jamvm到安装目录下的/bin/jamvm
再运行jamvm Test终于打出了hello! 我这就去把虚拟机snapshot供起来 T T
另外跑了个计算斐波那契数的小程序^ ^
classpath configure参数参考(以及曾经出现的错误T T):
看stackoverflow上提示运行:
./configure--disable-gtk-peer
接着configure遇到问题: Package gconf-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gconf-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gconf-2.0' found
configure: error: Library requirements (gconf-2.0 >= 2.6.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.
尝试: sudo apt-get install libgconf2-dev
接着又遇到问题TAT: No package 'gdk-2.0' found
configure: error: Library requirements (gdk-2.0 >= 2.8) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.
解决: 安装package : sudo apt-get install libgtk2.0-dev
接着报错: error: Couldn't find plugin support headers and libraries, try --disable-plugin
于是按提示来,运行: ./ --disable-gtk-peer --disable-plugin
结果configure发生错误:error: The Java VM jamvm failed
jamvm原作者写道:BTW, don't add JamVM to your path until _after_ you've configured and built GNU Classpath. You don't want GNU Classpath's configure picking JamVM up as a VM, as JamVM won't work without GNU Classpath, which you haven't built yet!
于是按照建议添加选项 --disable-examples
其他:
github page: https://github.com/zhaohouhou/myjvm)
很多都不懂是啥,只能抓瞎一样拿出错信息到处搜了= =。我感觉我把安装jamvm能碰到的问题都碰到了T T
参考:
www.xuebuyuan.com/1110463.html
gzlgq.blog.163.com/blog/static/21608050200710268338226/
blog.csdn.net/lizzydarcymsp/article/details/5807715
sourceforge.net/p/jamvm/discussion/256481/thread/2e71bc5e/
sourceforge.net/p/jamvm/discussion/256481/thread/7475c3be/
sourceforge.net/p/jamvm/discussion/256481/thread/ab900037/