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

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:42:49 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 bf33548073172ad050829e4eb3ee784cfe733e42
Author: patrick <>
Date:   Mon Apr 23 14:35:52 2001 +0000

    *** empty log message ***
---
 Java/JVM.pm | 70 +++++++++++++++++++++++++++++++++++++------------------------
 README      |  3 +--
 2 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/Java/JVM.pm b/Java/JVM.pm
index 2300fcb..aacc0e6 100644
--- a/Java/JVM.pm
+++ b/Java/JVM.pm
@@ -6,6 +6,7 @@ use strict ;
 $Inline::Java::JVM::VERSION = '0.20' ;
 
 use Carp ;
+use IPC::Open3 ;
 
 
 sub new {
@@ -26,7 +27,7 @@ sub new {
 		require Inline::Java::JNI ;
 
 		my $jni = new Inline::Java::JNI(
-			$ENV{CLASSPATH} || "", 
+			$ENV{CLASSPATH} || "",
 			(Inline::Java::get_DEBUG() ? 1 : 0),
 		) ;
 		$jni->create_ijs() ;
@@ -49,11 +50,16 @@ sub new {
 			($cmd) = $cmd =~ /(.*)/ ;
 		}
 
-		open(JVM, "$cmd|") or croak "Can't exec JVM: $!" ;
-		
-		# Use JVM to shut up the 'possible typo' warning...
-		Inline::Java::debug(*JVM) ;
+		my $pid = 0 ;
+		eval {
+			my $in = '' ;
+			$pid = open3($in, ">&STDOUT", ">&STDERR", $cmd) ;
+			# We won't be sending anything to the child in this fashion...
+			close($in) ;
+		} ;
+		croak "Can't exec JVM: $@" if $@ ;
 
+		$this->{pid} = $pid ;
 		$this->{socket}	= $this->setup_socket($port, $o->{Java}->{STARTUP_DELAY}) ;
 	}
 
@@ -61,6 +67,37 @@ sub new {
 }
 
 
+sub DESTROY {
+	my $this = shift ;
+
+	if ($this->{socket}){
+		# This asks the Java server to stop and die.
+		my $sock = $this->{socket} ;
+		if ($sock->connected()){
+			print $sock "die\n" ;
+		}
+		else{
+			carp "Lost connection with Java virtual machine" ;
+		}
+		close($sock) ;
+
+		if ($this->{pid}){
+			# Here we go ahead and send the signals anyway to be very 
+			# sure it's dead...
+			# Always be polite first, and then insist.
+			kill(15, $this->{pid}) ;
+			kill(9, $this->{pid}) ;
+
+			# Reap the child...
+			waitpid($this->{pid}, 0) ;
+		}
+	}
+
+	# For JNI we need to do nothing because the garbage collector will call
+	# the JNI destructor
+}
+
+
 sub setup_socket {
 	my $this = shift ;
 	my $port = shift ;
@@ -113,7 +150,7 @@ sub process_command {
 	my $this = shift ;
 	my $data = shift ;
 
-	Inline::Java::debug("  packet sent is $data") ;		
+	Inline::Java::debug("  packet sent is $data") ;
 
 	my $resp = undef ;
 	if ($this->{socket}){
@@ -134,24 +171,3 @@ sub process_command {
 
 	return $resp ;
 }
-
-
-sub DESTROY {
-	my $this = shift ;
-
-	if ($this->{socket}){
-		# This asks the Java server to stop and die.
-		my $sock = $this->{socket} ;
-		if ($sock->connected()){
-			print $sock "die\n" ;
-		}
-		else{
-			carp "Lost connection with Java virtual machine." ;
-		}
-		close($sock) ;
-	}
-
-	# For JNI we need to do nothing because the garbage collector will call
-	# the JNI destructor
-}
-
diff --git a/README b/README
index a447186..1ff250d 100644
--- a/README
+++ b/README
@@ -85,8 +85,7 @@ Inline::Java version 0.20 includes:
   member variables.
 + Type casting is now available to force the selection of specific
   method signatures.
-+ Optional JNI (Java Native Interface) extension improves performance and stability
-  dramatically.
++ Optional JNI (Java Native Interface) extension improves performance.
 + Increased stability on Win32.
 
 Inline::Java version 0.01 includes:

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