On Thu, Jun 01, 2006 at 10:31:34PM -0400, [EMAIL PROTECTED] wrote:
> > Line 185 in JVM.pm, BTW, looks like this:
> >
> > my $pid = open3($in, $out, $err, $cmd) ;
> >
> > But it's darn near impossible to look at the open3 code and know what
> > it's doing, it's chock full of TomC DWIM magic.
>
> Really? I just had a look and it doesn't look too bad. Anyway:
>
> > open3: open(GLOB(0x1809d50), >&=8) failed: Bad file descriptor at ...
>
> is fairly clear; 8 is not a valid file descriptor. In JVM.pm, $err is
> always \*STDERR, $out and $in are \*STDOUT and \*STDIN respectively,
> unless they're 'new IO::File(">$dn")' where
>
> my $dn = Inline::Java::Portable::portable("DEV_NULL") ;
>
> So my guess would be that Inline::Java::Portable::portable("DEV_NULL")
> might not be quite as portable as it portends.
Nope. It's /dev/null on OSX and that's fine.
Here's a ktrace of the system calls in open3 that lead to the failure:
(with PERL5OPT set to "MCarp=verbose")
open3(>&STDIN, IO::File=GLOB(0x1855518), >&STDERR,
"/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java"
org.perl.inline.java.InlineJavaServer 0 localhost 17891 true false false) at
/Users/timbo/.cpan/sources/authors/id/P/PA/PATL/Inline-Java-0.51/blib/lib/Inline/Java/JVM.pm
line 186.
14699 perl CALL dup(0x5)
14699 perl RET dup 6
14699 perl CALL close(0x5)
14699 perl RET close 0
14699 perl CALL dup2(0x6,0x5)
14699 perl RET dup2 5
14699 perl CALL close(0x6)
14699 perl RET close 0
14699 perl CALL close(0x5)
14699 perl RET close 0
14699 perl CALL pipe
14699 perl RET pipe 5
14699 perl CALL fcntl(0x5,0x3,0)
14699 perl RET fcntl 0
14699 perl CALL fcntl(0x6,0x3,0)
14699 perl RET fcntl 1
14699 perl CALL fcntl(0x5,0x2,0x1)
14699 perl RET fcntl 0
14699 perl CALL fcntl(0x6,0x2,0x1)
14699 perl RET fcntl 0
14699 perl CALL fork
14699 perl RET fork 14700/0x396c
14699 perl CALL close(0x6)
14699 perl RET close 0
14699 perl CALL close(0)
14699 perl RET close 0
14700 perl CALL getpid
14700 perl RET getpid 14700/0x396c
14699 perl CALL close(0x5)
14699 perl RET close 0
14700 perl CALL close(0x5)
14700 perl RET close 0
14700 perl CALL fcntl(0x6,0x3,0)
14700 perl RET fcntl 1
14700 perl CALL fstat(0x6,0x1800460)
14700 perl RET fstat -1 errno 9 Bad file descriptor
14700 perl CALL dup(0x6)
14700 perl RET dup 5
14700 perl CALL close(0x6)
14700 perl RET close 0
14700 perl CALL dup2(0x5,0x6)
14700 perl RET dup2 6
14700 perl CALL close(0x5)
14700 perl RET close 0
14699 perl CALL close(0x3)
14699 perl RET close 0
14699 perl CALL exit(0x1)
14700 perl CALL close(0x6)
14700 perl RET close 0
14700 perl CALL write(0x2,0x1931e00,0x400)
14700 perl GIO fd 2 wrote 1024 bytes
"Can't exec JVM: open3: open(GLOB(0x180a0cc), >&=6) failed: Bad file
descriptor at /usr/local/perl58-i/lib/5.8.6/IPC/Open3.pm line 142
IPC::Open3::xopen('GLOB(0x180a0cc)', '>&=6') called at
/usr/local/perl58-i/lib/5.8.6/IPC/Open3.pm line 222
IPC::Open3::_open3('open3', 'Inline::Java::JVM', '>&STDIN',
'IO::File=GLOB(0x1855518)', '>&STDERR',
'"/System/Library/Frameworks/JavaVM.framework/Versions/Current...') called at
/usr/local/perl58-i/lib/5.8.6/IPC/Open3.pm line 305
IPC::Open3::open3('>&STDIN', 'IO::File=GLOB(0x1855518)',
'>&STDERR', '"/System/Library/Frameworks/JavaVM.framework/Versions/Current...')
called at
/Users/timbo/.cpan/sources/authors/id/P/PA/PATL/Inline-Java-0.51/blib/lib/Inline/Java/JVM.pm
line 188
It looks like the parent closed both side of the pipe and the error is
from the child. I hope this helps someone else as I don't have time to
dig deeper - my real interest lies with the JNI.
So I went back to look at my old emails and found one whre I said:
: But all is well! I've found the problem after some reading of "man ld"
: and http://developer.apple.com/technotes/tn2002/tn2071.html and filling
: in the gaps. What's needed is "-framework JavaVM" options to the linker.
And sure enough, adding -framework JavaVM to the Java/Makefile fixed it.
I've attached a patch.
Tim.
--- ./Java/Portable.pm.orig 2006-06-02 12:27:20.000000000 +0100
+++ ./Java/Portable.pm 2006-06-02 12:24:10.000000000 +0100
@@ -223,7 +223,7 @@
J2SDK_BIN => 'Commands',
DEFAULT_J2SDK_DIR =>
'/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK',
# Tim Bunce:
- OTHERLDFLAGS => '',
+ OTHERLDFLAGS => '-framework JavaVM',
},
} ;