[libinline-java-perl] 220/398: Ready for TRIAL1
Jonas Smedegaard
dr at jones.dk
Thu Feb 26 11:43:05 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 7d3b10e9328f72e465547ca006f07f9ac821b2e5
Author: patrick_leb <>
Date: Wed Apr 9 18:41:14 2003 +0000
Ready for TRIAL1
---
Java.pm | 21 +++++++++------------
Java/Array.pm | 4 ++--
Java/JVM.pm | 5 +++++
Java/Portable.pm | 31 +++++++++++++++++++++++++------
TODO | 2 +-
t/t1.pl | 6 ++++--
6 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/Java.pm b/Java.pm
index 512bffb..c20b0b7 100644
--- a/Java.pm
+++ b/Java.pm
@@ -275,7 +275,7 @@ sub build {
$pcode =~ s/\/\*(.*?)\*\///gs ;
$pcode =~ s/\/\/(.*)$//gm ;
if ($pcode =~ /public\s+class\s+(\w+)/){
- # $source = "$1.java" ;
+ $source = "$1.java" ;
}
my $install_dir = File::Spec->catdir($o->get_api('install_lib'),
@@ -323,13 +323,13 @@ sub build {
# We need to take care of checking whether there are actually files
# to be copied, and if not will exit the script.
if (portable('COMMAND_COM')){
- my @flist= Inline::Java::Portable::find_classes_in_dir($install_dir) ;
- if (! scalar(@flist)){
+ my @fl = Inline::Java::Portable::find_classes_in_dir($install_dir) ;
+ if (! scalar(@fl)){
croak "No class files produced. Previous command failed under command.com?" ;
}
- foreach my $file (@flist){
- if (! (-s $file)){
- croak "File $file has size zero. Previous command failed under command.com?" ;
+ foreach my $f (@fl){
+ if (! (-s $f->{file})){
+ croak "File $f->{file} has size zero. Previous command failed under command.com?" ;
}
}
}
@@ -448,12 +448,9 @@ sub _study {
if ($study_module){
# We need to add the classes that are in the directory or under...
- my @cl = Inline::Java::Portable::find_classes_in_dir($install_dir) ;
- foreach my $class (@cl){
- if ($class =~ s/([\w\$]+)\.class$/$1/){
- my $f = $1 ;
- push @{$classes}, $f ;
- }
+ my @fl = Inline::Java::Portable::find_classes_in_dir($install_dir) ;
+ foreach my $f (@fl){
+ push @{$classes}, $f->{class} ;
}
}
diff --git a/Java/Array.pm b/Java/Array.pm
index 8903a2f..cae70b3 100644
--- a/Java/Array.pm
+++ b/Java/Array.pm
@@ -555,7 +555,7 @@ sub FillArray {
my $type = $map->{$level}->{type} ;
# Type can be undefined when array is zero length.
- if ((defined($type))&&($map->{$level}->{type} eq "SUB_ARRAY")){
+ if ((defined($type))&&($type eq "SUB_ARRAY")){
foreach my $elem (@{$array}){
if (! defined($elem)){
$elem = [] ;
@@ -567,7 +567,7 @@ sub FillArray {
if ($nb < $max){
# We must stuff...
for (my $i = $nb ; $i < $max ; $i++){
- if ($map->{$level}->{type} eq "SUB_ARRAY"){
+ if ((defined($type))&&($type eq "SUB_ARRAY")){
my $elem = [] ;
$this->FillArray($elem, $level + 1) ;
push @{$array}, $elem ;
diff --git a/Java/JVM.pm b/Java/JVM.pm
index 74f425a..4e2cf84 100644
--- a/Java/JVM.pm
+++ b/Java/JVM.pm
@@ -67,11 +67,16 @@ sub new {
LocalAddr => 'localhost', LocalPort => 0) ;
if ($sock){
$this->{port} = $sock->sockport() ;
+ Inline::Java::debug(2, "next available port number is $this->{port}") ;
close($sock) ;
}
else{
# Revert to the default.
$this->{port} = - $this->{port} ;
+ carp(
+ "Could not get next available port number, using port " .
+ "$this->{port} instead. Use the PORT configuration " .
+ "option to suppress this warning.\n") ;
}
}
diff --git a/Java/Portable.pm b/Java/Portable.pm
index dfb0208..6065759 100644
--- a/Java/Portable.pm
+++ b/Java/Portable.pm
@@ -75,9 +75,13 @@ sub make_classpath {
sub get_jar_dir {
- return Cwd::abs_path(File::Spec->catpath(
- (File::Spec->splitpath($INC{"Inline/Java.pm"}))[0,1],
- 'Java', '')) ;
+ my $path = $INC{"Inline/Java.pm"} ;
+ my ($v, $d, $f) = File::Spec->splitpath($path) ;
+
+ # This undef for the file should be ok.
+ my $dir = File::Spec->catpath($v, $d, 'Java', undef) ;
+
+ return Cwd::abs_path($dir) ;
}
@@ -91,14 +95,29 @@ sub get_user_jar {
}
+# This maybe could be made more stable
sub find_classes_in_dir {
my $dir = shift ;
+ my $sdir = (File::Spec->splitpath(
+ File::Spec->catfile($dir, 'dummy_file')))[1] ;
+
my @ret = () ;
find(sub {
- my $file = $_ ;
- if ($file =~ /\.class$/){
- push @ret, File::Spec->catfile($File::Find::dir, $file) ;
+ my $f = $_ ;
+ if ($f =~ /\.class$/){
+ my $file = $File::Find::name ;
+ my $fdir = (File::Spec->splitpath($file))[1] ;
+ $fdir =~ s/^$sdir// ;
+
+ my @dirs = File::Spec->splitdir($fdir) ;
+ if ((! scalar(@dirs))||($dirs[-1] ne '')){
+ push @dirs, '' ;
+ }
+ my $pkg = (scalar(@dirs) ? join('.', @dirs) : '') ;
+ my $class = "$pkg$f" ;
+ $class =~ s/\.class$// ;
+ push @ret, {file => $file, class => $class} ;
}
}, $dir) ;
diff --git a/TODO b/TODO
index 87348d1..c29eddc 100644
--- a/TODO
+++ b/TODO
@@ -8,7 +8,7 @@ $code =~ s/\/\/(.*)$///gm ;
- Write a test for a public class in a package.
- Retest all the small test stuff under Linux.
-- Fix MANIFEST
+- Add debug for port selection
TEST:
- Alpha
diff --git a/t/t1.pl b/t/t1.pl
index f909af6..2fe3b73 100755
--- a/t/t1.pl
+++ b/t/t1.pl
@@ -5,7 +5,9 @@ use blib ;
use Inline Java => <<'END_OF_JAVA_CODE' ;
-class Pod_alu {
+package test1.test2.test3 ;
+
+public class Pod_alu {
public Pod_alu(){
}
@@ -20,7 +22,7 @@ class Pod_alu {
END_OF_JAVA_CODE
-my $alu = new Pod_alu() ;
+my $alu = new test1::test2::test3::Pod_alu() ;
print($alu->add(9, 16) . "\n") ; # prints 25
print($alu->subtract(9, 16) . "\n") ; # prints -7
--
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