Life is more exciting with multi-language support on JVM. Recently john rose @ sun, created patch for loading anonymous classes in the VM (
read carefully, we are not talking about anonymous classes in JDK, we are talking about loading anonymous classes at VM level ). JVM wouldn't not allow someone to change structure of a class once it loaded. Though this security feature brings-in stability to JVM, dynamic language implementors for JVM are forced to write lots of boiler plate code to simulate dynamism on top of JVM (Ex: In Ruby, methods can be added, removed, modified at runtime, even class structure can be changed @ runtime too). The recent patch added by john for OpenJDK allows us to load an arbitrary class from a block of bytecodes and associate the new class with a pre-existing host class, inheriting its access, linkage, and permission characteristics. Very interesting thing is, a block of bytecodes can be template class file and this template class can be customized at runtime using various constant pool patching methods in java.dyn.AnonymousClassLoader, just before loaded by AnonymousClassLoader class loader. This patch not only alienate pain of other language implementers to a greater extent but accentuate complete JDK and Hotspot with new way of loading and linking anonymous classes in JVM, thereby opening up developers mind in yet another innovative direction. Read john's blog on
anonymous classes in the vm for more details on this feature. Pretty exciting ha?, Wanna try it out yourself?. Here is the step by step instruction for applying multi-language path to Open JDK Hotspot VM and building
mlvm aka
The Davinci VM.
If you haven't successfully built Open JDK and Hotspot VM, go through simonis blog on
building Open JDK and hotspot on linux. Once you successfully built OpenJDK and Hotspot, follow
below instructions for building and running mlvm,
- Download mlvm paths and related files
http://homepage.mac.com/rose00/work/webrev/6652736/wkk.patchhttp://homepage.mac.com/rose00/work/webrev/6653858/anonk.patchhttp://homepage.mac.com/rose00/work/webrev/6653858/DVMTest.zipcd
/jdk7/hotspotpatch -p1 --backup-if-mismatch < /home/tselvan/mlvm/patches/wkk.patch patch -p1 --backup-if-mismatch < /home/tselvan/mlvm/patches/anonk.patch LANG=C \
ALT_BOOTDIR=/share/software/jdk1.6.0_04/ \ HOTSPOT_BUILD_JOBS=1 \ ALT_OUTPUTDIR=../../build/hotspot_debug \ make jvmg 2>&1 | tee ../../build/hotspot_debug.log- Give necessary permissions to libjvm.so under linux,
chcon -t texrel_shlib_t /share/software/OpenJDK/jdk7/build/openjdk_full_debug/lib/i386/*.sochcon -t texrel_shlib_t /share/software/OpenJDK/jdk7/build/openjdk_full_debug/j2sdk-image/jre/lib/i386/*.soexport PATH=/share/software/OpenJDK/jdk7/build/openjdk_full_debug/bin:$PATHexport JAVA_HOME=/share/software/OpenJDK/jdk7/build/openjdk_full_debug- Running sample mlvm program
Unzip DVMTest.zip, ( i have locally unziped to /share/software/OpenJDK/mlvm)Run Make.shjava -esa -ea -Xbootclasspath/p:/share/software/OpenJDK/mlvm/bootcp -cp /share/software/OpenJDK/mlvm DVMTest
If you like to have discussion on mlvm, leave your comments or lets catch up during DevCamp. Watch this space for more experiment with mlvm in coming weeks.