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

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:42:48 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 eef7d6ebcfab8359e9172a288477283b13be59ea
Author: patrick <>
Date:   Tue Apr 17 15:12:53 2001 +0000

    *** empty log message ***
---
 Java.pm        | 14 ++++++++++----
 Java/JNI.pm    |  2 +-
 Java/Object.pm | 17 +++++++++++++----
 MANIFEST       |  1 +
 t/05_arrays.t  | 22 ++++++++++++++++++++--
 5 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/Java.pm b/Java.pm
index fdba498..5873100 100644
--- a/Java.pm
+++ b/Java.pm
@@ -15,8 +15,9 @@ if (! defined($Inline::Java::DEBUG)){
 	$Inline::Java::DEBUG = 0 ;
 }
 
+
 # Set DEBUG stream
-*DEBUG = *STDERR ;
+*DEBUG_STREAM = *STDERR ;
 
 
 require Inline ;
@@ -560,6 +561,7 @@ sub load_jdat {
 	
 	my $re = '[\w.\$\[;]+' ;
 
+	my $idx = 0 ;
 	my $current_class = undef ;
 	foreach my $line (@lines){
 		chomp($line) ;
@@ -579,6 +581,7 @@ sub load_jdat {
 				{
 					SIGNATURE => [split(", ", $signature)],
 					STATIC => 1,
+					IDX => $idx,
 				} ;
 		}
 		elsif ($line =~ /^method (\w+) ($re) (\w+)\((.*)\)$/){
@@ -595,6 +598,7 @@ sub load_jdat {
 				{
 					SIGNATURE => [split(", ", $signature)],
 					STATIC => ($static eq "static" ? 1 : 0),
+					IDX => $idx,
 				} ;
 		}
 		elsif ($line =~ /^field (\w+) ($re) (\w+) ($re)$/){
@@ -611,8 +615,10 @@ sub load_jdat {
 				{
 					TYPE => $type,
 					STATIC => ($static eq "static" ? 1 : 0),
+					IDX => $idx,
 				} ;
 		}
+		$idx++ ;
 	}
 
 	Inline::Java::debug_obj($d) ;
@@ -926,7 +932,7 @@ sub debug {
 	if ($Inline::Java::DEBUG){
 		my $str = join("", @_) ;
 		while (chomp($str)) {}
-		print DEBUG "perl $$: $str\n" ;
+		print DEBUG_STREAM "perl $$: $str\n" ;
 	}
 }
 
@@ -936,10 +942,10 @@ sub debug_obj {
 	my $pre = shift || "perl: " ;
 
 	if ($Inline::Java::DEBUG){
-		print DEBUG $pre . Dumper($obj) ;
+		print DEBUG_STREAM $pre . Dumper($obj) ;
 		if (UNIVERSAL::isa($obj, "Inline::Java::Object")){
 			# Print the guts as well...
-			print DEBUG $pre . Dumper($obj->__get_private()) ;
+			print DEBUG_STREAM $pre . Dumper($obj->__get_private()) ;
 		}
 	}
 }
diff --git a/Java/JNI.pm b/Java/JNI.pm
index 1068f5c..b4ae84c 100644
--- a/Java/JNI.pm
+++ b/Java/JNI.pm
@@ -13,7 +13,7 @@ eval {
 	Inline::Java::JNI->bootstrap($Inline::Java::JNI::VERSION) ;
 } ;
 if ($@){
-	croak "Can't load JNI module: $@" ;
+	croak "Can't load JNI module. Did you build it at install time?\nError: $@" ;
 }
 
 
diff --git a/Java/Object.pm b/Java/Object.pm
index 47023f2..c132590 100644
--- a/Java/Object.pm
+++ b/Java/Object.pm
@@ -87,6 +87,7 @@ sub __validate_prototype {
 	foreach my $s (values %{$protos}){
 		my $proto = $s->{SIGNATURE} ;
 		my $stat = $s->{STATIC} ;
+		my $idx = $s->{IDX} ;
 		my $new_args = undef ;
 		my $score = undef ;
 
@@ -114,6 +115,7 @@ sub __validate_prototype {
 			NB_ARGS =>	scalar(@{$new_args}),
 			SCORE =>	$score,
 			STATIC =>	$stat,
+			IDX =>		$idx,
 		} ;
 		push @matched, $h ;
 	}
@@ -139,14 +141,21 @@ sub __validate_prototype {
 	}
 
 	my $chosen = undef ;
-	my $max = 0 ;
 	foreach my $h (@matched){
+		my $idx = ($chosen ? $chosen->{IDX} : 0) ;
+		my $max = ($chosen ? $chosen->{SCORE} : 0) ;
+
 		my $s = $h->{SCORE} ;
-		if ($s >= $max){
+		my $i = $h->{IDX} ;
+		if ($s > $max){
+			$chosen = $h ;
+		}
+		elsif ($s == $max){
 			# Here if the scores are equal we take the last one since
 			# we start with inherited methods and move to class mothods
-			$max = $s ;
-			$chosen = $h ;
+			if ($i > $idx){
+				$chosen = $h ;
+			}
 		}
 	}
 
diff --git a/MANIFEST b/MANIFEST
index 38f0428..8069037 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -14,6 +14,7 @@ Java/Makefile.PL
 Java/JVM.pm
 Java/JNI.pm
 Java/JNI.xs
+Java/typemap
 t/1_init.t
 t/2_primitives.t
 t/3_objects.t
diff --git a/t/05_arrays.t b/t/05_arrays.t
index 54171a6..83fb70f 100644
--- a/t/05_arrays.t
+++ b/t/05_arrays.t
@@ -8,9 +8,8 @@ use Inline(
 	Java => 'DATA'
 ) ;
 
-
 BEGIN {
-	plan(tests => 31) ;
+	plan(tests => 36) ;
 }
 
 
@@ -41,6 +40,8 @@ ok($a->[0], "1") ;
 ok($a->[1], "two") ;
 ok(UNIVERSAL::isa($a->[2], "main::types")) ;
 ok($a->[2]->{data}->[1], "a") ;
+$a->[2]->{data} = ["1", "2"] ;
+ok($a->[2]->{data}->[1], 2) ;
 
 # Try some multidimensional arrays.
 $a = $t->_StringString([
@@ -57,6 +58,10 @@ $a = $t->_StringString([
 ]) ;
 ok($a->[1]->[0], undef) ;
 
+
+my $b = $a->[1] ;
+ok($t->_String($b)->[0], "STRING") ;
+
 # Arrays of other arrays
 $a = $t->_StringString([
 	$a->[0],
@@ -66,6 +71,17 @@ ok($a->[0]->[2], "02") ;
 # This is one of the things that won't work. 
 # Try passing an array as an Object.
 eval {$t->_o(["a", "b", "c"])} ; ok($@, qr/Can't create Java array/) ;
+ok($t->_o(Inline::Java::cast(
+	"java.lang.Object", 
+	["a", "b", "c"], 
+	"[Ljava.lang.String;"))->[0], "a") ;
+$t->{o} = Inline::Java::cast(
+	"java.lang.Object", 
+	["a", "b", "c"], 
+	"[Ljava.lang.String;") ;
+ok($t->{o}->[0], "a") ;
+$t->{o} = $t->{i} ;
+ok($t->{o}->[0], "1") ;
 
 # Mixed types
 eval {$t->_int(["3", "3456", "cat"])} ; ok($@, qr/Can't convert/) ;
@@ -82,6 +98,8 @@ __Java__
 
 
 class types {
+	public Object o ;
+	public int i[] = {1, 2, 3} ;
 	public String data[] = {"d", "a", "t", "a"} ;
 	public types(){
 	}

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