[libinline-java-perl] 06/398: Initial revision

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:42:35 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 02ec5401d0ae4d4e4ea492c4cbe549e86de5bde3
Author: patrick <>
Date:   Thu Mar 1 21:24:43 2001 +0000

    Initial revision
---
 CHANGES     |   5 ++
 Java.pod    | 284 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 MANIFEST    |  11 +++
 Makefile.PL |   7 ++
 README      |  65 ++++++++++++++
 TODO        |  12 +++
 t/01_init.t |   7 ++
 7 files changed, 391 insertions(+)

diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..7352fd1
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,5 @@
+Revision history for Perl extension Inline::Java.
+
+0.01  Thu Feb 15 14:01:25 EST 2001  
+	- Created Inline::Java.
+
diff --git a/Java.pod b/Java.pod
new file mode 100644
index 0000000..d96910a
--- /dev/null
+++ b/Java.pod
@@ -0,0 +1,284 @@
+=head1 NAME
+
+Inline::Java - Write Perl classes in Java.
+
+=head1 SYNOPSIS
+
+   my $alu = new alu() ;
+   print "9 + 16 = ", $alu->add(9, 16), "\n";
+   print "9 - 16 = ", $alu->subtract(9, 16), "\n";
+
+   use Inline Java => <<'END_OF_JAVA_CODE';
+      class alu {
+         public 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
+
+=head1 DESCRIPTION
+
+The C<Inline::Java> 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.
+
+=head1 Using the Inline::Java Module
+
+C<Inline::Java> is driven by fundamentally the same idea as other
+C<Inline> language modules, like C<Inline::C> or C<Inline::CPP>. 
+Because Java is both compiled and interpreted, the method of getting 
+your code is different, but overall, using C<Inline::Java> is very similar 
+to any other C<Inline> language module.
+
+This section will explain the different ways to C<use> Inline::Java.
+For more details on C<Inline>, see 'perldoc Inline'. 
+
+=head2 Basic Usage
+
+The most basic form for using C<Inline::Java> 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<Inline::Java> to function properly, it needs to know 
+where to find the Java compiler (javac) and the Java Runtime (java)
+on your machine. This is done using one of the following techniques:
+
+   - set the JAVA_BIN configuration option to the correct directory
+   - set the JAVA_BIN environment variable to the correct directory
+   - put the correct directory in your PATH environment variable
+
+=head2 Classes and Objects
+
+Because Java is object oriented, any interface between Perl and Java
+needs to support Java classes adequately.
+
+Example: 
+
+   use Inline Java => <<'END';
+      class Foo {
+         String data = "data" ;
+         static String sdata = "static data" ;
+
+         public Foo() {
+            System.out.println("new Foo object being created") ;
+         }
+
+         public String get_data(){
+            return data ;
+         }
+
+         public static get_static_data(){
+            return sdata ;
+         }
+
+         public void set_data(String d){
+            data = d ;
+         }
+      }
+   END
+
+   my $obj = new Foo ;
+   print $obj->get_data() . "\n" ;
+   $obj->set_data("new data") ;
+   print $obj->get_data() . "\n" ;
+
+The output from this program is:
+
+   new Foo object being created
+   data
+   new data
+
+C<Inline::Java> created a new namespace called C<main::Foo> and 
+created the following functions:
+
+   sub main::Foo::new { ... }
+   sub main::Foo::Foo { ... }
+   sub main::Foo::get_data { ... }
+   sub main::Foo::get_sdata { ... }
+   sub main::Foo::set_data { ... }
+   sub main::Foo::DESTROY { ... }
+
+Note that only the public methods are exported to Perl. 
+Note also that the class itself is not public. With 
+C<Inline::Java> you cannot create public classes because Java 
+requires that they be defined in a .java file of the same 
+name (C<Inline::Java> can't work this way).
+
+Inner classes are also supported, you simply need to supply a reference
+to an outer class object as the first parameter of the constructor:
+
+   use Inline Java => <<'END';
+      class Foo {
+         public Foo() {
+         }
+
+         public class Bar {
+
+            public Bar() {
+            }
+         }
+      }
+   END
+
+   my $obj = new Foo() ;
+   my $obj2 = new Bar($obj) ;
+
+Also of importance is that you can't use C<Data::Dumper> on objects
+returned by Java methods. This is because these objects are C<tie>d
+sp that you can set and get the values for member variables. This is not
+implemented yet though. If you want to look at an objects guts, you can 
+use :
+
+   print Dumper($obj->private()) ;
+
+=head2 Methods
+
+In the previous example we have seen how to call a method. You can also
+call static methods in the following manner:
+
+   print Foo->get_sdata() . "\n" ;
+   # or
+   my $obj = new Foo() ;
+   print $obj->get_sdata() . "\n" ;
+	
+both of these will print:
+   
+   static data   
+
+You can pass any kind of Perl scalar or any Java object to a method. It
+will be automatically converted to the correct type:
+
+   use Inline Java => <<'END';
+      class Foo2 {
+         public Foo2(int i, String j, Foo k) {
+            ...
+         }
+      }
+   END
+
+   my $obj = new Foo() ;
+   my $obj2 = new Foo2(5, "toto", $obj) ;
+
+will work fine. These objects can be of any type, even if these types
+are not know to C<Inline::Java>. This is also true for return types:
+
+   use Inline Java => <<'END';
+      import java.util.* ;
+
+      class Foo3 {
+         public Foo3() {
+         }
+
+         public HashMap get_hash(){
+            return new HashMap() ;
+         }
+
+         public void do_stuff_to_hash(HashMap h){
+            ...
+         }
+      }
+   END
+
+   my $obj = new Foo3() ;
+   my $h = $obj->gethash() ;
+   $obj->do_stuff_to_hash($h) ;
+
+Objects of types unknown to Perl can exist in the Perl space, you just 
+can't call any of their methods.
+
+=head2 Member variables
+
+Currently public member variables are not visible from the Perl space. 
+This will be implemented in a future version
+
+=head2 Arrays
+
+Currently array are not supported in C<Inline::Java>. 
+This will be implemented in a future version
+
+=head1 SUPPORTED PLATFORMS
+
+This is an ALPHA release of Inline::Java. Further testing and
+expanded support for other operating systems and platforms will be a
+focus for future releases. It has been tested on Solaris 2.5.1, with
+Perl 5.6 and Java SDK 1.2.1. It likely will work with many other
+configuration under Unix, and possibly under Windows.
+
+=head1 SEE ALSO 
+
+For information about using C<Inline>, see L<Inline>.
+
+For information about other Inline languages, see L<Inline-Support>.
+
+Inline::Java's mailing list is inline at perl.org
+
+The subscribe, send email to inline-subscribe at perl.org
+
+=head1 BUGS AND DEFICIENCIES
+
+When reporting a bug, please do the following:
+
+ - Put "use Inline REPORTBUG;" at the top of your code, or 
+   use the command line option "perl -MInline=REPORTBUG ...".
+ - Run your code.
+ - Follow the printed instructions.
+
+Here are some things to watch out for:
+
+=over 4
+
+=item 1
+
+
+=item 2
+
+
+=back
+
+=head1 AUTHOR
+
+Patrick LeBoutillier <patrick_leboutillier at hotmail.com>
+
+Brian Ingerson <INGY at cpan.org> is the author of Inline, Inline::C and
+Inline::CPR. He was responsible for much encouragement and many
+suggestions throughout the development of Inline::Java.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2000, Neil Watkiss.
+
+All Rights Reserved. This module is free software. It may be used,
+redistributed and/or modified under the terms of the Perl Artistic
+License.
+
+(see http://www.perl.com/perl/misc/Artistic.html)
+
+=cut
diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000..82eff46
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,11 @@
+CHANGES
+Java.pm
+Java.pod
+MANIFEST
+Makefile.PL
+README
+t/
+Java/private/Init.pm
+Java/private/Object.pm
+Java/private/Protocol.pm
+
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..b0d0764
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,7 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+	      NAME => 'Inline::Java',
+	      VERSION_FROM => 'Java.pm',
+	      clean => {FILES => '_Inline_test/'},
+	     );
diff --git a/README b/README
new file mode 100644
index 0000000..1442e4d
--- /dev/null
+++ b/README
@@ -0,0 +1,65 @@
+INTRODUCTION:
+
+Inline::Java - Write Perl classes in Java.
+
+Inline::Java lets you write Perl classes in Java.
+
+Example:
+
+    use Inline Java => <<'END',
+	    class JAxH {
+			public JAxH(String x){
+				System.out.println("Just Another " + x + " Hacker") ;
+			}
+	    }
+	END
+    
+    new JAxH('Inline') ;
+
+When run, this complete program prints:
+
+    Just Another Inline Hacker
+
+-------------------------------------------------------------------------------
+INSTALLATION:
+
+This module requires Inline.pm version 0.31 or higher to be installed.
+
+To install Inline::Java do this:
+
+perl Makefile.PL
+make
+make test
+make install
+
+You have to 'make install' before you can run it successfully.
+
+-------------------------------------------------------------------------------
+FEATURES:
+
+Inline::Java version 0.01 includes:
+
++ All classes and their public methods are exported to Perl, relative
+  to your current package.
++ All objects (except arrays) and primitive Java types are supported as
+  method parameters.
+
+-------------------------------------------------------------------------------
+INSTALLATION:
+
+This module requires the Inline module. 
+It also requires a version of Sun's Java2 SDK.
+
+-------------------------------------------------------------------------------
+INFORMATION:
+
+= For more information on Inline::Java, see 'perldoc Inline::Java'.
+= For information about Inline, see 'perldoc Inline'.
+= For information on using Java, visit http://java.sun.org
+
+The Inline::Java mailing list is inline at perl.org. 
+Send email to inline-subscribe at perl.org to subscribe.
+
+Please send questions and comments to "Patrick LeBoutillier" <patrick_leboutillier at hotmail.com>
+
+Copyright (c) 2001, Patrick LeBoutillier. All Rights Reserved.  
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..4d12ca5
--- /dev/null
+++ b/TODO
@@ -0,0 +1,12 @@
+- Documentation
+- Code comments
+- Code cleanup
+- Arrays
+- Casting
+
+PORTABILITY ISSUES:
+- find_java_bin (getpwuid)
+- path sep ":"
+- fork, exec
+- makefile stuff
+
diff --git a/t/01_init.t b/t/01_init.t
new file mode 100644
index 0000000..e5e0e45
--- /dev/null
+++ b/t/01_init.t
@@ -0,0 +1,7 @@
+use strict;
+use Test;
+
+mkdir('./_Inline_test', 0777) unless -e './_Inline_test';
+
+plan(tests => 1);
+ok(1);

-- 
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