[libinline-java-perl] 274/398: 0.45

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:43:13 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 af1dbc22ad4bca2f87a713643384985788aa8073
Author: patrick_leb <>
Date:   Tue Jan 20 00:18:24 2004 +0000

    0.45
---
 Java/Callback.pm |   6 +++
 Java/JNI.xs      | 114 -------------------------------------------------------
 Java/Makefile.PL |  20 +++++-----
 3 files changed, 17 insertions(+), 123 deletions(-)

diff --git a/Java/Callback.pm b/Java/Callback.pm
index 718e722..fdca596 100644
--- a/Java/Callback.pm
+++ b/Java/Callback.pm
@@ -24,6 +24,12 @@ sub InterceptCallback {
 		my $function = $2 ;
 		my $cast_return = $3 ;
 		my @args = split(' ', $resp) ;
+
+		# "Relative" namespace...
+		if ($module =~ /^::/){
+			$module = $inline->{pkg} . $module ;
+		}
+
 		return Inline::Java::Callback::ProcessCallback($inline, $module, $function, $cast_return, @args) ;
 	}
 
diff --git a/Java/JNI.xs b/Java/JNI.xs
index b9a89b4..fbeee2d 100644
--- a/Java/JNI.xs
+++ b/Java/JNI.xs
@@ -64,27 +64,6 @@ void throw_ije(JNIEnv *env, char *msg){
 }
 
 
-/*
-	Here we simply check if an exception is pending an re-throw it
-*/
-int check_exception_from_java(JNIEnv *env){
-	jthrowable exc ;
-	int ret = 0 ;
-
-	exc = (*(env))->ExceptionOccurred(env) ;
-	if (exc != NULL){
-		/* (*(env))->ExceptionDescribe(env) ; */
-		(*(env))->ExceptionClear(env) ;
-		if ((*(env))->Throw(env, exc)){
-			(*(env))->FatalError(env, "Throw if InlineJava*Exception failed: exiting...") ;
-		}
-		ret = 1 ;
-	}
-
-	return ret ;
-}
-
-
 jstring JNICALL jni_callback(JNIEnv *env, jobject obj, jstring cmd){
 	dSP ;
 	jstring resp ;
@@ -142,99 +121,6 @@ jstring JNICALL jni_callback(JNIEnv *env, jobject obj, jstring cmd){
 }
 
 
-/*
-	This is the generic native function that callback java to call the proper
-	perl method.
-*/
-jobject JNICALL generic_perl_native(JNIEnv *env, jobject obj, ...){
-	va_list list ;
-	jclass cls ;
-	jmethodID mid ;
-	jstring jfmt ;
-	char *fmt ;
-	int fmt_len ;
-	jclass obj_cls ;
-	jobjectArray obj_array ;
-	jobject arg ;
-	int i ;
-	jobject ret = NULL ;
-
-	cls = (*(env))->GetObjectClass(env, obj) ;
-	mid = (*(env))->GetMethodID(env, cls, "LookupMethod", "()Ljava/lang/String;") ;
-	if (check_exception_from_java(env)){
-		return NULL ;
-	}
-
-	/* Call obj.LookupMethod to get the format string */
-	jfmt = (*(env))->CallObjectMethod(env, obj, mid) ;
-	if (check_exception_from_java(env)){
-		return NULL ;
-	}
-
-	fmt = (char *)((*(env))->GetStringUTFChars(env, jfmt, NULL)) ;
-	fmt_len = strlen(fmt) ;
-
-	obj_cls = (*(env))->FindClass(env, "java/lang/Object") ;
-	if (check_exception_from_java(env)){
-		return NULL ;
-	}
-
-	obj_array = (*(env))->NewObjectArray(env, fmt_len, obj_cls, NULL) ;
-	if (check_exception_from_java(env)){
-		return NULL ;
-	}
-
-	(*(env))->SetObjectArrayElement(env, obj_array, 0, obj) ;
-	if (check_exception_from_java(env)){
-		return NULL ;
-	}
-	va_start(list, obj) ;
-	for (i = 1 ; i < fmt_len ; i++){
-		arg = va_arg(list, jobject) ;
-		(*(env))->SetObjectArrayElement(env, obj_array, i, arg) ;
-		if (check_exception_from_java(env)){
-			return NULL ;
-		}
-	}
-	va_end(list) ;
-
-	/* Call obj.InvokePerlMethod and grab the returned object and return it */
-	mid = (*(env))->GetMethodID(env, cls, "InvokePerlMethod", "([Ljava/lang/Object;)Ljava/lang/Object;") ;
-	if (check_exception_from_java(env)){
-		return NULL ;
-	}
-
-	ret = (*(env))->CallObjectMethod(env, obj, mid, obj_array) ;		
-	if (check_exception_from_java(env)){
-		return NULL ;
-	}
-
-	return ret ;
-}
-
-
-/*
-	This function is used to register the specified native method and associate it with our magic
-	method that trap and redirects all the Perl native calls.
-*/
-JNIEXPORT void JNICALL Java_org_perl_inline_java_InlineJavaPerlNatives_RegisterMethod(JNIEnv *env, jobject obj, jclass cls, jstring name, jstring signature){
-	JNINativeMethod nm ;
-
-	/* Register the function */
-	nm.name = (char *)((*(env))->GetStringUTFChars(env, name, NULL)) ;
-	nm.signature = (char *)((*(env))->GetStringUTFChars(env, signature, NULL)) ;
-	nm.fnPtr = generic_perl_native ;
-
-	(*(env))->RegisterNatives(env, cls, &nm, 1) ;
-	(*(env))->ReleaseStringUTFChars(env, name, nm.name) ;
-	(*(env))->ReleaseStringUTFChars(env, signature, nm.signature) ;
-	if (check_exception_from_java(env)){
-		return ;
-	}
-}
-
-
-
 
 /*****************************************************************************/
 
diff --git a/Java/Makefile.PL b/Java/Makefile.PL
index cbca0fa..f3c0870 100644
--- a/Java/Makefile.PL
+++ b/Java/Makefile.PL
@@ -3,6 +3,7 @@ use File::Find ;
 
 use strict ;
 use File::Spec ;
+use Config ;
 
 require "Portable.pm" ;
 # The file we just produced in the parent Makefile.PL
@@ -55,14 +56,16 @@ print
 	"(JVM) to be dynamically linked with Perl instead of running as a separate\n" .
 	"process. The use of this extension is optional, and building it still\n" .
 	"allows Inline::Java to run the JVM in the default (separate process)\n" .
-	"fashion. Note: You need a C compiler to build the extension.\n\n" ;
+	"fashion.\n" .
+	"Note: You need a C compiler to build the extension.\n" ;
+	"Note: You must build the extension if you wish to use PerlNatives.\n" ;
 
 if (($build_jni || AskYN("Do you wish to build the JNI extension?", 'y'))){
 	print "\nBuilding JNI extension.\n\n" ;
 
 	$jdk_dir = Inline::Java::get_default_j2sdk() ;
 
-	find(\&search, $jdk_dir) ;
+	find({wanted => \&search, follow => 1, follow_skip => 2}, $jdk_dir) ;
 
 	my $type = FindDefaultVMType() ;
 	if (defined($type)){
@@ -111,25 +114,24 @@ if (($build_jni || AskYN("Do you wish to build the JNI extension?", 'y'))){
 			map {print "  $_\n"; } keys %so_dirs ;
 			print "See README.JNI for more information.\n\n" ;
 
-			my @I = (
+			@main::I = (
 				Inline::Java::Portable::portable('SUB_FIX_MAKE_QUOTES', 
 					"-I" . $files->{'jni.h'}->{selected}), 
 				Inline::Java::Portable::portable('SUB_FIX_MAKE_QUOTES', 
 					"-I" . $files->{'jni_md.h'}->{selected})) ; 
-			my @L = (
+			@main::L = (
 				Inline::Java::Portable::portable('SUB_FIX_MAKE_QUOTES', 
 					"-L" . $files->{$jvm_lib}->{selected})) ;
+
 			WriteMakefile(
 				NAME => 'Inline::Java::JNI',
 				VERSION_FROM => 'JNI.pm',
-				DIR => [],
+				DIR => ['Natives'],
 				PMLIBDIRS => [File::Spec->catdir('sources', 'org', 'perl', 'inline', 'java')],
-				INC => join(' ', @I),
-				LIBS => [join(' ', @L) . " -ljvm"],
+				INC => join(' ', @main::I),
+				LIBS => [join(' ', @main::L) . " -ljvm"],
 				# CCFLAGS => '-D_REENTRANT',
 			) ;
-
-			$main::build_jni = 'true' ;
 		}
 	}
 }

-- 
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