[libinline-java-perl] 135/398: *** empty log message ***
Jonas Smedegaard
dr at jones.dk
Thu Feb 26 11:42:57 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 fc1cc684bde22fcb1ac3c63ab1b1b4c3dd9106ff
Author: Patrick LeBoutillier <patl at cpan.org>
Date: Wed Jan 9 16:16:09 2002 +0000
*** empty log message ***
---
Java.pm | 324 ++++++++++++++++++++----------------------------------------
Java.pod | 2 +-
MANIFEST | 11 ++-
Makefile.PL | 3 +
4 files changed, 118 insertions(+), 222 deletions(-)
diff --git a/Java.pm b/Java.pm
index 97a6a22..2d05a17 100644
--- a/Java.pm
+++ b/Java.pm
@@ -30,6 +30,7 @@ use Data::Dumper ;
use IO::Socket ;
+use Inline::Java::Portable ;
use Inline::Java::Class ;
use Inline::Java::Object ;
use Inline::Java::Array ;
@@ -52,22 +53,6 @@ my $JVM = undef ;
my $INLINES = {} ;
-# Here is some code to figure out if we are running on command.com
-# shell under Windows.
-my $COMMAND_COM =
- (
- ($^O eq 'MSWin32')&&
- (
- ($ENV{PERL_INLINE_JAVA_COMMAND_COM})||
- (
- (defined($ENV{COMSPEC}))&&
- ($ENV{COMSPEC} =~ /(command|4dos)\.com/i)
- )||
- (`ver` =~ /win(dows )?(9[58]|m[ei])/i)
- )
- ) || 0 ;
-
-
# This stuff is to control the termination of the Java Interpreter
sub done {
my $signal = shift ;
@@ -105,18 +90,8 @@ END {
# Signal stuff, not really needed with JNI
use sigtrap 'handler', \&done, 'normal-signals' ;
-# This whole $SIG{__DIE__} thing doesn't work because it is called
-# even if the die is trapped inside an eval...
-# $SIG{__DIE__} = sub {
- # Setting this to -1 will prevent Inline::Java::Object::DESTROY
- # from executing it's code for object destruction, since the state
- # in possibly unstable.
- # $DONE = -1 ;
-# die @_ ;
-# } ;
-
-# To export the cast function.
+# To export the cast function and others.
sub import {
Inline::Java->export_to_level(1, @_) ;
}
@@ -307,16 +282,12 @@ sub get_api {
sub set_java_bin {
my $o = shift ;
- my $sep = portable("PATH_SEP_RE") ;
-
my $cjb = $o->{ILSM}->{BIN} ;
my $ejb = $ENV{PERL_INLINE_JAVA_BIN} ;
if ($cjb){
- $cjb =~ s/$sep+$// ;
return $o->find_java_bin([$cjb]) ;
}
elsif ($ejb) {
- $ejb =~ s/$sep+$// ;
$o->{ILSM}->{BIN} = $ejb ;
return $o->find_java_bin([$ejb]) ;
}
@@ -339,7 +310,7 @@ sub find_java_bin {
}
else{
croak
- "Can't locate your java binaries ('java' and 'javac'). Please set one of the following to the proper directory:\n" .
+ "Can't locate your java binaries ('$java' and '$javac'). Please set one of the following to the proper directory:\n" .
" - The BIN config option;\n" .
" - The PERL_INLINE_JAVA_BIN environment variable;\n" .
" - The PATH environment variable.\n" ;
@@ -353,33 +324,19 @@ sub find_file_in_path {
my $paths = shift ;
if (! defined($paths)){
- my $psep = portable("ENV_VAR_PATH_SEP") ;
- $paths = [(split(/$psep/, $ENV{PATH} || ''))] ;
+ $paths = [File::Spec->path()] ;
}
Inline::Java::debug_obj($paths) ;
- my $home = $ENV{HOME} ;
- my $sep = portable("PATH_SEP_RE") ;
-
foreach my $p (@{$paths}){
+ $p =~ s/^\s+// ;
+ $p =~ s/\s+$// ;
Inline::Java::debug("path element: $p") ;
if ($p !~ /^\s*$/){
- $p =~ s/$sep+$// ;
-
- if ($p =~ /^~/){
- if ($home){
- $p =~ s/^~/$home/ ;
- }
- else{
- # -f don't work with ~/...
- next ;
- }
- }
-
my $found = 0 ;
foreach my $file (@{$files}){
- my $f = "$p/$file" ;
+ my $f = File::Spec->catfile($p, $file) ;
Inline::Java::debug(" candidate: $f\n") ;
if (-f $f){
@@ -427,19 +384,22 @@ sub write_java {
$o->mkpath($build_dir) ;
if (! $study_only){
- open(Inline::Java::JAVA, ">$build_dir/$modfname.java") or
- croak "Can't open $build_dir/$modfname.java: $!" ;
+ my $p = File::Spec->catfile($build_dir, "$modfname.java") ;
+ open(Inline::Java::JAVA, ">$p") or
+ croak "Can't open $p: $!" ;
Inline::Java::Init::DumpUserJavaCode(\*Inline::Java::JAVA, $code) ;
close(Inline::Java::JAVA) ;
}
- open(Inline::Java::JAVA, ">$build_dir/InlineJavaServer.java") or
- croak "Can't open $build_dir/InlineJavaServer.java: $!" ;
+ my $p = File::Spec->catfile($build_dir, "InlineJavaServer.java") ;
+ open(Inline::Java::JAVA, ">$p") or
+ croak "Can't open $p: $!" ;
Inline::Java::Init::DumpServerJavaCode(\*Inline::Java::JAVA) ;
close(Inline::Java::JAVA) ;
- open(Inline::Java::JAVA, ">$build_dir/InlineJavaPerlCaller.java") or
- croak "Can't open $build_dir/InlineJavaPerlCaller.java: $!" ;
+ $p = File::Spec->catfile($build_dir, "InlineJavaPerlCaller.java") ;
+ open(Inline::Java::JAVA, ">$p") or
+ croak "Can't open $p: $!" ;
Inline::Java::Init::DumpCallbackJavaCode(\*Inline::Java::JAVA) ;
close(Inline::Java::JAVA) ;
@@ -458,16 +418,15 @@ sub compile {
my $suffix = $o->get_api('suffix') ;
my $install_lib = $o->get_api('install_lib') ;
- my $install = "$install_lib/auto/$modpname" ;
- my $pinstall = portable("RE_FILE", $install) ;
+ my $install = File::Spec->catdir($install_lib, "auto", $modpname) ;
- $o->mkpath("$install") ;
- $o->set_classpath($pinstall) ;
+ $o->mkpath($install) ;
+ $o->set_classpath($install) ;
- my $javac = $o->{ILSM}->{BIN} . "/javac" . portable("EXE_EXTENSION") ;
+ my $javac = File::Spec->catfile($o->{ILSM}->{BIN},
+ "javac" . portable("EXE_EXTENSION")) ;
my $predir = portable("IO_REDIR") ;
- my $pjavac = portable("RE_FILE", $javac) ;
my $cwd = Cwd::cwd() ;
if ($o->get_config('UNTAINT')){
@@ -488,9 +447,9 @@ sub compile {
# file, but we can't penalize the other users just to give better support
# for Win9x...
foreach my $cmd (
- "\"$pjavac\" InlineJavaServer.java $source > cmd.out $predir",
+ "\"$javac\" InlineJavaServer.java $source > cmd.out $predir",
["copy_classes", $o, $install],
- ["touch_file", $o, "$install/$modfname.$suffix"],
+ ["touch_file", $o, File::Spec->catfile($install, "$modfname.$suffix")],
) {
if ($cmd){
@@ -572,10 +531,9 @@ sub copy_classes {
my $build_dir = $o->get_api('build_dir') ;
my $modpname = $o->get_api('modpname') ;
my $install_lib = $o->get_api('install_lib') ;
- my $pinstall = portable("RE_FILE", $install) ;
my $src_dir = $build_dir ;
- my $dest_dir = $pinstall ;
+ my $dest_dir = $install ;
my @flist = glob("*.class") ;
@@ -585,7 +543,7 @@ sub copy_classes {
}
foreach my $file (@flist){
if (! (-s $file)){
- croak "File $file has size zero. Previous command failed under WIN9x?" ;
+ croak "File $file has size zero. Previous command failed under command.com?" ;
}
}
}
@@ -594,9 +552,11 @@ sub copy_classes {
if ($o->get_config('UNTAINT')){
($file) = $file =~ /(.*)/ ;
}
- Inline::Java::debug("copy_classes: $file, $dest_dir/$file") ;
- if (! File::Copy::copy($file, "$dest_dir/$file")){
- return "Can't copy $src_dir/$file to $dest_dir/$file: $!" ;
+ my $f = File::Spec->catfile($src_dir, $file) ;
+ my $t = File::Spec->catfile($dest_dir, $file) ;
+ Inline::Java::debug("copy_classes: $file, $t") ;
+ if (! File::Copy::copy($file, $t)){
+ return "Can't copy $f to $t: $!" ;
}
}
@@ -608,10 +568,8 @@ sub touch_file {
my $o = shift ;
my $file = shift ;
- my $pfile = portable("RE_FILE", $file) ;
-
- if (! open(Inline::Java::TOUCH, ">$pfile")){
- croak "Can't create file $pfile" ;
+ if (! open(Inline::Java::TOUCH, ">$file")){
+ croak "Can't create file $file" ;
}
close(Inline::Java::TOUCH) ;
@@ -630,15 +588,14 @@ sub load {
my $install_lib = $o->get_api('install_lib') ;
my $modfname = $o->get_api('modfname') ;
my $modpname = $o->get_api('modpname') ;
- my $install = "$install_lib/auto/$modpname" ;
- my $pinstall = portable("RE_FILE", $install) ;
+ my $install = File::Spec->catdir($install_lib, "auto", $modpname) ;
# Make sure the default options are set.
$o->_validate(1, $o->get_config()) ;
# If the JVM is not running, we need to start it here.
if (! $JVM){
- $o->set_classpath($pinstall) ;
+ $o->set_classpath($install) ;
$JVM = new Inline::Java::JVM($o) ;
}
@@ -681,36 +638,37 @@ sub set_classpath {
my $sep = portable("ENV_VAR_PATH_SEP_CP") ;
my @cp = split(/$sep/, join($sep, @list)) ;
- my %cp = map { ($_ !~ /^\s*$/ ? ($_, 1) : ()) } @cp ;
# Add dot to CLASSPATH, required when building
- my $tmp = join($sep, (keys %cp, '.')) ;
-
- $tmp =~ s/\s*\[PERL_INLINE_JAVA\s*=\s*(.*?)\s*\]\s*/{
- my $modules = $1 ;
- Inline::Java::debug(" found special CLASSPATH entry: $modules") ;
+ push @cp, '.' ;
+
+ foreach my $p (@cp){
+ $p =~ s/^\s+// ;
+ $p =~ s/\s+$// ;
+ if ($p =~ /\[PERL_INLINE_JAVA\s*=\s*(.*?)\s*\]/){
+ my $modules = $1 ;
+ Inline::Java::debug(" found special CLASSPATH entry: $modules") ;
- my @modules = split(m#\s*,\s*#, $modules) ;
- my $psep = portable("PATH_SEP") ;
- my $psep_re = portable("PATH_SEP_RE") ;
- my $dir = $o->get_config('DIRECTORY') . $psep . "lib" . $psep ."auto" ;
+ my @modules = split(m#\s*,\s*#, $modules) ;
+ my $dir = File::Spec->catdir($o->get_config('DIRECTORY'), "lib", "auto") ;
- my %paths = () ;
- foreach my $m (@modules){
- $m =~ s#::#$psep_re#g ;
+ my %paths = () ;
+ foreach my $m (@modules){
+ $m = File::Spec->catdir(split(/::/, $m)) ;
- # Here we must make sure that the directory exists, or
- # else it is removed from the CLASSPATH by Java
- my $path = "$dir$psep$m" ;
- $o->mkpath($path) ;
+ # Here we must make sure that the directory exists, or
+ # else it is removed from the CLASSPATH by Java
+ my $path = File::Spec->catdir($dir, $m) ;
+ $o->mkpath($path) ;
- $paths{$path} = 1 ;
- }
+ $paths{$path} = 1 ;
+ }
- join($sep, keys %paths) ;
- }/eg ;
+ $p = join($sep, keys %paths) ;
+ }
+ }
- $ENV{CLASSPATH} = $tmp ;
+ $ENV{CLASSPATH} = join($sep, @cp) ;
Inline::Java::debug(" classpath: " . $ENV{CLASSPATH}) ;
}
@@ -744,8 +702,7 @@ sub report {
my $modpname = $o->get_api('modpname') ;
my $modfname = $o->get_api('modfname') ;
my $suffix = $o->get_api('suffix') ;
- my $install = "$install_lib/auto/$modpname" ;
- my $pinstall = portable("RE_FILE", $install) ;
+ my $install = File::Spec->catdir($install_lib, "auto", $modpname) ;
my $use_cache = 0 ;
if (! defined($classes)){
@@ -754,11 +711,13 @@ sub report {
$use_cache = 1 ;
# We need to take the classes that are in the directory...
- my @cl = glob("$pinstall/*.class") ;
+ my @cl = glob(File::Spec->catfile($install, "*.class")) ;
foreach my $class (@cl){
- $class =~ s/^\Q$pinstall\E\/(.*)\.class$/$1/ ;
- if ($class !~ /^InlineJava(Server|Perl)/){
- push @{$classes}, $class ;
+ if ($class =~ s/\.class$//){
+ my ($v, $d, $f) = File::Spec->splitpath($class) ;
+ if ($f !~ /^InlineJava(Server|Perl)/){
+ push @{$classes}, $f ;
+ }
}
}
}
@@ -782,9 +741,10 @@ sub report {
# it was up to date. We can therefore use the data
# from the cache
Inline::Java::debug("using jdat cache") ;
- my $size = (-s "$install/$modfname.$suffix") || 0 ;
+ my $p = File::Spec->catfile($install, "$modfname.$suffix") ;
+ my $size = (-s $p) || 0 ;
if ($size > 0){
- if (open(Inline::Java::CACHE, "<$install/$modfname.$suffix")){
+ if (open(Inline::Java::CACHE, "<$p")){
$resp = join("", <Inline::Java::CACHE>) ;
close(Inline::Java::CACHE) ;
}
@@ -887,7 +847,7 @@ sub load_jdat {
$d->{classes}->{$current_class}->{fields}->{$field} = {} ;
}
- $d->{classes}->{$current_class}->{fields}->{$field} =
+ $d->{classes}->{$current_class}->{fields}->{$field}->{$type} =
{
TYPE => $type,
STATIC => ($static eq "static" ? 1 : 0),
@@ -943,13 +903,18 @@ use Carp ;
CODE
- while (my ($field, $sign) = each %{$d->{classes}->{$class}->{fields}}){
- if ($sign->{STATIC}){
- $code .= <<CODE;
+ while (my ($field, $types) = each %{$d->{classes}->{$class}->{fields}}){
+ while (my ($type, $sign) = each %{$types}){
+ if ($sign->{STATIC}){
+ $code .= <<CODE;
tie \$$class$colon:$field, "Inline::Java::Object::StaticMember",
- \$DUMMY_OBJECT,
- '$field' ;
+ \$DUMMY_OBJECT,
+ '$field' ;
CODE
+ # We have at least one static version of this field,
+ # that's enough.
+ last ;
+ }
}
}
@@ -1049,6 +1014,8 @@ sub get_fields {
foreach my $d (@{$data_list}){
if (exists($d->{classes}->{$class})){
while (my ($field, $value) = each %{$d->{classes}->{$class}->{fields}}){
+ # Here $value is a hash that contains all the different
+ # types available for the field $field
$fields->{$field} = $value ;
}
}
@@ -1119,14 +1086,21 @@ sub info {
######################## General Functions ########################
-sub get_JVM {
+sub __get_JVM {
return $JVM ;
}
+# For testing purposes only...
+sub __clear_JVM {
+ $JVM = undef ;
+}
+
+
sub shutdown_JVM {
if ($JVM){
- undef $JVM ;
+ $JVM->shutdown() ;
+ $JVM = undef ;
}
}
@@ -1138,6 +1112,20 @@ sub reconnect_JVM {
}
+sub capture_JVM {
+ if ($JVM){
+ $JVM->capture() ;
+ }
+}
+
+
+sub i_am_JVM_owner {
+ if ($JVM){
+ $JVM->am_owner() ;
+ }
+}
+
+
sub release_JVM {
if ($JVM){
$JVM->release() ;
@@ -1162,11 +1150,6 @@ sub get_DEBUG {
}
-sub debug_all {
- return (Inline::Java::get_DEBUG() > 1) ;
-}
-
-
sub get_DONE {
return $DONE ;
}
@@ -1228,106 +1211,15 @@ sub debug_obj {
}
-sub dump_obj {
- my $obj = shift ;
-
- return debug_obj($obj, "Java Object Dump:\n") ;
+sub debug_all {
+ return (Inline::Java::get_DEBUG() > 1) ;
}
-sub portable {
- my $key = shift ;
- my $val = shift ;
-
- my $defmap = {
- EXE_EXTENSION => '',
- ENV_VAR_PATH_SEP => ':',
- ENV_VAR_PATH_SEP_CP => ':',
- PATH_SEP => '/',
- PATH_SEP_RE => '/',
- RE_FILE => [],
- RE_FILE_JAVA => [],
- IO_REDIR => '2>&1',
- GOT_ALARM => 1,
- COMMAND_COM => 0,
- SUB_FIX_CLASSPATH => undef,
- } ;
-
- my $map = {
- MSWin32 => {
- EXE_EXTENSION => '.exe',
- ENV_VAR_PATH_SEP => ';',
- ENV_VAR_PATH_SEP_CP => ';',
- PATH_SEP => '\\',
- PATH_SEP_RE => '\\\\',
- RE_FILE => ['/', '\\'],
- RE_FILE_JAVA => ['\\\\', '\\\\'],
- # 2>&1 doesn't work under command.com
- IO_REDIR => ($COMMAND_COM ? '' : undef),
- GOT_ALARM => 0,
- COMMAND_COM => $COMMAND_COM,
- },
- cygwin => {
- ENV_VAR_PATH_SEP_CP => ';',
- SUB_FIX_CLASSPATH => sub {
- my $val = shift ;
- if (defined($val)&&($val)){
- $val = `cygpath -w \"$val\"` ;
- chomp($val) ;
- }
- return $val ;
- },
- },
- } ;
-
- if (! exists($defmap->{$key})){
- croak "Portability issue $key not defined!" ;
- }
+sub dump_obj {
+ my $obj = shift ;
- if ((defined($map->{$^O}))&&(defined($map->{$^O}->{$key}))){
- if ($key =~ /^RE_/){
- if (defined($val)){
- my $f = $map->{$^O}->{$key}->[0] ;
- my $t = $map->{$^O}->{$key}->[1] ;
- $val =~ s/$f/$t/g ;
- Inline::Java::debug("portable: $key => $val for $^O is '$val'") ;
- return $val ;
- }
- else{
- Inline::Java::debug("portable: $key for $^O is 'undef'") ;
- return undef ;
- }
- }
- elsif ($key =~ /^SUB_/){
- my $sub = $map->{$^O}->{$key} ;
- if (defined($sub)){
- $val = $sub->($val) ;
- Inline::Java::debug("portable: $key => $val for $^O is '$val'") ;
- return $val ;
- }
- else{
- return $val ;
- }
- }
- else{
- Inline::Java::debug("portable: $key for $^O is '$map->{$^O}->{$key}'") ;
- return $map->{$^O}->{$key} ;
- }
- }
- else{
- if ($key =~ /^RE_/){
- Inline::Java::debug("portable: $key => $val for $^O is default '$val'") ;
- return $val ;
- }
- if ($key =~ /^SUB_/){
- Inline::Java::debug("portable: $key => $val for $^O is default '$val'") ;
- return $val ;
- }
- else{
- Inline::Java::debug("portable: $key for $^O is default '$defmap->{$key}'") ;
- return $defmap->{$key} ;
- }
- }
+ return debug_obj($obj, "Java Object Dump:\n") ;
}
diff --git a/Java.pod b/Java.pod
index f789b24..cd1231d 100644
--- a/Java.pod
+++ b/Java.pod
@@ -159,7 +159,7 @@ behavior of C<Inline::Java>:
WARN_METHOD_SELECT:
Throws a warning when C<Inline::Java> has to 'choose' between
different method signatures. The warning states the possible
- choices and the sugnature chosen.
+ choices and the signature chosen.
Ex: WARN_METHOD_SELECT => 1
STUDY:
diff --git a/MANIFEST b/MANIFEST
index 2ebc7d4..53f8109 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4,9 +4,6 @@ README
README.JNI
TODO
Makefile.PL
-shared_jvm_server.pl
-shared_jvm_test.pl
-swing_gui_test.pl
Java.pm
Java.pod
Java/Init.pm
@@ -14,6 +11,7 @@ Java/Object.pm
Java/Protocol.pm
Java/Class.pm
Java/Callback.pm
+Java/Portable.pm
Java/Array.pm
Java/Makefile.PL
Java/JVM.pm
@@ -28,8 +26,11 @@ t/05_arrays.t
t/06_static.t
t/07_polymorph.t
t/08_study.t
-t/09_exceptions.t
-t/10_callbacks.t
+t/09_shared_alone.t
+t/10_shared_mult.t
+t/11_shared_fork.t
+t/12_exceptions.t
+t/13_callbacks.t
t/types.java
t/types.class
t/no_const.java
diff --git a/Makefile.PL b/Makefile.PL
index 77aad23..f6712b4 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,6 +5,9 @@ use strict ;
require "Java/Portable.pm" ;
Inline::Java::Portable::use_alone() ;
+# Replace everything just like out-of-the-box...
+rename("Java/JNI.xs_", "Java/JNI.xs") ;
+
print "\nWelcome to the Inline::Java installation procedure.\n\n" ;
WriteMakefile(
--
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