[libinline-java-perl] 252/398: ok 0.44 RC2

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:43:11 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 3dd9b2ff17a215ca776a10c193a321fb3c1cc3d6
Author: patrick_leb <>
Date:   Sun Nov 23 22:18:04 2003 +0000

    ok 0.44 RC2
---
 CHANGES                                  |  5 +++
 Java.pod                                 | 68 +++++++++++++++++++++++++++++++-
 Java/JNI.xs                              | 25 ------------
 Java/JVM.pm                              |  5 +--
 Java/sources/InlineJavaServer.java       |  5 ++-
 Java/sources/InlineJavaServerThread.java |  5 ---
 README                                   |  4 +-
 7 files changed, 80 insertions(+), 37 deletions(-)

diff --git a/CHANGES b/CHANGES
index c54d4e9..c394c21 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
 Revision history for Perl extension Inline::Java
 ------------------------------------------------
 
+0.44  Sun Nov 23 15:47:06 EST 2003
+    - Callbacks from multiple threads are now supported.
+    - Refactored (again...) studying/.jdat/cache stuff
+    - Fixed memory leak in JNI coded (patch submitted by Dave Blob)
+
 0.43  Tue Oct 14 13:18:25 EDT 2003
     - Restored $VERSION in each .pm file
     - Inline::Java now formerly requires Perl 5.6
diff --git a/Java.pod b/Java.pod
index dcda319..a3f3700 100644
--- a/Java.pod
+++ b/Java.pod
@@ -187,6 +187,14 @@ behavior of C<Inline::Java>:
       'use Inline Java' call inside a Perl script, since all other calls 
       make use of the same JVM.
 
+   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.
+
    DEBUG:
       Enables debugging info. Debugging now uses levels (1 through 5)
       that (loosely) follow these definitions:
@@ -618,7 +626,7 @@ an "Inline::Java" object. Here is a example of a typical use:
       import org.perl.inline.java.* ;
 
       class Pod_regexp extends InlineJavaPerlCaller {
-         public Pod_regexp(){
+         public Pod_regexp() throws InlineJavaException {
          }
 
          public boolean match(String target, String pattern)
@@ -666,6 +674,64 @@ that $@ was a Perl scalar, you can use the GetString method).
    Z<>
 
 
+=head1 CALLBACK LOOPS
+
+As of 0.44, it is now possible to use callbacks from differents Java threads.
+One of the big advantages of this is that you can now handle, for example,
+SWING events in Perl. Here's an example:
+
+=for comment
+
+   use Inline Java => <<'END' ;
+      import java.util.* ;
+      import org.perl.inline.java.* ;
+      import javax.swing.* ;
+      import java.awt.event.* ;
+
+      class Pod_Button extends InlineJavaPerlCaller
+                       implements ActionListener {
+         public Pod_Button() throws InlineJavaException {
+            JFrame frame = new JFrame("Pod_Button") ;
+            frame.setSize(100,100) ;
+            JButton button = new JButton("Click Me!") ;
+            frame.getContentPane().add(button) ;
+            button.addActionListener(this) ;
+            frame.show() ;
+         }
+
+         public void actionPerformed(ActionEvent e){
+            try {
+               CallPerl("main", "button_pressed", new Object [] {}) ;
+            }
+            catch (InlineJavaPerlException pe){ }
+            catch (InlineJavaException pe) { pe.printStackTrace() ;}
+         }
+      }
+   END
+
+   my $b = new Pod_Button() ;
+   $b->StartCallbackLoop() ;
+
+   sub button_pressed {
+      print("click!\n") ; # prints click!
+      $b->StopCallbackLoop() ;
+   }
+
+=for comment
+
+The StartCallbackLoop method can be called on any InlineJavaPerlCaller object
+and will block the current thread and allow the reception of callbacks through
+any InlineJavaPerlCaller that has been created by the same (current) thread.
+The only way to interrupt such a StartCallbackLoop method is to call the
+StopCallbackLoop method on any InlineJavaPerlCaller object that has been created
+by that same thread.
+
+Also, only threads that communicate with Perl through C<Inline::Java> are allowed
+to create InlineJavaPerlCaller objects and invoke their StartCallbackLoop /
+StopCallbackLoop methods.
+   Z<>
+
+
 =head1 STUDYING
 
 As of version 0.21, C<Inline::Java> can learn about other Java classes
diff --git a/Java/JNI.xs b/Java/JNI.xs
index 2798faa..80701a9 100644
--- a/Java/JNI.xs
+++ b/Java/JNI.xs
@@ -109,31 +109,6 @@ jstring JNICALL jni_callback(JNIEnv *env, jobject obj, jstring cmd){
 }
 
 
-/* This function loads up a Perl Interpreter */
-static PerlInterpreter *my_perl ;
-JNIEXPORT void JNICALL Java_org_perl_inline_java_InlineJavaPerlInterpreter_jni_1load_1perl_1interpreter(JNIEnv *env, jobject obj){
-	JNINativeMethod nm ;
-	jclass ijs_class ;
-	char *embedding[] = { "", "-e", "0" } ;
-
-    /* Register the callback function */
-	ijs_class = (*(env))->FindClass(env, "org/perl/inline/java/InlineJavaServer") ;
-	check_exception(env, "Can't find class InlineJavaServer") ;
-
-    nm.name = "jni_callback" ;
-    nm.signature = "(Ljava/lang/String;)Ljava/lang/String;" ;
-    nm.fnPtr = jni_callback ;
-    (*(env))->RegisterNatives(env, ijs_class, &nm, 1) ;
-    check_exception(env, "Can't register method jni_callback in class InlineJavaServer") ;
-
-	my_perl = perl_alloc() ;
-	perl_construct(my_perl) ;
-                                                                                             
-	perl_parse(my_perl, NULL, 3, embedding, NULL) ;
-	perl_run(my_perl) ;
-}
-
-
 
 MODULE = Inline::Java::JNI   PACKAGE = Inline::Java::JNI
 
diff --git a/Java/JVM.pm b/Java/JVM.pm
index 378f435..8dba017 100644
--- a/Java/JVM.pm
+++ b/Java/JVM.pm
@@ -107,7 +107,8 @@ sub new {
 			"java" . Inline::Java::portable("EXE_EXTENSION")) ;
 
 		my $shared = ($this->{shared} ? "true" : "false") ;
-		my $cmd = Inline::Java::portable("SUB_FIX_CMD_QUOTES", "\"$java\" $args org.perl.inline.java.InlineJavaServer $debug $this->{port} $shared") ;
+		my $priv = ($this->{private} ? "true" : "false") ;
+		my $cmd = Inline::Java::portable("SUB_FIX_CMD_QUOTES", "\"$java\" $args org.perl.inline.java.InlineJavaServer $debug $this->{port} $shared $priv") ;
 		Inline::Java::debug(2, $cmd) ;
 		if ($o->get_config('UNTAINT')){
 			($cmd) = $cmd =~ /(.*)/ ;
@@ -289,8 +290,6 @@ sub setup_socket {
 	}
 
 	$socket->autoflush(1) ;
-
-	print $socket (($this->{private} ? "private" : "public") . "\n") ;
 	
 	return $socket ;
 }
diff --git a/Java/sources/InlineJavaServer.java b/Java/sources/InlineJavaServer.java
index c68ac26..0ed1829 100644
--- a/Java/sources/InlineJavaServer.java
+++ b/Java/sources/InlineJavaServer.java
@@ -13,6 +13,7 @@ public class InlineJavaServer {
 	private static InlineJavaServer instance = null ;
 	private int port = 0 ;
 	private boolean shared_jvm = false ;
+	private boolean priv = false ;
 
 	private InlineJavaUserClassLoader ijucl = null ;
 	private HashMap thread_objects = new HashMap() ;
@@ -38,6 +39,7 @@ public class InlineJavaServer {
 		jni = false ;
 		port = Integer.parseInt(argv[1]) ;
 		shared_jvm = new Boolean(argv[2]).booleanValue() ;
+		priv = new Boolean(argv[3]).booleanValue() ;
 
 		ServerSocket ss = null ;
 		try {
@@ -51,7 +53,8 @@ public class InlineJavaServer {
 		while (true){
 			try {
 				String name = "IJST-#" + thread_count++ ;
-				InlineJavaServerThread ijt = new InlineJavaServerThread(name, this, ss.accept(), ijucl) ;
+				InlineJavaServerThread ijt = new InlineJavaServerThread(name, this, ss.accept(),
+					(priv ? new InlineJavaUserClassLoader() : ijucl)) ;
 				ijt.start() ;
 				if (! shared_jvm){
 					try {
diff --git a/Java/sources/InlineJavaServerThread.java b/Java/sources/InlineJavaServerThread.java
index 74e54ca..7c0248f 100644
--- a/Java/sources/InlineJavaServerThread.java
+++ b/Java/sources/InlineJavaServerThread.java
@@ -23,11 +23,6 @@ class InlineJavaServerThread extends Thread {
 			new InputStreamReader(client.getInputStream())) ;
 		bw = new BufferedWriter(
 			new OutputStreamWriter(client.getOutputStream())) ;
-
-		String security_type = br.readLine() ;
-		if (security_type.equals("private")){
-			ijucl = new InlineJavaUserClassLoader() ;
-		}
 	}
 
 
diff --git a/README b/README
index 2e0b792..1a5ff6e 100644
--- a/README
+++ b/README
@@ -71,9 +71,9 @@ WARNING: THIS IS ALPHA SOFTWARE. It is incomplete and possibly unreliable.
          change in future releases.
 
 Inline::Java version 0.44 is a major upgrade that includes:
-+ Fixed memory leak in JNI coded (patch submitted by Dave Blob)
-+ Fixed STUDY that was sometimes not studying (.jdat issue)
 + Callbacks from multiple threads are now supported.
++ Refactored (again...) studying/.jdat/cache stuff
++ Fixed memory leak in JNI coded (patch submitted by Dave Blob)
 
 Inline::Java version 0.43 is a minor upgrade that includes:
 + Restored $VERSION in each .pm file

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