For v2003.06.01 Release $Revision: 1.56 $ Support: ------------- Language : Java Features : Component Testing - Code Coverage - Performance Profiling - Memory Profiling - Trace Tested Against: ------------------------ Host Machine : Windows 2000 - Sun Solaris 2.8 - Linux RedHat 7.2 - Linux RedHat 7.3 - Linux RedHat 8.0 - Linux Suse 8.1 Compiler : Java 2 Platform, Micro Edition Wireless Toolkit 1.03 Linker : Java 2 Platform, Micro Edition Wireless Toolkit 1.03 Debugger : Java 2 Platform, Micro Edition Wireless Toolkit 1.03 OS : Native Target : Native java jar -g -target 1.1 J2ME_RESTRICTION true SOCKET_UPLOAD true SOCKET_UPLOAD_DELIMITER ^ DEFAULT_BOOTCLASSPATH <Windows: Read and set from the registry when saved > ENV_PATH <Windows: Read and set from the registry when saved > COMPILER javac VIRTUALMACHINE emulator PREVERIFY preverify JAR jar DEBUGGER jdb Compiles the classes in the tmpclasses subdirectory. sub atl_cc($$$$\@\@) { my ( $lang,$src,$outDir,$cflags,$Defines,$Includes) = @_; # build the classpath my $separator = ($OSNAME eq "win32") ? ";" : ":"; my $bootclasspath = &BuildJavaBootClassPath("-bootclasspath ", $separator, ""); my $classpath = &BuildJavaClassPath("-classpath ", $separator, ""); my $COMP = $Ini{'COMPILER'}; if ( !$COMP ) { print "Error: no compiler known for target (lang:\"$lang\")\n"; return 1; } my $status=0; &CreateDirectory( "$outDir/tmpclasses" ); $status=SystemP( "$COMP -d \"$outDir/tmpclasses\" $bootclasspath $classpath \"$src\" $cflags" ); return $status; } 1; Preverifies the classes from the tmpclasses subdirectory to the classes subdirectory. Then build the Jar File. sub atl_link($\@$\@$) { my ($OutputFile,$Objects,$Manifest,$JarOtherDir,$OutputDir) = @_; # build the classpath my $separator = ($OSNAME eq "win32") ? ";" : ":"; my $classpath = &BuildCompleteJavaClassPath("-classpath ", $separator, ""); my $status=0; &CreateDirectory( "$OutputDir/classes" ); # Preverify: my $PREVERIFY = $Ini{'PREVERIFY'}; if ( !$PREVERIFY ) { print "Error: no preverify command known for target\n"; return 1; } $status=SystemP( "$PREVERIFY -d \"$OutputDir/classes\" $classpath \"$OutputDir/tmpclasses\"" ); return $status if ($status > 0); # Build jar file: my $JAR = $Ini{'JAR'}; if ( !$JAR ) { print "Error: no jar command known for target\n"; return 1; } $status=SystemP( "$JAR cfm \"$OutputFile\" $Manifest -C \"$OutputDir/classes\" ." ); return $status if ($status > 0); foreach $res (@$JarOtherDir) { $status=SystemP( "$JAR uf \"$OutputFile\" -C \"$res\" ." ); return $status if ($status > 0); } return $status; } 1; sub atl_exec($$$) { my ($JarFile,$MainClass,$Parameters) = @_; # build the classpath my $separator = ($OSNAME eq "win32") ? ";" : ":"; # JarFile is always used my $classpath = &BuildCompleteJavaClassPath("-classpath ", $separator, $JarFile); my $Vm = $Ini{'VIRTUALMACHINE'}; if ($OSNAME eq "win32") { if ( ! -f "emulator.bat" ) { # Copy the file emulator.bat from J2MEWTK delivery to current directory my ($emulator_bat) = split (/;/, $Ini{'ENV_PATH'}); $emulator_bat .= "\\emulator.bat"; copy ($emulator_bat, "emulator.bat"); } } my $status = 0; $status = SystemP( "$Vm $VIRTUAL_MACHINE_ARGUMENTS $classpath $MainClass $Parameters 0" ); print "\n"; return $status; } sub atl_execdbg($$$) { my ($JarFile,$MainClass,$Parameters) = @_; # build the classpath my $separator = ($OSNAME eq "win32") ? ";" : ":"; # JarFile is always used my $classpath = &BuildCompleteJavaClassPath("-classpath ", $separator, $JarFile); my $Vm = $Ini{'VIRTUALMACHINE'}; my $Debugger = $Ini{'DEBUGGER'}; if ($OSNAME eq "win32") { if ( ! -f "emulator.bat" ) { # Copy the file emulator.bat from J2MEWTK delivery to current directory my ($emulator_bat) = split (/;/, $Ini{'ENV_PATH'}); $emulator_bat .= "\\emulator.bat"; copy ($emulator_bat, "emulator.bat"); } SystemP( "$ENV{'COMSPEC'} /C START $Vm -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y $VIRTUAL_MACHINE_ARGUMENTS $classpath $MainClass $Parameters 0" ); sleep(10); SystemP( "$ENV{'COMSPEC'} /C START $Debugger -attach 8000" ); } else { SystemP( "$Vm -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y $VIRTUAL_MACHINE_ARGUMENTS $classpath $MainClass $Parameters 0 &" ); print "\n"; sleep(10); SystemP( "xterm -e $Debugger -attach 8000" ); } print "\n"; return 0; } 1; If you want to change the javic instrumenter written in perl, simply copy the contents of the lib/scripts/javic_j.pl here then modify it. die "Environment variable TESTRTDIR not found. Exiting.\n" if(!defined($ENV{'TESTRTDIR'})); # NO TRANSLATION require "$ENV{'TESTRTDIR'}/lib/scripts/javic_j.pl"; 1; use File::Copy; sub postGen() { my $d=shift; my $JavaHome; my $installDir; eval { require Win32::TieRegistry; import Win32::TieRegistry; my $Key = $Registry->{"HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit"}; return unless($Key); my $currentJdkVersion=$Key->{"CurrentVersion"}; return if($currentJdkVersion eq ""); $Key = $Registry->{"HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\$currentJdkVersion"}; return unless($Key); $JavaHome=$Key->{"JavaHome"}; $Key = $Registry->{"HKEY_LOCAL_MACHINE\\SOFTWARE\\Sun Microsystems, Inc.\\J2ME Wireless Toolkit"}; return unless($Key); my $latestVersion=$Key->{"LatestVersion"}; return if($latestVersion eq ""); $Key = $Registry->{"HKEY_LOCAL_MACHINE\\SOFTWARE\\Sun Microsystems, Inc.\\J2ME Wireless Toolkit\\$latestVersion"}; return unless($Key); $installDir=$Key->{"InstallDir"}; }; return if($@); return unless($JavaHome ne ""); return unless($installDir ne ""); # Patch the tp.ini file. my $atl_cc_in = $d ."\\tp.ini"; my $atl_cc_out = $d ."\\tp.ini.out"; open (IN, $atl_cc_in) or print "Can't open \"$atl_cc_in\"\n"; open (OUT, ">".$atl_cc_out) or print "Can't open \"$atl_cc_out\"\n"; while (<IN>) { s/DEFAULT_BOOTCLASSPATH=\"<Windows: Read and set from the registry when saved >\"/DEFAULT_BOOTCLASSPATH=\"$installDir\\lib\\midpapi.zip,$JavaHome\\jre\\lib\\rt.jar\"/; s/ENV_PATH=\"<Windows: Read and set from the registry when saved >\"/ENV_PATH=\"$installDir\\bin;$JavaHome\\bin;\$ENV{'PATH'}\"/; print OUT; } close (IN); close (OUT); # Rename the out file as the infile unlink ($atl_cc_in); rename ($atl_cc_out, $atl_cc_in); } 1; import java.io.*; JAVA_USR static { // Nothing to do } JAVA_USR public static void waitForThreads() { } public static byte [] threadName() { return null; } JAVA_USR public static java.io.OutputStream out_testrt = null; static final byte out_delimiter = (byte)'^'; public static void outOpen() { try { out_testrt = javax.microedition.io.Connector.openOutputStream ( Products.out_url ); String message = new java.lang.String ( "trtp://com.rational.testrealtime" ); out_testrt.write ( message.getBytes ( ) ); out_testrt.flush ( ); } catch ( java.io.IOException e ) { System.err.println ( "TestRT: com.rational.testrealtime.Custom: Cannot open OutputStream: " ); e.printStackTrace(); out_testrt = null; } } public static void outWrite(byte[] buffer, int index) { if ( out_testrt == null ) { return; } try { out_testrt.write ( out_delimiter ); out_testrt.write ( buffer, 0, index ); out_testrt.write ( out_delimiter ); out_testrt.flush ( ); } catch ( java.io.IOException e ) { System.err.println ( "TestRT: com.rational.testrealtime.Custom: Cannot write to OutputStream: " ); e.printStackTrace(); } } public static void outClose() { if ( out_testrt == null ) { return; } try { out_testrt.close ( ); } catch ( java.io.IOException e ) { System.err.println ( "TestRT: com.rational.testrealtime.Custom: Cannot close OutputStream: " ); e.printStackTrace(); } } public static void pushError ( String msg ) { System.err.println ( msg ); } JAVA_USR static final byte clock_unit[] = { (byte)'m', (byte)'s' }; public static long getClock() { return java.lang.System.currentTimeMillis ( ); } public static byte[] getClockUnit() { return clock_unit; } /* Add any extra includes or code */ JVMPI_STD JVMPI_USR int void *jvmpi_usr_malloc(JVMPI_SIZE_T size) { /* Code here the memory allocation function */ void *ptr=0; return(ptr); } void jvmpi_usr_free(void *ptr) { /* Code here the free function */ } JVMPI_STD JVMPI_USR FILE * JVMPI_FILE_TYPE jvmpi_usr_open(char *fileName) { /* Code here the open function */ JVMPI_FILE_TYPE f=(JVMPI_FILE_TYPE)0; return(f); } void *jvmpi_usr_write(JVMPI_FILE_TYPE file,char *buffer,int len) { /* Code here the write function */ } void *jvmpi_usr_close(JVMPI_FILE_TYPE file) { /* Code here the close function */ } JVMPI_STD JVMPI_USR void *jvmpi_usr_error(char *message) { /* Code here the error-print function */ printf("%s\n",message); } JVMPI_STD JVMPI_USR int jvmpi_usr_strncmp(const char *s1, const char *s2,JVMPI_SIZE_T n) { /* Code here the strncmp function */ } int jvmpi_usr_strcmp(const char *s1, const char *s2) { /* Code here the strcmp function */ return(0); } char *jvmpi_usr_strcpy(char *dest,const char *src) { /* Code here the strcpy function */ return(0); } char *jvmpi_usr_strstr(const char *haystack, const char *needle) { /* Code here the strstr function */ return(0); } JVMPI_SIZE_T jvmpi_usr_strlen(const char *s) { /* Code here the strlen function */ return(0); } JVMPI_STD JVMPI_USR unsigned long jvmpi_usr_getDateInMilliSec(void) { /* Code here the getDate function and return milliseconds */ } JVMPI_STD JVMPI_USR JVMPI_NONE int JVMPI_SOCKET_ID jvmpi_usr_connect(char *address,char *port) { /* Code here the connect function */ } int jvmpi_usr_recv(JVMPI_SOCKET_ID s,char *buffer,int len) { /* Code here the receive function */ } int jvmpi_usr_send(JVMPI_SOCKET_ID s,char *buffer,int len) { /* Code here the send function */ } int jvmpi_usr_socket_close(JVMPI_SOCKET_ID s) { /* Code here the close function */ } /* Add any extra code */ make --no_gen_finalize