Subject: How to make JIT work with lang/sun-jre13
To: None <tech-pkg@netbsd.org>
From: Todd Vierling <tv@pobox.com>
List: tech-pkg
Date: 02/13/2003 22:25:49
This is a mini-howto with glue code that currently is not yet fit for pkgsrc
consumption.  I've Bcc:'d to netbsd-java and port-i386, but any discussion
should be on tech-pkg.  (I am on neither of the other two lists.)

There's a long-standing deficiency in the Sun JDK/JRE 1.3.1 that prevents
the use of conventional JITs (such as lang/jbuilder-jit) with the Classic
VM.  Under NetBSD's Linux emulation, the Classic VM with green_threads is
the most reliable mode of operation, and pkgsrc sets this mode by default.

Normally, if you try to set JAVA_COMPILER in the environment or use
-Djava.compiler on the command line, you'll receive the message:

    Warning: JIT compiler "javacomp" not found. Will use interpreter.

Which means that JIT is not in use.  The problem stems from the fact that
the Sun 1.3.1 JIT compiler initialization code doesn't install the
java.lang.Compiler.initialize() JNI hook, preventing use of any JIT at all.

The Blackdown JRE doesn't have this problem, although the Blackdown JRE has
not been updated for several security fixes since its last release in March
2002.  (Since I originally created the jbuilder-jit package to work with
blackdown-jre13 and took a hiatus from Java work soon thereafter, I never
checked to see that JITs did not work on Sun's distribution.  8-)

So, you'll find a small piece of glue code attached to this message in
uuencode format that will bridge the gap by ensuring that the missing
initialize() method is registered.  Inside the .tgz is a jitwrap.c and
Makefile which can only be compiled on a Linux machine or cross-compiler,
and a precompiled "libjitwrap.so".  Most users will only need the
precompiled version.

This will be made more aesthetically pleasing and pkgsrc-worthy in the
future.  I'm playing with an attempt to hook it in via JVMPI (i.e.
"-Xrunjitwrap") so that it won't have to pretend to be the JIT compiler at
all, and will automatically step out of the way if no compiler is desired.

*****

To use the following JIT compiler glue library, assuming the installed JRE
is at least sun-jdk13-1.0.7, copy libjitwrap.so and the JIT .so into
/usr/pkg/java/sun-1.3.1/lib/i386/.  Here, I'll assume that lang/jbuilder-jit
is installed (shuJIT -- http://www.shudo.net/jit/ -- also works).

Then set the following in the environment:

    JAVA_COMPILER=jitwrap
    JAVA_COMPILER_WRAP=libjavacomp.so

Note that JAVA_COMPILER_WRAP is the full library name, with "lib" and ".so",
so set it to "libshujit.so" if using shuJIT.  When "java" is invoked after
this point, the desired JIT will indeed be loaded and work as expected,
although "java -version" will say that the JIT in use is "jitwrap".

begin 644 jdk13comp.tgz
M'XL(`.-=3#X``^T9;6P4U_'9!NQ;2`.$.`W0Y`5,>G;M]?E\-I2OVAQGQ^YA
MG\R'B4A9UG=[OC7GW=/NG@NEJ&Y/^6&=7"$E_=/T!RI2I/17U51I)?Y8`M$B
M5:I_5%5_HJJMSFI5T0@A6M%<9]Y[>]Y;?"1(?*C"8\W-F_?FS<S[FC=O/94Z
MV]6=-*=SG>2)`8V$=O?T4$(!>L*<AB.<<@A1NKLWW!WJZ=T=WDUI5ZBG*T)H
MSY-S:1GRMJ-:E!)GYN%R()9./PV'GBY,5=;_B'I62^M9[?';Z`J%>B.1VNL?
M"85]ZQ\.AWL(#3U^5QZ$YWS]A_M/]"MOC1Z)?>-`H#-O6YU9,ZEF.Z?4&56*
M#L3[!X]"0\=H6!+<UX`;:KE0Z7:Q4S>2V7Q*HRM7=V9U(W^.=HRKV2S\&F9'
MWLC;6@K*FF69%NU()X:B4OPPTP[*[8QJ:2E)RNH34[KS;4O-R;:YE[IE4PJT
M7(@/C7Q33EZD'29MZ:,MIR4IF=548Z\4Z+"F02-M`SDII=L.KZ>,5%JK5$O/
M>@6>+2R?_ZI9>:PVX/P_)/YWA2+=_OC?W1V)K)[_IP'?B\4'ZNKJ*GP#_"%'
M&PF)`)U]@=?#<D!+D+Q"FDF=3\<9B>-:9#82UL[JMG*D4+$?<)UHKP>2@_;<
M5HX+A".VKP'<!1@4NE_SV/FRH*\#-@-^M<:8ON+C=P)N%>5MOK8W5NB_0_C@
MPIN`+8#;:]A[$O"JCW^EAAS]`KK>%[1!K-QBG<O7,YI8X_(-C.;6NCQO6*CP
MO'"[PK,5)<%U+M_(:*;"-S%ZJ<('N,^-+L^#[VS`Y=<S>KG";V#TS%:7YYLQ
M6^&_Q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