[libinline-java-perl] 351/398: ok v_50_90

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 598dbcc1780cf4a9f115926f70535f213019816c
Author: patrick_leb <>
Date:   Sun Sep 4 16:13:03 2005 +0000

    ok v_50_90
---
 Java.pm                                      |   5 +-
 Java/Array.pm                                |   2 +-
 Java/Callback.pm                             |   2 +-
 Java/Class.pm                                |   2 +-
 Java/Handle.pm                               |  11 ++-
 Java/JNI.pm                                  |   2 +-
 Java/JVM.pm                                  |   5 +-
 Java/Makefile.PL                             |   5 +-
 Java/Object.pm                               |   2 +-
 Java/PerlInterpreter/PerlInterpreter.pm      |   2 +-
 Java/PerlInterpreter/t/02_perl_interpreter.t |   7 +-
 Java/PerlNatives/PerlNatives.pm              |   2 +-
 Java/Portable.pm                             |  13 ++-
 Java/Protocol.pm                             | 139 ++++++++++++++++++++++-----
 Java/Server.pm                               |   2 +-
 MANIFEST                                     |   2 +
 Makefile.PL                                  |   9 +-
 t/13_handles.t                               |   4 +-
 18 files changed, 166 insertions(+), 50 deletions(-)

diff --git a/Java.pm b/Java.pm
index 95097e4..34c8274 100644
--- a/Java.pm
+++ b/Java.pm
@@ -358,8 +358,9 @@ sub build {
 		close(Inline::Java::JAVA) ;
 
 		# ... and compile it.
-		my $javac = File::Spec->catfile($o->get_java_config('J2SDK'), 'bin', 
-		"javac" . Inline::Java::Portable::portable("EXE_EXTENSION")) ;
+		my $javac = File::Spec->catfile($o->get_java_config('J2SDK'), 
+			Inline::Java::Portable::portable("J2SDK_BIN"), 
+			"javac" . Inline::Java::Portable::portable("EXE_EXTENSION")) ;
 		my $redir = Inline::Java::Portable::portable("IO_REDIR") ;
 
 		my $args = "-deprecation " . $o->get_java_config('EXTRA_JAVAC_ARGS') ;
diff --git a/Java/Array.pm b/Java/Array.pm
index 32c458b..baf060d 100644
--- a/Java/Array.pm
+++ b/Java/Array.pm
@@ -4,7 +4,7 @@ package Inline::Java::Array ;
 use strict ;
 use Carp ;
 
-$Inline::Java::Array::VERSION = '0.50' ;
+$Inline::Java::Array::VERSION = '0.50_90' ;
 
 # Here we store as keys the knots and as values our blessed objects
 my $OBJECTS = {} ;
diff --git a/Java/Callback.pm b/Java/Callback.pm
index b96e1d9..3daf2eb 100644
--- a/Java/Callback.pm
+++ b/Java/Callback.pm
@@ -3,7 +3,7 @@ package Inline::Java::Callback ;
 use strict ;
 use Carp ;
 
-$Inline::Java::Callback::VERSION = '0.50' ;
+$Inline::Java::Callback::VERSION = '0.50_90' ;
 
 $Inline::Java::Callback::OBJECT_HOOK = undef ;
 
diff --git a/Java/Class.pm b/Java/Class.pm
index a39e3e8..7e99093 100644
--- a/Java/Class.pm
+++ b/Java/Class.pm
@@ -3,7 +3,7 @@ package Inline::Java::Class ;
 use strict ;
 use Carp ;
 
-$Inline::Java::Class::VERSION = '0.50' ;
+$Inline::Java::Class::VERSION = '0.50_90' ;
 
 $Inline::Java::Class::MAX_SCORE = 10 ;
 
diff --git a/Java/Handle.pm b/Java/Handle.pm
index eaf2d7a..f0f9394 100644
--- a/Java/Handle.pm
+++ b/Java/Handle.pm
@@ -144,18 +144,19 @@ sub AUTOLOAD {
 sub DESTROY {
 	my $this = shift ;
 
-	my $obj = $this->__get_object() ;
-	if (! $obj->__get_private()->{closed}){
-		$this->__close() ;	
-	}
 
 	my $knot = tied *{$this} ;
 	if (! $knot){
 		Inline::Java::debug(4, "destroying Inline::Java::Handle::Tie") ;
 
+		my $obj = $this->__get_object() ;
+		if (! $obj->__get_private()->{closed}){
+		 	$this->__close() ;	
+		}
+
 		$OBJECTS->{$this} = undef ;
 	}
-	else{
+	else {
 		Inline::Java::debug(4, "destroying Inline::Java::Handle") ;
 	}
 }
diff --git a/Java/JNI.pm b/Java/JNI.pm
index be6cc7f..52d9499 100644
--- a/Java/JNI.pm
+++ b/Java/JNI.pm
@@ -4,7 +4,7 @@ package Inline::Java::JNI ;
 
 use strict ;
 
-$Inline::Java::JNI::VERSION = '0.50' ;
+$Inline::Java::JNI::VERSION = '0.50_90' ;
 
 use DynaLoader ;
 use Carp ;
diff --git a/Java/JVM.pm b/Java/JVM.pm
index c1677a8..b8bec65 100644
--- a/Java/JVM.pm
+++ b/Java/JVM.pm
@@ -8,7 +8,7 @@ use IPC::Open3 ;
 use IO::Socket ;
 use Inline::Java::Portable ;
 
-$Inline::Java::JVM::VERSION = '0.50' ;
+$Inline::Java::JVM::VERSION = '0.50_90' ;
 
 my %SIGS = () ;
 
@@ -109,7 +109,8 @@ sub new {
 			}
 		}
 
-		my $java = File::Spec->catfile($o->get_java_config('J2SDK'), 'bin',
+		my $java = File::Spec->catfile($o->get_java_config('J2SDK'), 
+			Inline::Java::Portable::portable("J2SDK_BIN"),
 			($this->{debugger} ? "jdb" : "java") . 
 			Inline::Java::Portable::portable("EXE_EXTENSION")) ;
 
diff --git a/Java/Makefile.PL b/Java/Makefile.PL
index 1983415..a1c7b6c 100644
--- a/Java/Makefile.PL
+++ b/Java/Makefile.PL
@@ -71,7 +71,7 @@ if (($build_jni || AskYN("Do you wish to build the JNI extension?",
 	find(
 		{
 			wanted => \&search,
-			($symlink ? (follow => 1, follow_skip => 2) : ()),
+			($symlink ? (follow_fast => 1, follow_skip => 2) : ()),
 		},
 		$jdk_dir) ;
 
@@ -162,6 +162,9 @@ TXT
 				PMLIBDIRS => [File::Spec->catdir('sources', 'org', 'perl', 'inline', 'java')],
 				INC => join(' ', @main::I),
 				LIBS => [join(' ', @main::L) . " -ljvm"],
+				dynamic_lib => { 
+					OTHERLDFLAGS => Inline::Java::Portable::portable('OTHERLDFLAGS') 
+				},
 				# CCFLAGS => '-D_REENTRANT',
 			) ;
 		}
diff --git a/Java/Object.pm b/Java/Object.pm
index c33cf5a..1720d59 100644
--- a/Java/Object.pm
+++ b/Java/Object.pm
@@ -5,7 +5,7 @@ use strict ;
 use Inline::Java::Protocol ;
 use Carp ;
 
-$Inline::Java::Object::VERSION = '0.50' ;
+$Inline::Java::Object::VERSION = '0.50_90' ;
 
 # Here we store as keys the knots and as values our blessed private objects
 my $PRIVATES = {} ;
diff --git a/Java/PerlInterpreter/PerlInterpreter.pm b/Java/PerlInterpreter/PerlInterpreter.pm
index 7b97089..3b3b62f 100644
--- a/Java/PerlInterpreter/PerlInterpreter.pm
+++ b/Java/PerlInterpreter/PerlInterpreter.pm
@@ -3,7 +3,7 @@ package Inline::Java::PerlInterpreter ;
 use strict ;
 use Inline::Java ;
 
-$Inline::Java::PerlInterpreter::VERSION = '0.50' ;
+$Inline::Java::PerlInterpreter::VERSION = '0.50_90' ;
 
 
 use Inline (
diff --git a/Java/PerlInterpreter/t/02_perl_interpreter.t b/Java/PerlInterpreter/t/02_perl_interpreter.t
index 5448413..44ebe27 100644
--- a/Java/PerlInterpreter/t/02_perl_interpreter.t
+++ b/Java/PerlInterpreter/t/02_perl_interpreter.t
@@ -4,7 +4,7 @@ use Test ;
 use File::Spec ;
 
 BEGIN {
-    plan(tests => 7) ;
+    plan(tests => 12) ;
 }
 
 
@@ -42,7 +42,8 @@ sub run_java {
 
 	my $java = File::Spec->catfile(
 		Inline::Java::get_default_j2sdk(),
-		'bin', 'java' . Inline::Java::Portable::portable("EXE_EXTENSION")) ;
+		Inline::Java::Portable::portable("J2SDK_BIN"), 
+		'java' . Inline::Java::Portable::portable("EXE_EXTENSION")) ;
 
 	my $debug = $ENV{PERL_INLINE_JAVA_DEBUG} || 0 ;
 	my $cmd = Inline::Java::Portable::portable("SUB_FIX_CMD_QUOTES", "\"$java\" " . 
@@ -69,7 +70,7 @@ class InlineJavaPerlInterpreterTests implements Runnable {
 	private InlineJavaPerlInterpreterTests() throws InlineJavaException, InlineJavaPerlException {
 	}
 
-	private static void ok(Object o1, Object o2){
+	private synchronized static void ok(Object o1, Object o2){
 		if (o1.equals(o2)){
 			String comment = " # " + o1 + " == " + o2 ;
 			System.out.println("ok " + cnt + comment) ;
diff --git a/Java/PerlNatives/PerlNatives.pm b/Java/PerlNatives/PerlNatives.pm
index c9d56e7..3ff6e60 100644
--- a/Java/PerlNatives/PerlNatives.pm
+++ b/Java/PerlNatives/PerlNatives.pm
@@ -2,6 +2,6 @@ package Inline::Java::PerlNatives ;
 
 use strict ;
 
-$Inline::Java::PerlNatives::VERSION = '0.50' ;
+$Inline::Java::PerlNatives::VERSION = '0.50_90' ;
 
 1 ;
diff --git a/Java/Portable.pm b/Java/Portable.pm
index 5d64cd2..1902ea3 100644
--- a/Java/Portable.pm
+++ b/Java/Portable.pm
@@ -9,7 +9,7 @@ use Config ;
 use File::Find ;
 use File::Spec ;
 
-$Inline::Java::Portable::VERSION = '0.50' ;
+$Inline::Java::Portable::VERSION = '0.50_90' ;
 
 # Here is some code to figure out if we are running on command.com
 # shell under Windows.
@@ -161,6 +161,8 @@ sub portable {
 		POST_WHOLE_ARCHIVE	=>  '-Wl,--no-whole-archive',
 		PERL_PARSE_DUP_ENV	=>  '-DPERL_PARSE_DUP_ENV',
 		BUILD_JNI_BY_DFLT	=>  1,
+		J2SDK_BIN			=>  'bin',
+		OTHERLDFLAGS		=>  '',
 	} ;
 
 	my $map = {
@@ -225,6 +227,15 @@ sub portable {
 		darwin => {
 			# Suggested by Ken Williams, mailing list 2004/07/07
 			SO_EXT				=>	$Config{so},
+			# Andrew Bruno
+			JVM_LIB				=>	"libjvm.dylib",
+			JVM_SO				=>	"libjvm.dylib",
+			PRE_WHOLE_ARCHIVE	=>  '-Wl',
+			POST_WHOLE_ARCHIVE	=>  '-Wl',
+		    GOT_SYMLINK			=>	1,
+            J2SDK_BIN        	=>  'Commands',
+			# Tim Bunce:
+			OTHERLDFLAGS		=>  '',
 		},
 	} ;
 
diff --git a/Java/Protocol.pm b/Java/Protocol.pm
index bfe9f32..27c54bc 100644
--- a/Java/Protocol.pm
+++ b/Java/Protocol.pm
@@ -4,8 +4,10 @@ use strict ;
 use Inline::Java::Object ;
 use Inline::Java::Array ;
 use Carp ;
+use MIME::Base64 ;
+use Encode qw(encode_utf8 decode_utf8) ;
 
-$Inline::Java::Protocol::VERSION = '0.50' ;
+$Inline::Java::Protocol::VERSION = '0.50_90' ;
 
 my %CLASSPATH_ENTRIES = () ;
 
@@ -42,7 +44,7 @@ sub AddClassPath {
 
 	my $data = "add_classpath " . join(" ", map {encode($_)} @paths) ;
 
-	return $this->Send($data, 1) ;
+	return $this->Send($data) ;
 }
 
 
@@ -53,7 +55,7 @@ sub ServerType {
 
 	my $data = "server_type" ;
 
-	return $this->Send($data, 1) ;
+	return $this->Send($data) ;
 }
 
 
@@ -69,7 +71,7 @@ sub Report {
 		$this->ValidateArgs([$classes]),
 	) ;
 
-	return $this->Send($data, 1) ;
+	return $this->Send($data) ;
 }
 
 
@@ -96,7 +98,7 @@ sub __ISA {
 		Inline::Java::Class::ValidateClass($proto),
 	) ;
 
-	return $this->Send($data, 1) ;
+	return $this->Send($data) ;
 }
 
 
@@ -109,7 +111,7 @@ sub ObjectCount {
 		"obj_cnt", 
 	) ;
 
-	return $this->Send($data, 1) ;
+	return $this->Send($data) ;
 }
 
 
@@ -221,6 +223,94 @@ sub GetJavaMember {
 }
 
 
+sub ReadFromJavaHandle {
+	my $this = shift ;
+	my $len = shift ;
+
+	my $id = $this->{obj_priv}->{id} ;
+	my $class = $this->{obj_priv}->{java_class} ;
+	Inline::Java::debug(3, "reading from handle object($id)") ;
+
+	my $data = join(" ", 
+		"read", 
+		$id,
+		$len,
+	) ;
+
+	return $this->Send($data) ;
+}
+
+
+sub MakeJavaHandleBuffered {
+	my $this = shift ;
+
+	my $id = $this->{obj_priv}->{id} ;
+	my $class = $this->{obj_priv}->{java_class} ;
+	Inline::Java::debug(3, "making handle object($id) buffered") ;
+
+	my $data = join(" ", 
+		"make_buffered", 
+		$id,
+	) ;
+
+	return $this->Send($data) ;
+}
+
+
+sub ReadLineFromJavaHandle {
+	my $this = shift ;
+
+	my $id = undef ;
+	if (! defined($this->{obj_priv}->{buffered})){
+		$this->{obj_priv}->{buffered} = $this->MakeJavaHandleBuffered() ;
+	}
+	$id = $this->{obj_priv}->{buffered} ;
+	my $class = $this->{obj_priv}->{java_class} ;
+	Inline::Java::debug(3, "reading line from handle object($id)") ;
+
+	my $data = join(" ", 
+		"readline", 
+		$id,
+	) ;
+
+	return $this->Send($data) ;
+}
+
+
+sub WriteToJavaHandle {
+	my $this = shift ;
+	my $str = shift ;
+
+	my $id = $this->{obj_priv}->{id} ;
+	my $class = $this->{obj_priv}->{java_class} ;
+	Inline::Java::debug(3, "writing to handle object($id)") ;
+
+	my $data = join(" ", 
+		"write", 
+		$id,
+		$this->ValidateArgs([$str]),
+	) ;
+
+	return $this->Send($data) ;
+}
+
+
+sub CloseJavaHandle {
+	my $this = shift ;
+
+	my $id = $this->{obj_priv}->{id} ;
+	my $class = $this->{obj_priv}->{java_class} ;
+	Inline::Java::debug(3, "closing handle object($id)") ;
+
+	my $data = join(" ", 
+		"close", 
+		$id,
+	) ;
+
+	return $this->Send($data) ;
+}
+
+
 # Deletes a Java object
 sub DeleteJavaObject {
 	my $this = shift ;
@@ -321,9 +411,9 @@ sub CreateSignature {
 	my $proto = shift ;
 	my $del = shift || ", " ;
 
-	my @p = map {(defined($_) ? $_ : '')} @{$proto} ;
-
-	return "(" . join($del, @p) . ")" ;
+	no warnings ;
+	my $sig = join($del, @{$proto}) ;
+	return "($sig)" ;
 }
 
 
@@ -335,7 +425,7 @@ sub Send {
 	my $const = shift ;
 
 	my $resp = Inline::Java::__get_JVM()->process_command($this->{inline}, $data) ;
-	if ($resp =~ /^error scalar:([\d.-]*)$/){
+	if ($resp =~ /^error scalar:([\w+\/=+]*)$/){
 		my $msg = decode($1) ;
 		Inline::Java::debug(3, "packet recv error: $msg") ;
 		croak $msg ;
@@ -353,17 +443,18 @@ sub DeserializeObject {
 	my $const = shift ;
 	my $resp = shift ;
 
-	if ($resp =~ /^scalar:([\d.-]*)$/){
+	if ($resp =~ /^scalar:([\w+\/=+]*)$/){
 		return decode($1) ; 
 	}
 	elsif ($resp =~ /^undef:$/){
 		return undef ;
 	}
-	elsif ($resp =~ /^java_object:([01]):(\d+):(.*)$/){
+	elsif ($resp =~ /^java_(object|array|handle):([01]):(\d+):(.*)$/){
 		# Create the Perl object wrapper and return it.
-		my $thrown = $1 ;
-		my $id = $2 ;
-		my $class = $3 ;
+		my $type = $1 ;
+		my $thrown = $2 ;
+		my $id = $3 ;
+		my $class = $4 ;
 
 		if ($thrown){
 			# If we receive a thrown object, we jump out of 'constructor
@@ -384,12 +475,11 @@ sub DeserializeObject {
 			my $elem_class = $class ;
 
 			Inline::Java::debug(3, "checking if stub is array...") ;
-			if (Inline::Java::Class::ClassIsArray($class)){
+			if ($type eq 'array'){
 				my @d = Inline::Java::Class::ValidateClassSplit($class) ;
 				$elem_class = $d[2] ;
 			}
 
-
 			my $perl_class = "Inline::Java::Object" ;
 			if ($elem_class){
 				# We have a real class or an array of real classes
@@ -414,12 +504,19 @@ sub DeserializeObject {
 				# the block below will handle it.
 			}
 
-			if (Inline::Java::Class::ClassIsArray($class)){
+			if ($type eq 'array'){
 				Inline::Java::debug(3, "creating array object...") ;
 				$obj = Inline::Java::Object->__new($class, $this->{inline}, $id) ;
 				$obj = new Inline::Java::Array($obj) ;
 				Inline::Java::debug(3, "array object created...") ;
 			}
+			# To be finished at a later time...
+			# elsif ($type eq 'handle'){
+			# 	Inline::Java::debug(3, "creating handle object...") ;
+			# 	$obj = Inline::Java::Object->__new($class, $this->{inline}, $id) ;
+			# 	$obj = new Inline::Java::Handle($obj) ;
+			# 	Inline::Java::debug(3, "handle object created...") ;
+			# }
 			else{
 				$obj = $perl_class->__new($class, $this->{inline}, $id) ;
 			}
@@ -455,16 +552,14 @@ sub DeserializeObject {
 sub encode {
 	my $s = shift ;
 
-	# If Perl version < 5.6, use C*
-	return join(".", unpack("U*", $s)) ;
+	return encode_base64(encode_utf8($s), '') ;
 }
 
 
 sub decode {
 	my $s = shift ;
 
-	# If Perl version < 5.6, use C*
-	return pack("U*", split(/\./, $s)) ;
+	return decode_utf8(decode_base64($s)) ;
 }
 
 
diff --git a/Java/Server.pm b/Java/Server.pm
index 51a9594..c609d1b 100644
--- a/Java/Server.pm
+++ b/Java/Server.pm
@@ -13,7 +13,7 @@ require Inline::Java ;
 use File::Spec ;
 
 
-$Inline::Java::Server::VERSION = '0.50' ;
+$Inline::Java::Server::VERSION = '0.50_90' ;
 
 
 # Create a dummy Inline::Java object in order to 
diff --git a/MANIFEST b/MANIFEST
index a91a4c3..c0a61bd 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -14,6 +14,7 @@ Java/Callback.pm
 Java/Callback.pod
 Java/Portable.pm
 Java/Array.pm
+Java/Handle.pm
 Java/Makefile.PL
 Java/JVM.pm
 Java/Server.pm
@@ -39,6 +40,7 @@ Java/sources/org/perl/inline/java/InlineJavaCallbackQueue.java
 Java/sources/org/perl/inline/java/InlineJavaPerlNatives.java
 Java/sources/org/perl/inline/java/InlineJavaPerlInterpreter.java
 Java/sources/org/perl/inline/java/InlineJavaPerlObject.java
+Java/sources/org/perl/inline/java/InlineJavaHandle.java
 Java/PerlNatives/Makefile.PL
 Java/PerlNatives/PerlNatives.pm
 Java/PerlNatives/PerlNatives.xs
diff --git a/Makefile.PL b/Makefile.PL
index 4ff8530..b9caa5d 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -46,10 +46,11 @@ my $perl_jdk_dir = $jdk_dir ;
 $perl_jdk_dir =~ s/'/\'/g ;
 
 # Check directory
+my $jdk_bin = Inline::Java::Portable::portable("J2SDK_BIN") ;
 my $ext = Inline::Java::Portable::portable('EXE_EXTENSION') ;
 foreach my $f ('javac', 'jar', 'java'){
-	if (! -x File::Spec->catfile($jdk_dir, 'bin', $f . $ext)){
-		my $bf = File::Spec->catfile('bin', $f . $ext) ;
+	if (! -x File::Spec->catfile($jdk_dir, $jdk_bin, $f . $ext)){
+		my $bf = File::Spec->catfile($jdk_bin, $f . $ext) ;
 		print "Can't locate file '$bf' anywhere under '$jdk_dir'\n" ;
 	}
 }
@@ -86,8 +87,8 @@ SAVE_J2SDK
 
 
 # We will now add the building of our Java files to the Makefile.
-my $javac = File::Spec->catfile($jdk_dir, 'bin', 'javac' . $ext) ;
-my $jar = File::Spec->catfile($jdk_dir, 'bin', 'jar' . $ext) ;                      
+my $javac = File::Spec->catfile($jdk_dir, $jdk_bin, 'javac' . $ext) ;
+my $jar = File::Spec->catfile($jdk_dir, $jdk_bin, 'jar' . $ext) ;                      
 my $src_dir = File::Spec->catdir('Java', 'sources', 'org', 'perl', 'inline', 'java') ;
 my $src = File::Spec->catfile($src_dir, '*.java') ;
 my $obj_dir = File::Spec->catdir('Java', 'classes') ;
diff --git a/t/13_handles.t b/t/13_handles.t
index 8eda65f..03aa4a0 100755
--- a/t/13_handles.t
+++ b/t/13_handles.t
@@ -24,9 +24,9 @@ my $t = new t13() ;
 	my $o = t13->getWriter(File::Spec->catfile("t", "t13.txt")) ;
 	my $h = new Inline::Java::Handle($o) ;
 	for (my $i = 1 ; $i <= 10 ; $i++){
-		print $h "$i\n" ;
+	 	print $h "$i\n" ;
 	}
-	close($h) ;	
+	# close($h) ;	
 	ok(1) ;
 }
 

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