[libinline-java-perl] 45/398: chaged stuff around a bit in order to make the methods callable later with JNI
Jonas Smedegaard
dr at jones.dk
Thu Feb 26 11:42:43 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 e5a92d0c9c72e4d9a13da2392b47d8a7787948be
Author: patrick <>
Date: Tue Mar 27 20:27:26 2001 +0000
chaged stuff around a bit in order to make the methods callable later with JNI
---
Java/Init.pm | 102 +++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 68 insertions(+), 34 deletions(-)
diff --git a/Java/Init.pm b/Java/Init.pm
index 686ea3f..944c4fc 100644
--- a/Java/Init.pm
+++ b/Java/Init.pm
@@ -57,6 +57,13 @@ public class InlineJavaServer {
public HashMap objects = new HashMap() ;
public int objid = 1 ;
+ // This constructor is used in JNI mode
+ InlineJavaServer(boolean d) {
+ debug = d ;
+ }
+
+
+ // This constructor is used in server mode
InlineJavaServer(String[] argv) {
String mode = argv[0] ;
debug = new Boolean(argv[1]).booleanValue() ;
@@ -78,26 +85,10 @@ public class InlineJavaServer {
while (true){
String cmd = br.readLine() ;
- debug(" packet recv is " + cmd) ;
-
- if (cmd != null){
- InlineJavaProtocol ijp = new InlineJavaProtocol(this, cmd) ;
- try {
- ijp.Do() ;
- debug(" packet sent is " + ijp.response) ;
- bw.write(ijp.response + "\n") ;
- bw.flush() ;
- }
- catch (InlineJavaException e){
- String err = "error scalar:" + ijp.unpack(e.getMessage()) ;
- debug(" packet sent is " + err) ;
- bw.write(err + "\n") ;
- bw.flush() ;
- }
- }
- else{
- System.exit(1) ;
- }
+
+ String resp = ProcessCommand(cmd) ;
+ bw.write(resp) ;
+ bw.flush() ;
}
}
catch (IOException e){
@@ -112,6 +103,31 @@ public class InlineJavaServer {
}
+ public String ProcessCommand(String cmd){
+ debug(" packet recv is " + cmd) ;
+
+ String resp = null ;
+ if (cmd != null){
+ InlineJavaProtocol ijp = new InlineJavaProtocol(this, cmd) ;
+ try {
+ ijp.Do() ;
+ debug(" packet sent is " + ijp.response) ;
+ resp = ijp.response + "\n" ;
+ }
+ catch (InlineJavaException e){
+ String err = "error scalar:" + ijp.unpack(e.getMessage()) ;
+ debug(" packet sent is " + err) ;
+ resp = err + "\n" ;
+ }
+ }
+ else{
+ System.exit(1) ;
+ }
+
+ return resp ;
+ }
+
+
/*
Returns a report on the Java classes, listing all public methods
and members
@@ -125,13 +141,28 @@ public class InlineJavaServer {
File dat = new File(module + ".jdat") ;
PrintWriter pw = new PrintWriter(new FileWriter(dat)) ;
+ String data = ProcessReport(class_list, idx) ;
+ pw.print(data) ;
+ pw.close() ;
+ }
+ catch (IOException e){
+ System.err.println("Problems writing to " + module + ".jdat file: " + e.getMessage()) ;
+ System.exit(1) ;
+ }
+ }
+
+
+ String ProcessReport(String [] class_list, int idx){
+ StringBuffer pw = new StringBuffer() ;
+
+ try {
for (int i = idx ; i < class_list.length ; i++){
if (! class_list[i].startsWith("InlineJavaServer")){
StringBuffer name = new StringBuffer(class_list[i]) ;
name.replace(name.length() - 6, name.length(), "") ;
Class c = Class.forName(name.toString()) ;
- pw.println("class " + c.getName()) ;
+ pw.append("class " + c.getName() + "\n") ;
Constructor constructors[] = c.getConstructors() ;
Method methods[] = c.getMethods() ;
Field fields[] = c.getFields() ;
@@ -140,35 +171,31 @@ public class InlineJavaServer {
Constructor x = constructors[j] ;
String sign = CreateSignature(x.getParameterTypes()) ;
Class decl = x.getDeclaringClass() ;
- pw.println("constructor" + " " + sign) ;
+ pw.append("constructor" + " " + sign + "\n") ;
}
for (int j = 0 ; j < methods.length ; j++){
Method x = methods[j] ;
String stat = (Modifier.isStatic(x.getModifiers()) ? " static " : " instance ") ;
String sign = CreateSignature(x.getParameterTypes()) ;
Class decl = x.getDeclaringClass() ;
- pw.println("method" + stat + decl.getName() + " " + x.getName() + sign) ;
+ pw.append("method" + stat + decl.getName() + " " + x.getName() + sign + "\n") ;
}
for (int j = 0 ; j < fields.length ; j++){
Field x = fields[j] ;
String stat = (Modifier.isStatic(x.getModifiers()) ? " static " : " instance ") ;
Class decl = x.getDeclaringClass() ;
Class type = x.getType() ;
- pw.println("field" + stat + decl.getName() + " " + x.getName() + " " + type.getName()) ;
+ pw.append("field" + stat + decl.getName() + " " + x.getName() + " " + type.getName() + "\n") ;
}
}
}
-
- pw.close() ;
- }
- catch (IOException e){
- System.err.println("Problems writing to " + module + ".jdat file: " + e.getMessage()) ;
- System.exit(1) ;
}
catch (ClassNotFoundException e){
System.err.println("Can't find class: " + e.getMessage()) ;
System.exit(1) ;
}
+
+ return pw.toString() ;
}
@@ -188,6 +215,14 @@ public class InlineJavaServer {
}
+ public void debug(String s) {
+ if (debug){
+ System.err.println("java: " + s) ;
+ System.err.flush() ;
+ }
+ }
+
+
/*
Startup
*/
@@ -196,12 +231,11 @@ public class InlineJavaServer {
}
- public void debug(String s) {
- if (debug){
- System.err.println("java: " + s) ;
- }
+ public static InlineJavaServer jni_main(boolean debug) {
+ return new InlineJavaServer(debug) ;
}
+
<INLINE_JAVA_OBJECT>
<INLINE_JAVA_CLASS>
--
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