[libinline-java-perl] 354/398: Fixed bug in JVM arg processing

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:43:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.55
in repository libinline-java-perl.

commit a7e024922110daa4d10eebb49201751cb8cac34d
Author: patrick_leb <>
Date:   Sat Sep 10 01:09:26 2005 +0000

    Fixed bug in JVM arg processing
---
 Java/JNI.xs   | 29 +++++++++++++++++++++--------
 t/09_usages.t | 10 +++++++++-
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/Java/JNI.xs b/Java/JNI.xs
index 4dd8c46..74e0a10 100644
--- a/Java/JNI.xs
+++ b/Java/JNI.xs
@@ -140,11 +140,13 @@ new(CLASS, classpath, args, embedded, debug)
 
 	PREINIT:
 	JavaVMInitArgs vm_args ;
-	JavaVMOption options[8] ;
+	JavaVMOption options[128] ;
 	JNIEnv *env ;
 	JNINativeMethod nm ;
 	jint res ;
 	char *cp ;
+	char *al ;
+	char *alsep ;
 
     CODE:
 	RETVAL = (InlineJavaJNIVM *)safemalloc(sizeof(InlineJavaJNIVM)) ;
@@ -158,16 +160,24 @@ new(CLASS, classpath, args, embedded, debug)
 
 	vm_args.version = JNI_VERSION_1_2 ;
 	vm_args.options = options ;
-	vm_args.nOptions = 2 ;
+	vm_args.nOptions = 0 ;
 	vm_args.ignoreUnrecognized = JNI_FALSE ;
 
-	options[0].optionString = ((RETVAL->debug > 5) ? "-verbose" : "-verbose:") ;
-	cp = (char *)malloc((strlen(classpath) + 128) * sizeof(char)) ;
-	sprintf(cp, "-Djava.class.path=%s", classpath, args) ;
-	options[1].optionString = cp ;
+	options[vm_args.nOptions++].optionString = 
+		((RETVAL->debug > 5) ? "-verbose" : "-verbose:") ;
+	cp = (char *)malloc((strlen(classpath) + 32) * sizeof(char)) ;
+	sprintf(cp, "-Djava.class.path=%s", classpath) ;
+	options[vm_args.nOptions++].optionString = cp ;
+
+	al = NULL ;
 	if (strlen(args) > 0){
-		options[2].optionString = args ;
-		vm_args.nOptions++ ;
+		al = (char *)malloc((strlen(args) + 1) * sizeof(char)) ;
+		strcpy(al, args) ;
+		alsep = strtok(al, " ") ;
+		while (alsep != NULL){
+			options[vm_args.nOptions++].optionString = alsep ;
+    		alsep = strtok(NULL, " ") ;
+		}	
 	}
 
 	/* Embedded patch and idea by Doug MacEachern */
@@ -195,6 +205,9 @@ new(CLASS, classpath, args, embedded, debug)
 	}
 
 	free(cp) ;
+	if (al != NULL){
+		free(al) ;
+	}
 
 
 	/* Load the classes that we will use */
diff --git a/t/09_usages.t b/t/09_usages.t
index 34b1628..93badb1 100755
--- a/t/09_usages.t
+++ b/t/09_usages.t
@@ -7,7 +7,7 @@ use Inline Config =>
 
 
 BEGIN {
-	plan(tests => 4) ;
+	plan(tests => 6) ;
 }
 
 
@@ -20,9 +20,14 @@ use Inline(
 
 			public t09p1(){
 			}
+
+			public static String get_prop(int n){
+				return System.getProperty("prop" + n) ;
+			}
 		}
 	|,
 	NAME => 't09::p1',
+	EXTRA_JAVA_ARGS => '-Dprop1=a -Dprop2=b',
 ) ;
 
 
@@ -43,6 +48,7 @@ Inline->bind(
 	Java => qq |
 		class t09p3 {
 			public static String name = "p3" ;
+
 		}
 	|,
 	NAME => 't09::p3',
@@ -55,6 +61,8 @@ my $t = new t09::p1::t09p1() ;
 
 {
 	ok($t->{name}, "p1") ;
+	ok($t->get_prop(1), 'a') ;
+	ok($t->get_prop(2), 'b') ;
 	ok($t09::p2::t09p2::name . $t09::p3::t09p3::name, "p2p3") ;
 	ok($t09::p2::t09p2::name . $t09::p3::t09p3::name, "p2p3") ;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libinline-java-perl.git



More information about the Pkg-perl-cvs-commits mailing list