[libinline-java-perl] 112/398: localize file handles

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:42:55 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 b116834664962fe2a7ceda19eb9653125f6c827b
Author: Patrick LeBoutillier <patl at cpan.org>
Date:   Thu Nov 1 13:57:27 2001 +0000

    localize file handles
---
 Java.pm | 59 +++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 22 deletions(-)

diff --git a/Java.pm b/Java.pm
index c517ef3..92927cb 100644
--- a/Java.pm
+++ b/Java.pm
@@ -420,16 +420,16 @@ sub write_java {
 	$o->mkpath($build_dir) ;
 
 	if (! $study_only){
-		open(JAVA, ">$build_dir/$modfname.java") or
+		open(Inline::Java::JAVA, ">$build_dir/$modfname.java") or
 			croak "Can't open $build_dir/$modfname.java: $!" ;
-		Inline::Java::Init::DumpUserJavaCode(\*JAVA, $modfname, $code) ;
-		close(JAVA) ;
+		Inline::Java::Init::DumpUserJavaCode(\*Inline::Java::JAVA, $modfname, $code) ;
+		close(Inline::Java::JAVA) ;
 	}
 
-	open(JAVA, ">$build_dir/InlineJavaServer.java") or
+	open(Inline::Java::JAVA, ">$build_dir/InlineJavaServer.java") or
 		croak "Can't open $build_dir/InlineJavaServer.java: $!" ;
-	Inline::Java::Init::DumpServerJavaCode(\*JAVA, $modfname) ;
-	close(JAVA) ;
+	Inline::Java::Init::DumpServerJavaCode(\*Inline::Java::JAVA, $modfname) ;
+	close(Inline::Java::JAVA) ;
 
 	Inline::Java::debug("write_java done.") ;
 }
@@ -528,9 +528,9 @@ sub compile_error_msg {
 
 	my $build_dir = $o->get_api('build_dir') ;
 	my $error = '' ;
-	if (open(CMD, "<cmd.out")){
-		$error = join("", <CMD>) ;
-		close(CMD) ;
+	if (open(Inline::Java::CMD, "<cmd.out")){
+		$error = join("", <Inline::Java::CMD>) ;
+		close(Inline::Java::CMD) ;
 	}
 
 	my $lang = $o->get_api('language') ;
@@ -598,10 +598,10 @@ sub touch_file {
 
 	my $pfile = portable("RE_FILE", $file) ;
 
-	if (! open(TOUCH, ">$pfile")){
+	if (! open(Inline::Java::TOUCH, ">$pfile")){
 		croak "Can't create file $pfile" ;
 	}
-	close(TOUCH) ;
+	close(Inline::Java::TOUCH) ;
 
 	return '' ;
 }
@@ -631,6 +631,15 @@ sub load {
 	}
 
 	# Add our Inline object to the list.
+	my $prev_o = $INLINES->{$modfname} ;
+	if (defined($prev_o)){
+		Inline::Java::debug("Module '$modfname' was already loaded, importing binding into new instance") ;
+		if (! defined($o->{ILSM}->{data})){
+			$o->{ILSM}->{data} = [] ;
+		}
+		push @{$o->{ILSM}->{data}}, @{$prev_o->{ILSM}->{data}} ;		
+	}
+
 	$INLINES->{$modfname} = $o ;
 
 	$o->_study() ;
@@ -674,7 +683,13 @@ sub set_classpath {
 
 			foreach my $m (@modules){
 				$m =~ s/::/$sep_re/g ;
-				$cp{"$dir$sep$m"} = 1 ;
+
+				# 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) ;
+
+				$cp{$path} = 1 ;
 			}
 
 			delete $cp{$k} ;
@@ -754,9 +769,9 @@ sub report {
 		Inline::Java::debug("using jdat cache") ;
 		my $size = (-s "$install/$modfname.$suffix") || 0 ;
 		if ($size > 0){
-			if (open(CACHE, "<$install/$modfname.$suffix")){
-				$resp = join("", <CACHE>) ;
-				close(CACHE) ;
+			if (open(Inline::Java::CACHE, "<$install/$modfname.$suffix")){
+				$resp = join("", <Inline::Java::CACHE>) ;
+				close(Inline::Java::CACHE) ;
 			}
 			else{
 				croak "Can't open $modfname.$suffix file for reading" ;
@@ -772,9 +787,9 @@ sub report {
 	if (($use_cache)&&($o->{ILSM}->{built})){
 		# Update the cache.
 		Inline::Java::debug("updating jdat cache") ;
-		if (open(CACHE, ">$install/$modfname.$suffix")){
-			print CACHE $resp ;
-			close(CACHE) ;
+		if (open(Inline::Java::CACHE, ">$install/$modfname.$suffix")){
+			print Inline::Java::CACHE $resp ;
+			close(Inline::Java::CACHE) ;
 		}
 		else{
 			croak "Can't open $modfname.$suffix file for writing" ;
@@ -796,7 +811,7 @@ sub load_jdat {
 	}
 
 	# We need an array here since the same object can have many 
-	# load sessions.
+	# study sessions.
 	if (! defined($o->{ILSM}->{data})){
 		$o->{ILSM}->{data} = [] ;
 	}
@@ -961,7 +976,7 @@ CODE
 			Inline::Java::debug($code) ;
 		}
 
-		# open (CODE, ">>code") and print CODE $code and close(CODE) ;
+		# open (Inline::Java::CODE, ">>code") and print CODE $code and close(CODE) ;
 
 		eval $code ;
 
@@ -1157,11 +1172,11 @@ sub known_to_perl {
 
 	no strict 'refs' ;
 	if (defined(${$perl_class . "::" . "EXISTS"})){
-		Inline::Java::debug("  returned class exists!") ;
+		Inline::Java::debug("  Perl knows about '$jclass'") ;
 		return 1 ;
 	}
 	else{
-		Inline::Java::debug("  returned class doesn't exist!") ;
+		Inline::Java::debug("  Perl doesn't know about '$jclass'") ;
 	}
 
 	return 0 ;

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