[libinline-java-perl] 125/398: *** empty log message ***

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:42:56 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 94f1f544ee43c32aafd9136bba13cf7c6a261a10
Author: Patrick LeBoutillier <patl at cpan.org>
Date:   Fri Dec 14 13:17:36 2001 +0000

    *** empty log message ***
---
 Java.pm           |  12 +++++--
 Java/Array.pm     |   4 +--
 Java/Callback.pm  |  51 ++++++++++++++++++++++++++--
 Java/Class.pm     |  38 +++++++++++++++------
 Java/Init.pm      | 100 ++++++++++++++++++++++++++++++++++++++++++------------
 Java/JNI.pm       |  30 +++++++++++++++-
 Java/JNI.xs       |  59 ++++++++++++++++++++++++++++++++
 Java/JVM.pm       |  50 ++++++++++++++-------------
 MANIFEST          |   5 ++-
 Makefile.PL       |   6 +++-
 t/03_objects.t    |   6 +++-
 t/12_exceptions.t |   5 ++-
 t/13_callbacks.t  |  49 +++++++++++++++++++++++---
 13 files changed, 341 insertions(+), 74 deletions(-)

diff --git a/Java.pm b/Java.pm
index 1cb0b68..7fee281 100644
--- a/Java.pm
+++ b/Java.pm
@@ -242,6 +242,12 @@ sub _validate {
 
 	$o->set_java_bin() ;
 
+	# Moved the require here so that $Inline::Java::JNI::SO will
+	# be set in time for the generation of the Init.pm Java code.
+	if ($o->{ILSM}->{JNI}){
+		require Inline::Java::JNI ;
+	}
+
 	Inline::Java::debug("validate done.") ;
 }
 
@@ -1364,9 +1370,11 @@ sub caught {
 	if (($e)&&(UNIVERSAL::isa($e, "Inline::Java::Object"))){
 		my ($msg, $score) = $e->__isa($class) ;
 		if ($msg){
-			croak $msg ;
+			$ret = 0 ;
+		}
+		else{
+			$ret = 1 ;
 		}
-		$ret = 1 ;
 	}
 	$@ = $e ;
 
diff --git a/Java/Array.pm b/Java/Array.pm
index a670932..47c9c2b 100644
--- a/Java/Array.pm
+++ b/Java/Array.pm
@@ -636,8 +636,8 @@ __DATA__
 
 
 class InlineJavaArray {
-	InlineJavaServer ijs ;
-	InlineJavaClass ijc ;
+	private InlineJavaServer ijs ;
+	private InlineJavaClass ijc ;
 
 
 	InlineJavaArray(InlineJavaServer _ijs, InlineJavaClass _ijc){
diff --git a/Java/Callback.pm b/Java/Callback.pm
index b1911f6..1c23638 100644
--- a/Java/Callback.pm
+++ b/Java/Callback.pm
@@ -9,13 +9,60 @@ $Inline::Java::Callback::VERSION = '0.31' ;
 use Carp ;
 
 
+sub InterceptCallback {
+	my $inline = shift ;
+	my $resp = shift ;
+
+	# With JNI we need to store the object somewhere since we
+	# can't drag it along all the wat through Java land...
+	if (! defined($inline)){ 
+		$inline = $Inline::Java::JNI::INLINE_HOOK ;
+	}
+
+	if ($resp =~ s/^callback (.*?) (\w+)//){
+		my $module = $1 ;
+		my $function = $2 ;
+		my @args = split(' ', $resp) ;
+		return Inline::Java::Callback::ProcessCallback($inline, $module, $function, @args) ;
+	}
+
+	croak "Malformed callback request from server: $resp" ;
+}
+
+
+sub ProcessCallback {
+	my $inline = shift ;
+	my $module = shift ;
+	my $function = shift ;
+	my @sargs = @_ ;
+
+	my $pc = new Inline::Java::Protocol(undef, $inline) ;
+	my @args = map {$pc->DeserializeObject(0, $_)} @sargs ;
+
+	Inline::Java::debug(" processing callback $module" . "::" . "$function(" . 
+		join(", ", @args) . ")") ;
+
+	no strict 'refs' ;
+	my $sub = "$module" . "::" . $function ;
+	my $ret = $sub->(@args) ;
+
+	($ret) = $pc->ValidateArgs([$ret]) ;
+
+	return "callback $ret" ;
+}
+
+
 __DATA__
 
 /*
 	Callback to Perl...
 */
 public class InlineJavaPerlCaller {
-	protected InlineJavaPerlCaller(){
+	public InlineJavaPerlCaller(){
+		if (InlineJavaServer.instance == null){
+			System.err.println("Can't use InlineJavaPerlCaller outside of an Inline::Java context") ;
+			System.err.flush() ;
+		}
 	}
 
 
@@ -26,7 +73,7 @@ public class InlineJavaPerlCaller {
 	}
 
 
-	protected Object CallPerl(String pkg, String method, Object args[]) throws InlineJavaPerlCallerException {
+	public Object CallPerl(String pkg, String method, Object args[]) throws InlineJavaPerlCallerException {
 		try {
 			return InlineJavaServer.instance.Callback(pkg, method, args) ;
 		}
diff --git a/Java/Class.pm b/Java/Class.pm
index abf9c15..b083fb6 100644
--- a/Java/Class.pm
+++ b/Java/Class.pm
@@ -493,8 +493,8 @@ package Inline::Java::Class ;
 __DATA__
 
 class InlineJavaClass {
-	InlineJavaServer ijs ;
-	InlineJavaProtocol ijp ;
+	private InlineJavaServer ijs ;
+	private InlineJavaProtocol ijp ;
 
 	InlineJavaClass(InlineJavaServer _ijs, InlineJavaProtocol _ijp){
 		ijs = _ijs ;
@@ -685,16 +685,34 @@ class InlineJavaClass {
 		Returns the number of levels that separate a from b
 	*/
 	int DoesExtend(Class a, Class b){
-		// We need to check if a extends b
-		Class parent = a ;
-		int level = 0 ;
-		while (parent != null){
+		return DoesExtend(a, b, 0) ;
+	}
+
+
+	int DoesExtend(Class a, Class b, int level){
+		ijs.debug("   checking if " + a.getName() + " extends " + b.getName()) ;
+
+		if (a == b){
+			return level ;
+		}
+
+		Class parent = a.getSuperclass() ;
+		if (parent != null){
 			ijs.debug("    parent is " + parent.getName()) ;
-			if (parent == b){
-				return level ;
+			int ret = DoesExtend(parent, b, level + 1) ;
+			if (ret != -1){
+				return ret ;
+			}
+		}
+
+		// Maybe b is an interface a implements it?
+		Class inter[] = a.getInterfaces() ;
+		for (int i = 0 ; i < inter.length ; i++){
+			ijs.debug("    interface is " + inter[i].getName()) ;
+			int ret = DoesExtend(inter[i], b, level + 1) ;
+			if (ret != -1){
+				return ret ;
 			}
-			level++ ;
-			parent = parent.getSuperclass() ;
 		}
 
 		return -1 ;
diff --git a/Java/Init.pm b/Java/Init.pm
index 5eb53ef..4d234ad 100644
--- a/Java/Init.pm
+++ b/Java/Init.pm
@@ -36,6 +36,9 @@ sub DumpServerJavaCode {
 	$java =~ s/<INLINE_JAVA_CLASS>/$java_class/g ;
 	$java =~ s/<INLINE_JAVA_PROTOCOL>/$java_proto/g ;
 
+	my $so = $Inline::Java::JNI::SO || '' ;
+	$java =~ s/<INLINE_JAVA_JNI_SO>/$so/g ;
+
 	print $fh $java ;
 }
 
@@ -96,6 +99,7 @@ public class InlineJavaServer {
 		}
 		catch (IOException e){
 			System.err.println("Can't open server socket on port " + String.valueOf(port)) ;
+			System.err.flush() ;
 			System.exit(1) ;
 		}
 
@@ -114,6 +118,7 @@ public class InlineJavaServer {
 			}
 			catch (IOException e){
 				System.err.println("IO error: " + e.getMessage()) ;
+				System.err.flush() ;
 			}
 		}
 
@@ -131,6 +136,10 @@ public class InlineJavaServer {
 		it's best if it doesn't throw any exceptions.
 	*/
 	private String ProcessCommand(String cmd) {
+		return ProcessCommand(cmd, true) ;
+	}
+
+	private String ProcessCommand(String cmd, boolean addlf) {
 		debug("  packet recv is " + cmd) ;
 
 		String resp = null ;
@@ -139,12 +148,12 @@ public class InlineJavaServer {
 			try {
 				ijp.Do() ;
 				debug("  packet sent is " + ijp.response) ;
-				resp = ijp.response + "\n" ;
+				resp = ijp.response ;
 			}
 			catch (InlineJavaException e){
 				String err = "error scalar:" + ijp.unpack(e.getMessage()) ;
 				debug("  packet sent is " + err) ;
-				resp = err + "\n" ;
+				resp = err ;
 			}
 		}
 		else{
@@ -159,6 +168,10 @@ public class InlineJavaServer {
 			}
 		}
 
+		if (addlf){
+			resp = resp + "\n" ;
+		}
+
 		return resp ;
 	}
 
@@ -242,40 +255,65 @@ public class InlineJavaServer {
 
 
 	public Object Callback(String pkg, String method, Object args[]) throws InlineJavaException {
+		Object ret = null ;
+
 		try {
-			Thread t = Thread.currentThread() ;
-			if (t instanceof InlineJavaThread){
-				// Client-server mode
-				InlineJavaProtocol ijp = new InlineJavaProtocol(this, null) ;
-				StringBuffer cmd = new StringBuffer("callback " + pkg + " " + method) ;
-				if (args != null){
-					for (int i = 0 ; i < args.length ; i++){
-						 cmd.append(" " + ijp.SerializeObject(args[i])) ;
-					}
+			InlineJavaProtocol ijp = new InlineJavaProtocol(this, null) ;
+			InlineJavaClass ijc = new InlineJavaClass(this, ijp) ;
+			StringBuffer cmdb = new StringBuffer("callback " + pkg + " " + method) ;
+			if (args != null){
+				for (int i = 0 ; i < args.length ; i++){
+					 cmdb.append(" " + ijp.SerializeObject(args[i])) ;
 				}
-				System.out.println("Callback command: " + cmd.toString()) ;
-				debug("Callback command: " + cmd.toString()) ;
+			}
+			String cmd = cmdb.toString() ;
+			debug(" callback command: " + cmd) ;
 
-				InlineJavaThread ijt = (InlineJavaThread)t ;
-				ijt.bw.write(cmd.toString() + "\n") ;
-				ijt.bw.flush() ;			
+			Thread t = Thread.currentThread() ;
+			String resp = null ;
+			while (true) {			
+				debug("  packet sent (callback) is " + cmd) ;
+				if (t instanceof InlineJavaThread){
+					// Client-server mode
+					InlineJavaThread ijt = (InlineJavaThread)t ;
+					ijt.bw.write(cmd + "\n") ;
+					ijt.bw.flush() ;
+
+					resp = ijt.br.readLine() ;
+				}
+				else{
+					// JNI mode
+					resp = jni_callback(cmd) ;
+				}
+				debug(" packet recv (callback) is " + resp) ;
 
-				String resp = ijt.br.readLine() ;
+				StringTokenizer st = new StringTokenizer(resp, " ") ;
+				String c = st.nextToken() ;
+				if (c.equals("callback")){
+					String arg = st.nextToken() ;
+					ret = ijc.CastArgument(java.lang.Object.class, arg) ;
+					break ;
+				}	
+				else{
+					// Pass it on through the regular channel...
+					debug(" packet is not callback response: " + resp) ;
+					cmd = ProcessCommand(resp, false) ;
 
-				System.out.println("Callback response: " + resp) ;
-			}
-			else{
-				// JNI mode
+					continue ;
+				}
 			}
 		}
 		catch (IOException e){
 			throw new InlineJavaException("IO error: " + e.getMessage()) ;
 		}
 
-		return null ;
+		return ret ;
 	}
 
 
+	native private String jni_callback(String cmd) ;
+
+
 	/*
 		Creates a string representing a method signature
 	*/
@@ -314,6 +352,24 @@ public class InlineJavaServer {
 
 
 	public static InlineJavaServer jni_main(boolean debug) {
+		String so = "<INLINE_JAVA_JNI_SO>" ;
+		if (! so.equals("")){
+			try {
+				System.load(so) ;
+			}
+			catch (UnsatisfiedLinkError e){
+				System.err.println("Can't load shared object '" + so + "' required for callbacks") ;
+				System.err.flush() ;
+				System.exit(1) ;
+			}
+		}
+		else{
+			System.err.println("JNI shared object not specified (required for callbacks)") ;
+			System.err.println("Perhaps your Java code was not initially built in JNI mode") ;
+			System.err.flush() ;
+			System.exit(1) ;
+		}
+
 		return new InlineJavaServer(debug) ;
 	}
 	
diff --git a/Java/JNI.pm b/Java/JNI.pm
index b4ae84c..653ab93 100644
--- a/Java/JNI.pm
+++ b/Java/JNI.pm
@@ -4,18 +4,46 @@ package Inline::Java::JNI ;
 
 use strict ;
 
-$Inline::Java::JNI::VERSION = '0.20' ;
+$Inline::Java::JNI::VERSION = '0.31' ;
 
 use Carp ;
+use File::Basename ;
+
+
+# A place to attach the Inline object that is currently in Java land
+$Inline::Java::JNI::INLINE_HOOK = undef ;
+
+# The full path to the shared object loaded by JNI
+$Inline::Java::JNI::SO = '' ;
 
 
 eval {
 	Inline::Java::JNI->bootstrap($Inline::Java::JNI::VERSION) ;
+	
+	if (! $Inline::Java::JNI::SO){
+		croak "Can't find JNI shared object!" ;
+	}
+
+	Inline::Java::debug("JNI shared object is '$Inline::Java::JNI::SO'") ;
 } ;
 if ($@){
 	croak "Can't load JNI module. Did you build it at install time?\nError: $@" ;
 }
 
 
+# This is a *NASTY* way to get the shared object file that was loaded 
+# by DynaLoader
+sub dl_load_flags {
+	my $so = $DynaLoader::file ;
+	my $dir = dirname($so) ;
+	my $f = basename($so) ;
+	my $sep = Inline::Java::portable("PATH_SEP") ;
+
+	$Inline::Java::JNI::SO = Cwd::abs_path($dir) . $sep . $f ;
+
+	return DynaLoader::dl_load_flags() ;
+}
+
+
 
 1 ;
diff --git a/Java/JNI.xs b/Java/JNI.xs
index 0c08db0..5a86231 100644
--- a/Java/JNI.xs
+++ b/Java/JNI.xs
@@ -22,6 +22,45 @@ void debug_ex(InlineJavaJNIVM *this){
 }
 
 
+JNIEXPORT jstring JNICALL Java_InlineJavaServer_jni_1callback(
+	JNIEnv *env, jobject obj, jstring cmd){
+
+	dSP ;
+	jstring resp = NULL ;
+	char *c = (char *)((*(env))->GetStringUTFChars(env, cmd, NULL)) ;
+	char *r = NULL ;
+	int count = 0 ;
+
+	ENTER ;
+	SAVETMPS ;
+
+	PUSHMARK(SP) ;
+	XPUSHs(&PL_sv_undef) ;
+	XPUSHs(sv_2mortal(newSVpv(c, 0))) ;
+	PUTBACK ;
+
+	count = perl_call_pv("Inline::Java::Callback::InterceptCallback", 
+		G_SCALAR) ;
+
+	SPAGAIN ;
+
+	if (count != 1){
+		croak("Invalid return value from Inline::Java::Callback::InterceptCallback: %d",
+			count) ;
+	}
+
+	r = (char *)POPp ;
+	resp = (*(env))->NewStringUTF(env, r) ;
+
+	PUTBACK ;
+	FREETMPS ;
+	LEAVE ;
+
+	return resp ;
+}
+
+
+
 MODULE = Inline::Java::JNI   PACKAGE = Inline::Java::JNI
 
 
@@ -87,11 +126,19 @@ create_ijs(this)
 
 	CODE:
 	this->ijs_class = (*(this->env))->FindClass(this->env, "InlineJavaServer") ;
+	if ((*(this->env))->ExceptionOccurred(this->env)){
+		(*(this->env))->ExceptionDescribe(this->env) ;
+		croak("Exception occured") ;
+	}
 	if (this->ijs_class == NULL){
 		croak("Can't find class InlineJavaServer") ;
 	}
 
 	mid = (*(this->env))->GetStaticMethodID(this->env, this->ijs_class, "jni_main", "(Z)LInlineJavaServer;") ;
+	if ((*(this->env))->ExceptionOccurred(this->env)){
+		(*(this->env))->ExceptionDescribe(this->env) ;
+		croak("Exception occured") ;
+	}
 	if (mid == NULL) {
 		croak("Can't find method jni_main in class InlineJavaServer") ;
 	}
@@ -115,6 +162,10 @@ process_command(this, data)
 
 	CODE:
 	mid = (*(this->env))->GetMethodID(this->env, this->ijs_class, "ProcessCommand", "(Ljava/lang/String;)Ljava/lang/String;") ;
+	if ((*(this->env))->ExceptionOccurred(this->env)){
+		(*(this->env))->ExceptionDescribe(this->env) ;
+		croak("Exception occured") ;
+	}
 	if (mid == NULL) {
 		croak("Can't find method ProcessCommand in class InlineJavaServer") ;
 	}
@@ -157,11 +208,19 @@ report(this, module, classes, nb_classes)
 
 	CODE:
 	mid = (*(this->env))->GetMethodID(this->env, this->ijs_class, "Report", "([Ljava/lang/String;I)V") ;
+	if ((*(this->env))->ExceptionOccurred(this->env)){
+		(*(this->env))->ExceptionDescribe(this->env) ;
+		croak("Exception occured") ;
+	}
 	if (mid == NULL) {
 		croak("Can't find method Report in class InlineJavaServer") ;
 	}
 
 	class = (*(this->env))->FindClass(this->env, "java/lang/String") ;
+	if ((*(this->env))->ExceptionOccurred(this->env)){
+		(*(this->env))->ExceptionDescribe(this->env) ;
+		croak("Exception occured") ;
+	}
 	if (class == NULL){
 		croak("Can't find class java.lang.String") ;
 	}
diff --git a/Java/JVM.pm b/Java/JVM.pm
index f153975..03e59b1 100644
--- a/Java/JVM.pm
+++ b/Java/JVM.pm
@@ -25,8 +25,6 @@ sub new {
 	if ($o->get_java_config('JNI')){
 		Inline::Java::debug("  JNI mode") ;
 
-		require Inline::Java::JNI ;
-
 		my $jni = new Inline::Java::JNI(
 			$ENV{CLASSPATH} || "",
 			(Inline::Java::get_DEBUG() ? 1 : 0),
@@ -216,35 +214,39 @@ sub reconnect {
 
 sub process_command {
 	my $this = shift ;
+	my $inline = shift ;
 	my $data = shift ;
 
-	Inline::Java::debug("  packet sent is $data") ;
-
 	my $resp = undef ;
-	if ($this->{socket}){
-		my $sock = $this->{socket} ;
-		print $sock $data . "\n" or
-			croak "Can't send packet to JVM: $!" ;
-
-		$resp = <$sock> ;
-		if (! $resp){
-			croak "Can't receive packet from JVM: $!" ;
-		}
-	}
-	if ($this->{JNI}){
-		$resp = $this->{JNI}->process_command($data) ;
-	}
-
-	# We got an answer from the server. Is it a callback?
-	if ($resp =~ s/^callback //){
-		print "Callback!!! ($resp)\n" ;
-	}
-
+	while (1){
+		Inline::Java::debug("  packet sent is $data") ;
 
+		if ($this->{socket}){
+			my $sock = $this->{socket} ;
+			print $sock $data . "\n" or
+				croak "Can't send packet to JVM: $!" ;
 
+			$resp = <$sock> ;
+			if (! $resp){
+				croak "Can't receive packet from JVM: $!" ;
+			}
+		}
+		if ($this->{JNI}){
+			$Inline::Java::JNI::INLINE_HOOK = $inline ;
+			$resp = $this->{JNI}->process_command($data) ;
+		}
 
+		Inline::Java::debug("  packet recv is $resp") ;
 
-	Inline::Java::debug("  packet recv is $resp") ;
+		# We got an answer from the server. Is it a callback?
+		if ($resp =~ /^callback/){
+			$data = Inline::Java::Callback::InterceptCallback($inline, $resp) ;
+			next ;
+		}
+		else{
+			last ;
+		}
+	}
 
 	return $resp ;
 }
diff --git a/MANIFEST b/MANIFEST
index 7479755..2ebc7d4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -6,6 +6,7 @@ TODO
 Makefile.PL
 shared_jvm_server.pl
 shared_jvm_test.pl
+swing_gui_test.pl
 Java.pm
 Java.pod
 Java/Init.pm
@@ -28,10 +29,8 @@ t/06_static.t
 t/07_polymorph.t
 t/08_study.t
 t/09_exceptions.t
-t/___pod.t
+t/10_callbacks.t
 t/types.java
 t/types.class
 t/no_const.java
 t/no_const.class
-
-
diff --git a/Makefile.PL b/Makefile.PL
index 1faeb64..fd8a7bf 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -3,6 +3,7 @@ use ExtUtils::MakeMaker;
 
 # So that the the sub dir Makefile.PL will see it...
 $main::JNI_BUILD = 0 ;
+$main::JNI_VM = "classic" ;
 
 
 # In case we had built differently a previous time
@@ -15,8 +16,11 @@ foreach my $arg (@ARGV){
 	$a =~ s/^\s+// ;
 	$a =~ s/\s+$// ;
 
-	if ($a =~ /^JNI$/i){
+	if ($a =~ /^JNI(:(\w+))?$/i){
 		$JNI_BUILD = 1 ;
+		if ($2){
+			$main::JNI_VM = $2 ;			
+		}
 	}
 	elsif ($a =~ /^FIX$/i){
 		$fix_makefile = 1 ;
diff --git a/t/03_objects.t b/t/03_objects.t
index d89af16..86e2fa1 100644
--- a/t/03_objects.t
+++ b/t/03_objects.t
@@ -10,7 +10,7 @@ use Inline(
 
 
 BEGIN {
-	plan(tests => 14) ;
+	plan(tests => 15) ;
 }
 
 
@@ -47,6 +47,10 @@ my $t = new types3() ;
 	
 	# Return a scalar hidden in an object.
 	ok($t->_olong(), 12345) ;
+
+	# Pass a non-Java object.
+	my $d = bless({}, "Inline::Java::dummy") ;
+	eval {$t->_Object($d)} ; ok($@, qr/Can't convert/) ;
 }
 
 ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
diff --git a/t/12_exceptions.t b/t/12_exceptions.t
index 774e96a..81186f8 100644
--- a/t/12_exceptions.t
+++ b/t/12_exceptions.t
@@ -110,7 +110,10 @@ my $t = new t9(0) ;
 		$t2->len(undef) ;
 	} ;
 	if ($@){
-		if (caught("java.lang.Exception")){
+		if (caught("java.lang.IOException")){
+			$msg = "io" ;
+		}
+		elsif (caught("java.lang.Exception")){
 			$msg = "null" ;
 		}
 		else{
diff --git a/t/13_callbacks.t b/t/13_callbacks.t
index 04c70d8..6a16f47 100644
--- a/t/13_callbacks.t
+++ b/t/13_callbacks.t
@@ -14,10 +14,7 @@ use Inline::Java qw(caught) ;
 
 
 BEGIN {
-	print STDERR "\nWARNING: Callbacks are still experimental and are possibly unstable!\n" ;
-	print STDERR "WARNING: Callback API can still change and might not be backwards compatible!\n" ;
-
-	plan(tests => 9) ;
+	plan(tests => 12) ;
 }
 
 my $t = new t10() ;
@@ -32,7 +29,24 @@ my $t = new t10() ;
 		ok($t->silly_mul_via_perl(3, 2), 6) ;
 
 		ok(add_via_java(3, 4), 7) ;
+
 		ok($t->add_via_perl_via_java(3, 4), 7) ;
+		ok($t->silly_mul_via_perl_via_java(10, 9), 90) ;
+
+		eval {$t->death_via_perl()} ; ok($@, qr/death/) ;
+
+		my $msg = '' ;
+		eval {$t->except()} ; 
+		if ($@) {
+			if (caught('InlineJavaPerlCaller$InlineJavaPerlCallerException')){
+				$msg = $@->getMessage() ;
+			}
+			else{
+				die $@ ;
+			}
+		}
+		ok($msg, "test") ;
+	
 	} ;
 	if ($@){
 		if (caught("java.lang.Throwable")){
@@ -71,6 +85,12 @@ sub add_via_java {
 	return $t->add($i, $j) ;
 }
 
+
+sub death {
+	die("death") ;
+}
+
+
 __END__
 
 __Java__
@@ -103,7 +123,7 @@ class t10 extends InlineJavaPerlCaller {
 		for (int i = 0 ; i < b ; i++){
 			ret = add_via_perl(ret, a) ;
 		}
-		return a * b ;
+		return ret ;
 	}
 
 
@@ -114,6 +134,15 @@ class t10 extends InlineJavaPerlCaller {
 		return new Integer(val).intValue() ;
 	}
 
+	public void death_via_perl() throws InlineJavaPerlCallerException {		
+		InlineJavaPerlCaller c = new InlineJavaPerlCaller() ;
+		c.CallPerl("main", "death", null) ;
+	}
+
+	public void except() throws InlineJavaPerlCallerException {		
+		throw new InlineJavaPerlCaller.InlineJavaPerlCallerException("test") ;
+	}
+
 	public int mul_via_perl(int a, int b) throws InlineJavaPerlCallerException {
 		String val = (String)CallPerl("main", "mul", 
 			new Object [] {new Integer(a), new Integer(b)}) ;
@@ -127,5 +156,15 @@ class t10 extends InlineJavaPerlCaller {
 
 		return new Integer(val).intValue() ;
 	}
+
+	public int silly_mul_via_perl_via_java(int a, int b) throws InlineJavaPerlCallerException {
+		int ret = 0 ;
+		for (int i = 0 ; i < b ; i++){
+			String val = (String)CallPerl("main", "add_via_java", 
+				new Object [] {new Integer(ret), new Integer(a)}) ;
+			ret = new Integer(val).intValue() ;
+		}
+		return ret ;
+	}
 }
 

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