[libinline-java-perl] 119/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 b41f94882d688c596a86c3dee0909d2a7d494dab
Author: Patrick LeBoutillier <patl at cpan.org>
Date:   Fri Dec 7 18:59:17 2001 +0000

    *** empty log message ***
---
 Java.pm              | 112 ++++++++++++++-------------------------------------
 TODO                 |   3 +-
 t/07_polymorph.t     |  14 ++++++-
 t/12_exceptions.t    |   4 +-
 t/shared_jvm_test.pl |  17 ++++----
 5 files changed, 57 insertions(+), 93 deletions(-)

diff --git a/Java.pm b/Java.pm
index 6d69aaa..1cb0b68 100644
--- a/Java.pm
+++ b/Java.pm
@@ -34,6 +34,7 @@ use Inline::Java::Class ;
 use Inline::Java::Object ;
 use Inline::Java::Array ;
 use Inline::Java::Protocol ;
+use Inline::Java::Callback ;
 # Must be last.
 use Inline::Java::Init ;
 use Inline::Java::JVM ;
@@ -51,10 +52,6 @@ my $JVM = undef ;
 my $INLINES = {} ;
 
 
-# Stores the last uncaught exception
-my $UNCAUGHT_EXCEPTION = undef ;
-
-
 # Here is some code to figure out if we are running on command.com
 # shell under Windows.
 my $COMMAND_COM = 
@@ -202,9 +199,6 @@ sub _validate {
 			}
 			$o->{ILSM}->{$key} = $value ;
 		}
-		elsif ($key eq 'REMOTE_HOST'){
-			$o->{ILSM}->{$key} = $value ;
-		}
 		elsif ($key eq 'SHARED_JVM'){
 			$o->{ILSM}->{$key} = $value ;
 		}
@@ -245,12 +239,6 @@ sub _validate {
 	if (($o->{ILSM}->{JNI})&&($o->{ILSM}->{SHARED_JVM})){
 		croak("You can't use the 'SHARED_JVM' option in 'JNI' mode") ;
 	}
-	if (($o->{ILSM}->{JNI})&&($o->{ILSM}->{REMOTE_HOST})){
-		croak("You can't use the 'REMOTE_HOST' option in 'JNI' mode") ;
-	}
-	if (($o->{ILSM}->{REMOTE_HOST})&&($o->{ILSM}->{SHARED_JVM})){
-		croak("You can't use the 'REMOTE_HOST' option in combination with the 'SHARED_JVM' option") ;
-	}
 
 	$o->set_java_bin() ;
 
@@ -435,13 +423,18 @@ sub write_java {
 	if (! $study_only){
 		open(Inline::Java::JAVA, ">$build_dir/$modfname.java") or
 			croak "Can't open $build_dir/$modfname.java: $!" ;
-		Inline::Java::Init::DumpUserJavaCode(\*Inline::Java::JAVA, $modfname, $code) ;
+		Inline::Java::Init::DumpUserJavaCode(\*Inline::Java::JAVA, $code) ;
 		close(Inline::Java::JAVA) ;
 	}
 
 	open(Inline::Java::JAVA, ">$build_dir/InlineJavaServer.java") or
 		croak "Can't open $build_dir/InlineJavaServer.java: $!" ;
-	Inline::Java::Init::DumpServerJavaCode(\*Inline::Java::JAVA, $modfname) ;
+	Inline::Java::Init::DumpServerJavaCode(\*Inline::Java::JAVA) ;
+	close(Inline::Java::JAVA) ;
+
+	open(Inline::Java::JAVA, ">$build_dir/InlineJavaPerlCaller.java") or
+		croak "Can't open $build_dir/InlineJavaPerlCaller.java: $!" ;
+	Inline::Java::Init::DumpCallbackJavaCode(\*Inline::Java::JAVA) ;
 	close(Inline::Java::JAVA) ;
 
 	Inline::Java::debug("write_java done.") ;
@@ -684,31 +677,33 @@ sub set_classpath {
 	my @cp = split(/$sep/, join($sep, @list)) ;
 	my %cp = map { ($_ !~ /^\s*$/ ? ($_, 1) : ()) } @cp ;
 
-	foreach my $k (keys %cp){
-		if ($k =~ /\s*\[PERL_INLINE_JAVA=(.*?)\]\s*/){
-			my $modules = $1 ;
-			Inline::Java::debug("   found special CLASSPATH entry: $modules") ;
+	my $tmp = join($sep, keys %cp) ;
 
-			my @modules = split(/\s*,\s*/, $modules) ;
-			my $sep = portable("PATH_SEP") ;
-			my $sep_re = portable("PATH_SEP_RE") ;
-			my $dir = $o->get_config('DIRECTORY') . $sep . "lib" . $sep ."auto" ;
+	$tmp =~ s/\s*\[PERL_INLINE_JAVA\s*=\s*(.*?)\s*\]\s*/{
+		my $modules = $1 ;
+		Inline::Java::debug("   found special CLASSPATH entry: $modules") ;
+		
+		my @modules = split(m#\s*,\s*#, $modules) ;
+		my $psep = portable("PATH_SEP") ;
+		my $psep_re = portable("PATH_SEP_RE") ;
+		my $dir = $o->get_config('DIRECTORY') . $psep . "lib" . $psep ."auto" ;
 
-			foreach my $m (@modules){
-				$m =~ s/::/$sep_re/g ;
+		my %paths = () ;
+		foreach my $m (@modules){
+			$m =~ s#::#$psep_re#g ;
 
-				# Here we must make sure that the directory exists, or
-				# else it is removed from the CLASSPATH by Java
-				my $path = "$dir$sep$m" ;
-				$o->mkpath($path) ;
+			# Here we must make sure that the directory exists, or
+			# else it is removed from the CLASSPATH by Java
+			my $path = "$dir$psep$m" ;
+			$o->mkpath($path) ;
 
-				$cp{$path} = 1 ;
-			}
-
-			delete $cp{$k} ;
+			$paths{$path} = 1 ;
 		}
-	}
-	$ENV{CLASSPATH} = join($sep, keys %cp) ;
+
+		join($sep, keys %paths) ;
+	}/eg ;
+
+	$ENV{CLASSPATH} = $tmp ;
 
 	Inline::Java::debug("  classpath: " . $ENV{CLASSPATH}) ;
 }
@@ -755,7 +750,7 @@ sub report {
 		my @cl = glob("$pinstall/*.class") ;
 		foreach my $class (@cl){
 			$class =~ s/^\Q$pinstall\E\/(.*)\.class$/$1/ ;
-			if ($class !~ /^InlineJavaServer/){
+			if ($class !~ /^InlineJava(Server|Perl)/){
 				push @{$classes}, $class ;
 			}
 		}
@@ -1358,44 +1353,6 @@ sub study_classes {
 }
 
 
-sub try (&){
-	my $coderef = shift ;
-	eval {
-		$coderef->() ;
-	} ;
-	my $e = $@ ;
-	if ($e){
-		if (! UNIVERSAL::isa($e, "Inline::Java::Object")){
-			die $e ;
-		}
-
-		$UNCAUGHT_EXCEPTION = $@ ;
-		$@ = undef ;
-	}
-}
-
-
-sub catch ($$){
-	my $class = shift ;
-	my $coderef = shift ;
-
-	$class = Inline::Java::Class::ValidateClass($class) ;
-
-	my $e = $UNCAUGHT_EXCEPTION ;
-	if ($e){
-		if (UNIVERSAL::isa($e, "Inline::Java::Object")){
-			my ($msg, $score) = $e->__isa($class) ;
-			if ($msg){
-				croak $msg ;
-			}
-			$coderef->($e) ;
-			# clear $@ for other blocks that follow
-			$UNCAUGHT_EXCEPTION = undef ;
-		}
-	}
-}
-
-
 sub caught {
 	my $class = shift ;
 
@@ -1417,13 +1374,6 @@ sub caught {
 }
 
 
-sub with (&){
-	my $coderef = shift ;
-
-	return $coderef ;
-}
-
-
 1 ;
 
 __END__
diff --git a/TODO b/TODO
index 92538db..eb58166 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,5 @@
 CODE:
-- Localize filehandles
-
+- Callbacks
 
 TEST:
 - Add test script for configuration options (other than BIN)
diff --git a/t/07_polymorph.t b/t/07_polymorph.t
index 00c2d6d..c306f59 100644
--- a/t/07_polymorph.t
+++ b/t/07_polymorph.t
@@ -12,7 +12,7 @@ use Inline::Java qw(cast) ;
 
 
 BEGIN {
-	plan(tests => 17) ;
+	plan(tests => 18) ;
 }
 
 
@@ -43,6 +43,10 @@ my $t = new types7() ;
 	ok($t1->f($t2), "t1") ;
 	ok($t2->f($t1), "t2") ;
 	ok($t2->f(cast("t17", $t2)), "t2") ;
+
+	# Interfaces
+	my $al = $t1->get_al() ;
+	ok(0, $t1->count($al)) ;
 }
 
 ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
@@ -62,6 +66,14 @@ class t17 {
 	public String f(t27 o){
 		return "t1" ;
 	}
+
+	public ArrayList get_al(){
+		return new ArrayList() ;
+	}
+
+	public int count(Collection c){
+		return c.size() ;
+	}
 }
 
 
diff --git a/t/12_exceptions.t b/t/12_exceptions.t
index f5d4bd8..774e96a 100644
--- a/t/12_exceptions.t
+++ b/t/12_exceptions.t
@@ -24,10 +24,10 @@ my $t = new t9(0) ;
 		$t->f() ;
 	} ;
 	if ($@){
-		if (Inline::Java::caught("java.io.IOException")){
+		if (caught("java.io.IOException")){
 			$msg = $@->getMessage() . "io" ;
 		}
-		elsif (Inline::Java::caught("java.lang.Exception")){
+		elsif (caught("java.lang.Exception")){
 			$msg = $@->getMessage() ;
 		}
 		else {
diff --git a/t/shared_jvm_test.pl b/t/shared_jvm_test.pl
index 9124ed0..d4f5b07 100644
--- a/t/shared_jvm_test.pl
+++ b/t/shared_jvm_test.pl
@@ -1,3 +1,5 @@
+package shared_jvm_test ;
+
 use strict ;
 
 use blib ;
@@ -12,20 +14,21 @@ use Inline Config =>
            DIRECTORY => './_Inline_test' ;
 
 
-use Inline(
+use Inline (
 	Java => 'DATA',
+	NAME => "shared_jvm_test",
 	SHARED_JVM => 1,
 ) ;
 
 
-$t::i = 0 ;
+$shared_jvm_test::t::i = 0 ;
 
 my $nb = 10 ;
 my $sum = (($nb) * ($nb + 1)) / 2 ;
 for (my $i = 0 ; $i < $nb ; $i++){
 	if (! fork()){
 		print STDERR "." ;
-		do_child($i) ;
+		shared_jvm_test::do_child($i) ;
 	}
 }
 
@@ -37,7 +40,7 @@ for (my $i = 0 ; $i < 5 ; $i++){
 }
 print STDERR "\n" ;
 
-if ($t::i == $sum){
+if ($shared_jvm_test::t::i == $sum){
 	print STDERR "Test succeeded\n" ;
 }
 else{
@@ -50,7 +53,7 @@ sub do_child {
 
 	Inline::Java::reconnect_JVM() ;
 
-	my $t = new t() ;
+	my $t = new shared_jvm_test::t() ;
 	my $j = 0 ;
 	for ( ; $j <= $i ; $j++){
 		$t->incr_i() ;
@@ -59,14 +62,14 @@ sub do_child {
 }
 
 
-__END__
+__DATA__
 
 __Java__
 
 
 import java.util.* ;
 
-class t {
+class t extends InlineJavaPerlCaller {
 	static public int i = 0 ;
 
 	public t(){

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