Inline-Java-0.53/0000755000076400007640000000000011512335757013763 5ustar patricklpatricklInline-Java-0.53/MANIFEST0000644000076400007640000000446311407146510015111 0ustar patricklpatricklCHANGES MANIFEST README README.JNI TODO META.yml Makefile.PL Java.pm Java.pod Java/Object.pm Java/Protocol.pm Java/Class.pm Java/Callback.pm Java/Callback.pod Java/Portable.pm Java/Array.pm Java/Handle.pm Java/Makefile.PL Java/JVM.pm Java/Server.pm Java/JNI.pm Java/JNI.xs Java/typemap Java/jvm.def Java/sources/org/perl/inline/java/InlineJavaArray.java Java/sources/org/perl/inline/java/InlineJavaCastException.java Java/sources/org/perl/inline/java/InlineJavaClass.java Java/sources/org/perl/inline/java/InlineJavaException.java Java/sources/org/perl/inline/java/InlineJavaInvocationTargetException.java Java/sources/org/perl/inline/java/InlineJavaPerlCaller.java Java/sources/org/perl/inline/java/InlineJavaPerlException.java Java/sources/org/perl/inline/java/InlineJavaProtocol.java Java/sources/org/perl/inline/java/InlineJavaServer.java Java/sources/org/perl/inline/java/InlineJavaServerThread.java Java/sources/org/perl/inline/java/InlineJavaThrown.java Java/sources/org/perl/inline/java/InlineJavaUserClassLink.java Java/sources/org/perl/inline/java/InlineJavaUserClassLoader.java Java/sources/org/perl/inline/java/InlineJavaUtils.java Java/sources/org/perl/inline/java/InlineJavaCallback.java Java/sources/org/perl/inline/java/InlineJavaCallbackQueue.java Java/sources/org/perl/inline/java/InlineJavaPerlNatives.java Java/sources/org/perl/inline/java/InlineJavaPerlInterpreter.java Java/sources/org/perl/inline/java/InlineJavaPerlObject.java Java/sources/org/perl/inline/java/InlineJavaHandle.java Java/PerlNatives/Makefile.PL Java/PerlNatives/PerlNatives.pm Java/PerlNatives/PerlNatives.xs Java/PerlNatives/PerlNatives.pod Java/PerlNatives/t/01_init.t Java/PerlNatives/t/02_perl_natives.t Java/PerlInterpreter/Makefile.PL Java/PerlInterpreter/PerlInterpreter.pm Java/PerlInterpreter/PerlInterpreter.xs Java/PerlInterpreter/PerlInterpreter.pod Java/PerlInterpreter/t/01_init.t Java/PerlInterpreter/t/02_perl_interpreter.t Java/PerlInterpreter/t/Tests.pl t/01_init.t t/02_primitives.t t/02_primitives_1_4.t t/03_objects.t t/04_members.t t/05_arrays.t t/06_static.t t/07_polymorph.t t/08_study.t t/09_usages.t t/10_1_shared_alone.t t/10_5_shared_fork.t t/10_6_shared_sim.t t/11_exceptions.t t/12_1_callbacks.t t/13_handles.t t/14_encoding.t t/15_native_doubles.t t/99_end.t t/types.java t/types.class t/no_const.java t/no_const.class t/shared.java Inline-Java-0.53/Java.pod0000644000076400007640000007617411176663515015371 0ustar patricklpatrickl=head1 NAME Inline::Java - Write Perl classes in Java. =head1 SYNOPSIS =for comment use Inline Java => <<'END_OF_JAVA_CODE' ; class Pod_alu { public Pod_alu(){ } public int add(int i, int j){ return i + j ; } public int subtract(int i, int j){ return i - j ; } } END_OF_JAVA_CODE my $alu = new Pod_alu() ; print($alu->add(9, 16) . "\n") ; # prints 25 print($alu->subtract(9, 16) . "\n") ; # prints -7 =for comment =head1 DESCRIPTION The C module allows you to put Java source code directly "inline" in a Perl script or module. A Java compiler is launched and the Java code is compiled. Then Perl asks the Java classes what public methods have been defined. These classes and methods are available to the Perl program as if they had been written in Perl. The process of interrogating the Java classes for public methods occurs the first time you run your Java code. The namespace is cached, and subsequent calls use the cached version. Z<> =head1 USING THE Inline::Java MODULE C is driven by fundamentally the same idea as other C language modules, like C or C. Because Java is both compiled and interpreted, the method of getting your code is different, but overall, using C is very similar to any other C language module. This section will explain the different ways to C Inline::Java. For more details on C, see 'perldoc Inline'. B The most basic form for using C is: use Inline Java => 'Java source code' ; Of course, you can use Perl's "here document" style of quoting to make the code slightly easier to read: use Inline Java => <<'END'; Java source code goes here. END The source code can also be specified as a filename, a subroutine reference (sub routine should return source code), or an array reference (array contains lines of source code). This information is detailed in 'perldoc Inline'. In order for C to function properly, it needs to know where to find a Java 2 SDK on your machine. This is done using one of the following techniques: =over 4 =item 1 Set the J2SDK configuration option to the correct directory =item 2 Set the PERL_INLINE_JAVA_J2SDK environment variable to the correct directory =back If none of these are specified, C will use the Java 2 SDK that was specified a install time (see below). =head1 DEFAULT JAVA 2 SDK When C was installed, the path to the Java 2 SDK that was used was stored in a file called default_j2sdk.pl that resides with the C module. You can find this file by using the following command: % perl -MInline::Java=j2sdk If you wish to permanently change the default Java 2 SDK that is used by C, edit this file and change the value found there. If you wish use a different Java 2 SDK temporarily, see the J2SDK configuration option described below. Additionally, you can use the following command to get the list of directories that you should put in you shared library path when using the JNI extension: % perl -MInline::Java=so_dirs =head1 CONFIGURATION OPTIONS There are a number of configuration options that dictate the behavior of C: =over 4 =item J2SDK Specifies the path to your Java 2 SDK. Ex: J2SDK => '/my/java/2/sdk/path' Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item PORT Specifies the port number for the server. Default is -1 (next available port number), default for SHARED_JVM mode is 7891. Ex: PORT => 4567 Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item HOST Specifies the host on which the JVM server is running. This option really only makes sense in SHARED_JVM mode when START_JVM is disabled. Ex: HOST => 'jvm.server.com' Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item BIND Specifies the IP address on which the JVM server will be listening. By default the JVM server listens for connections on 'localhost' only. Ex: BIND => '192.168.1.1' Ex: BIND => '0.0.0.0' Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item STARTUP_DELAY Specifies the maximum number of seconds that the Perl script will try to connect to the Java server. In other this is the delay that Perl gives to the Java server to start. Default is 15 seconds. Ex: STARTUP_DELAY => 20 Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item CLASSPATH Adds the specified CLASSPATH. This CLASSPATH will only be available through the user classloader. To set the CLASSPATH globally (which is most probably what you want to do anyways), use the CLASSPATH environment variable. Ex: CLASSPATH => '/my/other/java/classses' =item JNI Toggles the execution mode. The default is to use the client/server mode. To use the JNI extension (you must have built it at install time though. See README and README.JNI for more information), set JNI to 1. Ex: JNI => 1 Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item EXTRA_JAVA_ARGS, EXTRA_JAVAC_ARGS Specify extra command line parameters to be passed to, respectively, the JVM and the Java compiler. Use with caution as some options may alter normal C behavior. Ex: EXTRA_JAVA_ARGS => '-Xmx96m' Note: EXTRA_JAVA_ARGS only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item EMBEDDED_JNI Same as JNI, except C expects the JVM to already be loaded and to have loaded the Perl interpreter that is running the script. This is an advanced feature that should only be need in very specific circumstances. Ex: EMBEDDED_JNI => 1 Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. Also, the EMBEDDED_JNI option automatically sets the JNI option. =item SHARED_JVM This mode enables mutiple processes to share the same JVM. It was created mainly in order to be able to use C under mod_perl. Ex: SHARED_JVM => 1 Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item START_JVM When used with SHARED_JVM, tells C that the JVM should already be running and that it should not attempt to start a new one. This option is useful in combination with command line interface described in the BUGS AND DEFICIENCIES section. Default is 1. Ex: START_JVM => 0 Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item PRIVATE In SHARED_JVM mode, makes every connection to the JVM use a different classloader so that each connection is isolated from the others. Ex: PRIVATE => 1 Note: This configuration option only has an effect on the first 'use Inline Java' call inside a Perl script, since all other calls make use of the same JVM. =item DEBUG Enables debugging info. Debugging now uses levels (1 through 5) that (loosely) follow these definitions: 1 = Major program steps 2 = Object creation/destruction 3 = Method/member accesses + packet dumps 4 = Everything else 5 = Data structure dumps Ex: DEBUG => 2 =item DEBUGGER Starts jdb, (the Java debugger) instead of the regular Java JVM. This option will also cause the Java code to be compiled using the '-g' switch for extra debugging information. EXTRA_JAVA_ARGS can be used use to pass extra options to the debugger. Ex: DEBUGGER => 1 =item WARN_METHOD_SELECT Throws a warning when C has to 'choose' between different method signatures. The warning states the possible choices and the signature chosen. Ex: WARN_METHOD_SELECT => 1 =item STUDY Takes an array of Java classes that you wish to have C learn about so that you can use them inside Perl. Ex: STUDY => ['java.lang.HashMap', 'my.class'] =item AUTOSTUDY Makes C automatically study unknown classes it encounters them. Ex: AUTOSTUDY => 1 =item PACKAGE Forces C to bind the Java code under the specified package instead of under the current (caller) package. Ex: PACKAGE => 'main' =item NATIVE_DOUBLES Normally, C stringifies floating point numbers when passing them between Perl and Java. In certain cases, this can lead to loss of precision. When NATIVE_DOUBLES is set, C will send the actual double bytes in order to preserve precision. Note: This applies only to doubles, not floats. Note: This option may not be portable and may not work properly on some platforms. Ex: NATIVE_DOUBLES => 1 =back =head1 ENVIRONMENT VARIABLES Every configuration option listed above, with the exception of STUDY, can be specified using an environment variable named using the following convention: PERL_INLINE_JAVA_