dslinux/user/perl/jpl ChangeLog README README.JUST-JNI SETVARS.PL install-jpl

cayenne dslinux_cayenne at user.in-berlin.de
Mon Dec 4 17:59:58 CET 2006


Update of /cvsroot/dslinux/dslinux/user/perl/jpl
In directory antilope:/tmp/cvs-serv17422/jpl

Added Files:
	ChangeLog README README.JUST-JNI SETVARS.PL install-jpl 
Log Message:
Adding fresh perl source to HEAD to branch from

--- NEW FILE: README ---
Copyright 1998, O'Reilly & Associates, Inc.

This package may be copied under the same terms as Perl itself.

Disclaimers
-----------
This is a work in progress, and relies on bleeding-edge technology
from the network.  Don't expect not to be surprised occasionally.

Requirements
------------
Under Solaris and GNU/Linux (and other Unix-like systems), Perl 5.005 (or
later) must be compiled and installed as a shared library (libperl.so).  I
had to use the system's malloc.  JPL was originally built and tested with
5.004_04 and early Java 1.1 development kits.  This version has not been
well tested under other versions, so you can expect some rough edges.

You need JDK 1.1.  On Solaris, 1.1.5 has been verified to work.  GNU/Linux
users can try the latest version (1.1.3 or later) available from (for
example):

  ftp://ftp.blackdown.org/pub/Linux/JDK/1.1.3/updates/libjava-1.1.3v2-1.tar.gz

(GNU/Linux users can also try Kaffe (see below).)

The get_jdk directory contains a script that will download JDK (but not
the patch file above) off of the net for you.  (This presumes you've
already installed the modules mentioned in ../README.)

You may need to ensure that all files under the ../jpl directory are writable.
install-jpl expects to be run with super-user privileges so that it can
put things in the right places.

Microsoft Windows
-----------------
Only a subset of JPL works under Microsoft Windows.  This subset includes
the JNI extension and the JPL module.  This is enough for you to embed
Java in Perl, but not Perl in Java.

This has only been tested with the Sun JDK 1.1.8. I haven't tested it
with JDK 1.2 (aka Java 2) or any Microsoft implementation of Java.

Kaffe
-----
You might notice some mention of Kaffe (www.kaffe.org) in the source files.
This is because support has been added for Kaffe for JNI:: and JPL::.  In
other words, you can now call to Java from Perl using Kaffe.

You'll likely need the a checkout circa 2000-12-03 or later from Kaffe's
CVS.  It has been verified that Kaffe 1.0.5 definitely *will not work*.
Kaffe 1.0.6 might work, but the CVS tree definitely works (as of
2000-12-06).

You can get the CVS tree from:

cvs -z3 -d ':pserver:readonly at cvs.kaffe.org:/cvs/kaffe' checkout kaffe

(password is 'readonly')

What the heck is JPL?
---------------------
JPL is a hybrid (to use the polite term) language.  It's basically Java
in which the methods can optionally be implemented by Perl code.  A
preprocessor called "JPL::Compile" looks at your .jpl file and spits
out the appropriate .java, .c, .h, .pl, and .so files to accomplish the
desired task.  Hopefully a lot of those files can go away in the future
as jpl mutates into a Perl-to-Java compiler.  The long-term goal is for
jpl to be able to take a pure Perl file and spit out a java .class
file.  This initial version of JPL is an attempt to begin to mesh the
semantics of Java and Perl.  Some people may find it useful in its
current form, but you should know right up front that we've still got a
ways to go with it.  A journey of a thousand miles continues with the
second step...

JPL Syntax
----------
JPL syntax is trivial, given that you know Java and Perl.  Pretend like
you're writing a native Java method, but say "perl" instead of
"native", and then instead of omitting the body of the method, put your
Perl code in double curlies.  (See Sample.jpl for an example.)

Calling back from Perl to Java is done through the JNI (Java Native
Interface).  No weird transmogrifications are done by the preprocessor
to your Perl code--it's all normal Perl.  The preprocessor just wraps
it up into funny subroutines you don't see unless you peek at the .pl
file it generates.

Installation
------------
There are two ways to install JPL.

The first way gives you the ability to embed Perl in Java programs. You
can also call back into Java from your embedded Perl programs. This should
work well with most JDKs, and is the only option for people using a JDK
that uses green threads (see your JDK documentation). 

The second way lets you embed Java in Perl, but doesn't provide support
for the other direction. This is good, in theory, if you need to work with
a lot of Java classes from within Perl.  I say "in theory," because this 
doesn't actually work a lot of the time.  To use this second way, you
must be using a JDK with native threads. Please see README.JUST-JNI for 
details.

At this point, the second way is the only way to use JPL under Microsoft 
Windows, and probably the only way to use JPL if you're using a version
of Perl compiled by someone else (such as the Perl that comes with RedHat). 

Installation the First Way (All of JPL)
---------------------------------------
Run "install-jpl".  You have to tell it whether you want to use the
current directory for JPL_HOME or some other directory.  Everything
else should take care of itself, except that after install-jpl
writes the setvars program, you are responsible to invoke it properly
before any JPL applications can be compiled under the current shell.

    sh:   eval `setvars -sh`
    csh:  eval `setvars -csh`
    perl: eval `setvars -perl`;

install-jpl has been tested under:

    Solaris 2.5.1 SPARC, GCC 2.8.0, Perl 5.005_03, JDK 1.1.7
    Debian 2.1 x86, Perl 5.005_60, JDK 1.1.7v3

********************
Solaris 2.5.1 Users:
********************

NOTE: Under Solaris 2.5.1, you may get an error message when install-jpl
builds Sample.jpl:

    You must install a Solaris patch to run this version of the Java 
    runtime.  Please see the README and release notes for more 
    information.
    Exiting.

  This is apparently a spurious message, and it has been reported to 
  Sun.  Although this message aborts the installation, all of JPL is 
  installed by the time this message is reached. To recover and continue, 
  run setvars as described above, cd to the Sample directory, and type
  'make' to continue building. You can then run 'java Sample' to test the 
  example.

  Unfortunately, each time you use 'make' to build a JPL application,
  it will abort when it tries to run 'perl -c' on the generated .pl
  file.  However, you can continue building by typing 'make' again.

Mailing List
------------
To subscribe to the jpl mailing list, send an email message to 
jpl-subscribe at perl.org.

CVS Access
----------
Information on accessing the bleeding edge JPL via CVS can be found at:

    http://users.ids.net/~bjepson/jpl/cvs.html

More Info
---------

You can look at the Sample and Test directories, as well as the ../eg
directory for examples.

Perhaps the most important bit of advice we can give you is to watch

    http://perl.oreilly.com

for further information on how to get further information.

Have the appropriate amount of fun.

--- NEW FILE: ChangeLog ---
2000-12-18  Bradley M. Kuhn  <bkuhn at ebb.org>

	* JNI/JNI.pm: Updated version to 0.1

2000-12-16  Bradley M. Kuhn  <bkuhn at ebb.org>

	* JNI/JNI.pm (AUTOLOAD): Added check to make sure fiels only
	appear once in CLASSPATH. 

2000-12-07  Bradley M. Kuhn  <bkuhn at ebb.org>

	* JNI/JNI.xs: Added a requirement that -DJPL_DEBUG be defined for
	JNI.xs to print out jpldebug options

2000-12-06  Bradley M. Kuhn  <bkuhn at ebb.org>

	* JNI/JNI.pm: removed some stray C-m's floating in the file

	* README.JUST-JNI: Added instructions concerning Kaffe.

	* JNI/JNI.xs (GetJavaVM): Added support for Kaffe's options, and
	made sure version number gets set.  Also did error checking on
	creating the JVM.
	Fixed bug on option processing.

	* JNI/Makefile.PL: Added support to configure Kaffe, including
	automatic creation of JNI/Config.pm (a new file).

	* JNI/JNI.pm (AUTOLOAD): Added support for Kaffe.


--- NEW FILE: README.JUST-JNI ---
Just-JNI (call into Java from Perl only)
----------------------------------------

This has been tested with:

    Debian GNU/Linux 2.2 i386, perl 5.6.0, Kaffe (CVS, 2000-12-05 or later)
    RedHat 6.1, perl-5.00503-6 (RedHat RPM), IBM JDK 1.1.8
    Debian 2.1 SPARC, Perl 5.005_60, JDK 1.2 beta (crashes with AWT, though)
    Windows NT 4.0 SP4, ActivePerl 519, JDK 1.1.8, Visual C++
    Solaris 7, Perl 5.005_03, JDK 1.1.6, GCC 2.8.1

Solaris 7 Note (this probably applies to all native thread situations):

    Native threads were tricky. I had to build my own Perl, configured with:

    sh Configure -Dprefix=/opt/perl5.005 -Duseshrplib -Doptimize=-g \
                 -Uusemymalloc -D cc=gcc -Dusethreads -d

    When Configure let me edit config.sh, I changed libs to:

    libs='-lthread -lsocket -lnsl -ldl -lm -lposix4 -lpthread -lc -lcrypt'

    The leading -lthread is the only thing I had to add.

Kaffe Note:

I believe that Kaffe with JIT enabled will likely be problematic.  I had a
lot of trouble with it, that simply went away with interpreter-based Kaffe.
FWIW, here's how I configured Kaffe:

     env AM_CPPFLAGS=-DDEBUG CFLAGS="-O0 -ggdb" ./configure --disable-gcj \
                                                  --with-engine=intrp

Likely you don't need all that debugging stuff.

Also, when I build perl, I do this, to be on the safe side.  I was worried
about thread interaction, but realized there was no need to build threaded
perl, but I thought that the perl code should probably be reentrant, so, I
did this:

      sh ./Configure -Dcc=gcc -Doptimize='-D_REENTRANT -DDEBUGGING -ggdb'  \
                     -Dlibperl='libperl.so' -Duseshrplib='true' 

Again, you likely don't need the debugging flags.


How do I do this crazy thing?
-----------------------------

1) Cd into the JPL directory. Type the following:

    perl Makefile.PL
    make
    make install

   Under windows, that's:

    perl Makefile.PL
    nmake
    nmake install

3) cd into the JNI directory (cd ../JNI or cd ..\JNI)   

4) We now need to compile and make the Closer.class available to your 
   JPL program.  Closer is a WindowListener that closes the Frame we 
   make in the test program.

   It seems that we've managed to fix the problem with CLASSPATH not
   getting propagated to the JVM, so if '.' is in your CLASSPATH, you
   should be able to compile Closer.java and leave it in the current
   directory:

       javac Closer.java

     or perhaps

       jikes Closer.java

5) Make the demo:

    a) type the following:

      for SUN's proprietary software Java:

	env JAVA_HOME=/path/to/java perl Makefile.PL
	# setting the JAVA_HOME enviornment variable might not be needed
	# if Java is in installed in a canonical location
        make
        make test

      for Kaffe:

	env KAFFE_PREFIX=/kaffe/installation/prefix perl Makefile.PL
	# setting the KAFFE_PREFIX enviornment variable might not be needed
	# if Kaffe is in a canonical location
        make
        make test

       Under Windows:

        perl Makefile.PL
        nmake
        nmake test


    b) if all went well, type:

        make install

       or, under Windows:

        nmake install


--- NEW FILE: SETVARS.PL ---
# Your JDK top-level directory.
#
$ENV{JAVA_HOME} = 'c:\jdk1.1.8';

# The location where you extracted JPL.
#
$ENV{JPL_HOME} = 'D:\jpl';

# The executeable name of Perl
#
$ENV{JPLPERL} = 'perl';

--- NEW FILE: install-jpl ---
#!/usr/bin/perl

print <<'END' if $>;
NOTE: Since you're not running as root, the installation will su at
the appropriate time later.  You will need to supply the root password
for the su program.

END

# Gather data.

# JPL_SRC

chop($JPL_SRC = `pwd`);
print "JPL_SRC = $JPL_SRC\n";

# JAVA_HOME

foreach $dir (
    $ENV{JAVA_HOME},
    "/usr/java",
    "/usr/local/java",
    "/usr/lib/java",
    "/usr/local/lib/java",
) {
    $JAVA_HOME = $dir, last if $dir and -d "$dir/bin";
}
die "You must set the \$JAVA_HOME environment variable first.\n"
	unless $JAVA_HOME;
print "JAVA_HOME = $JAVA_HOME\n";

# JPL_HOME

($likelyjpl = $JAVA_HOME) =~ s#(.*)/.*#$1/jpl#;

print <<"END";

You need to decide which directory JPL files are to be installed in.
Applications will look in subdirectories of this directory for any JPL
related files.

You may use the current directory ($JPL_SRC)
or you may use a directory such as $likelyjpl.

END

$| = 1;
until (-d $JPL_HOME) {
    print "Install JPL files where: [$JPL_SRC] ";
    chop($JPL_HOME = <STDIN>);
    $JPL_HOME ||= $JPL_SRC;
    unless (-d $JPL_HOME) {
	print "Warning: $JPL_HOME doesn't exist yet!\n\n";
	print "Do you want to create it? [y] ";
	chop($ans = <STDIN>);
	$ans ||= 'y';
	next unless $ans =~ /^y/i;

	system "mkdir -p $JPL_HOME";
	if ($> and not -d $JPL_HOME) {
	    warn "Couldn't create $JPL_HOME!\nTrying again as root...running su...\n";
	    system "set -x
su root -c 'mkdir -p $JPL_HOME && chown $> $JPL_HOME && chmod 0755 $JPL_HOME'";
	    warn "Couldn't create $JPL_HOME!\n" unless -d $JPL_HOME;
	}
    }
}
print "JPL_HOME = $JPL_HOME\n";

#########################################################################
# Spit out setvars.

print "Writing setvars...\n";

unlink "$JPL_SRC/setvars";
open(SETVARS, ">$JPL_HOME/setvars") or die "Can't create setvars: $!\n";
while (<DATA>) {
    s/^JPL_SRC=.*/JPL_SRC='$JPL_SRC'/;
    s/^JAVA_HOME=.*/JAVA_HOME='$JAVA_HOME'/;
    s/^JPL_HOME=.*/JPL_HOME='$JPL_HOME'/;
    print SETVARS $_;
}
close SETVARS;
chmod 0755, "$JPL_HOME/setvars";
symlink "$JPL_HOME/setvars", "$JPL_SRC/setvars" if $JPL_HOME ne $JPL_SRC;

#########################################################################
# Pretend we're make.

eval `./setvars -perl`;		# Take our own medicine.

print "\n\nStarting install...\n";

system <<'END' and die "Couldn't install JPL\n";
set -x
cd JPL
perl Makefile.PL
make clean
perl Makefile.PL
make install
END

print "\nInstalling PerlInterpreter class\n";

system <<'END' and die "Couldn't install PerlInterpreter\n";
set -x
cd PerlInterpreter
perl Makefile.PL
make clean
perl Makefile.PL
make install
END

print "\nInstalling JNI module\n";

system <<'END' and die "Couldn't install JNI\n";
set -x
cd JNI
perl Makefile.PL -e
make clean
perl Makefile.PL -e
make
echo 'Attempting to install JNI as root'
su root -c "make install"
END

#touch Makefile
#make -f makefile.jv
## These should be executed as root
#rm -rf /usr/lib/perl5/site_perl/i586-linux/auto/JNI
#rm -rf /usr/lib/perl5/site_perl/auto/JNI
#rm -f  /usr/lib/perl5/site_perl/JNI.pm
#make -f makefile.jv install UNINST=1 

print "\nInstalling Sample JPL program\n";

system <<'END' and die "Couldn't install Sample\n";
set -x
cd Sample
perl Makefile.PL
make clean
perl Makefile.PL
make install
END

# Test
print "\n\nTesting Sample...\n";
system <<'END' and die "Couldn't run Sample\n";
set -x
cd Sample
JPLDEBUG=1
export JPLDEBUG
java Sample
END

__END__
#!/bin/sh

# You can edit this, but your changes will only last until the next
# time you run install-jpl.

# Where jpl is currently installed

cd `dirname $0`
JPL_SRC=`pwd`

# Where java is installed

JAVA_HOME=/usr/local/java
export JAVA_HOME

# Where jpl will be installed

JPL_HOME="$JPL_SRC"
export JPL_HOME

# Which perl to run

JPLPERL=perl`perl -e "print $]"`
#JPLPERL=perl5.00404
export JPLPERL

# Some derivative variables
archname=`$JPLPERL -MConfig -e 'print $Config{archname}'`
 archlib=`$JPLPERL -MConfig -e 'print $Config{archlib}'`

CLASSPATH=".:$JPL_HOME/lib${CLASSPATH:+:$CLASSPATH}"
export CLASSPATH

LD_LIBRARY_PATH=".:$JPL_HOME/lib/$archname:$archlib/CORE${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH

PERL5LIB="$JPL_HOME/perl${PERL5LIB:+:$PERL5LIB}"
export PERL5LIB

# Make sure the right java programs are selected.
PATH="$JAVA_HOME/bin:$PATH"
export PATH

case "$1" in
-perl)
    cat <<END
\$ENV{PATH} = '$PATH';
\$ENV{JAVA_HOME} = '$JAVA_HOME';
\$ENV{JPL_HOME} = '$JPL_HOME';
\$ENV{JPLPERL} = '$JPLPERL';
\$ENV{CLASSPATH} = '$CLASSPATH';
\$ENV{LD_LIBRARY_PATH} = '$LD_LIBRARY_PATH';
\$ENV{PERL5LIB} = '$PERL5LIB';
END
    ;;
-sh)
    cat <<END
 PATH='$PATH';export PATH;JAVA_HOME='$JAVA_HOME';export JAVA_HOME;JPL_HOME='$JPL_HOME';export JPL_HOME;JPLPERL='$JPLPERL';export JPLPERL;CLASSPATH='$CLASSPATH';export CLASSPATH;LD_LIBRARY_PATH='$LD_LIBRARY_PATH';export LD_LIBRARY_PATH;PERL5LIB='$PERL5LIB';export PERL5LIB
END
    ;;
-csh)
    cat <<END
setenv PATH '$PATH';
setenv JAVA_HOME '$JAVA_HOME';
setenv JPL_HOME '$JPL_HOME';
setenv JPLPERL '$JPLPERL';
setenv CLASSPATH '$CLASSPATH';
setenv LD_LIBRARY_PATH '$LD_LIBRARY_PATH';
setenv PERL5LIB '$PERL5LIB';
END
    ;;
esac





More information about the dslinux-commit mailing list