From 8fedd07a679ae495b75abb62eb6b1d29808710e3 Mon Sep 17 00:00:00 2001 From: pancake Date: Sun, 8 Dec 2024 19:10:53 +0100 Subject: [PATCH] Add pom.xml and fix deprecation issues --- java/Makefile | 12 ++++-- java/jni/Makefile | 2 +- java/pom.xml | 40 +++++++++++++++++++ .../main/java}/org/radare/r2pipe/R2Pipe.java | 8 +++- .../java}/org/radare/r2pipe/R2PipeJNI.java | 2 + 5 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 java/pom.xml rename java/{ => src/main/java}/org/radare/r2pipe/R2Pipe.java (93%) rename java/{ => src/main/java}/org/radare/r2pipe/R2PipeJNI.java (99%) diff --git a/java/Makefile b/java/Makefile index 9fbc7fc..8d5eb05 100644 --- a/java/Makefile +++ b/java/Makefile @@ -1,12 +1,18 @@ JARPATH=$(shell pwd) +JAVASRC=src/main/java/org/radare/r2pipe +JAVAC?=javac include config.mk all: - javac $(JAVACFLAGS) org/radare/r2pipe/*.java examples/Test.java - jar cvf r2pipe.jar org - $(MAKE) -C jni + $(JAVAC) $(JAVACFLAGS) $(JAVASRC)/*.java examples/Test.java + cd src/main/java && jar cvf ../../../r2pipe.jar org +# $(MAKE) -C jni $(MAKE) -C examples +maven: + mvn clean compile + mvn install + run: $(MAKE) -C examples run diff --git a/java/jni/Makefile b/java/jni/Makefile index 13c8733..b50732d 100644 --- a/java/jni/Makefile +++ b/java/jni/Makefile @@ -7,7 +7,7 @@ JNIFLAGS+=-I /System/Library/Frameworks/JavaVM.framework/Headers/ all: $(JVH) $(CC) -o $(OUT) -dynamiclib -fPIC $(JNIFLAGS) r2pipe-jni.c -framework JavaVM -$(JVH): ../org/radare/r2pipe/R2PipeJNI.class +$(JVH): ../src/main/java/org/radare/r2pipe/R2PipeJNI.class javah -cp ../r2pipe.jar -d . org.radare.r2pipe.R2PipeJNI clean: diff --git a/java/pom.xml b/java/pom.xml new file mode 100644 index 0000000..bdcfdbc --- /dev/null +++ b/java/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + + + org.radare + r2pipe + 1.0.0 + jar + + + + javax.json + javax.json-api + 1.1.4 + + + org.glassfish + javax.json + 1.1.4 + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + 11 + 11 + + + + + diff --git a/java/org/radare/r2pipe/R2Pipe.java b/java/src/main/java/org/radare/r2pipe/R2Pipe.java similarity index 93% rename from java/org/radare/r2pipe/R2Pipe.java rename to java/src/main/java/org/radare/r2pipe/R2Pipe.java index 2e48b18..2e50845 100644 --- a/java/org/radare/r2pipe/R2Pipe.java +++ b/java/src/main/java/org/radare/r2pipe/R2Pipe.java @@ -4,7 +4,11 @@ import java.net.*; // java7 -import javax.json.*; +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; +// import jakarta.json.Json; +// import jakarta.json.JsonObject; public class R2Pipe { private boolean viaHttp; @@ -90,9 +94,11 @@ public String httpCmd(String str) { return output; } + /* protected void finalize() throws Throwable { quit(); } + */ public void quit() throws Exception { if (!viaHttp) { diff --git a/java/org/radare/r2pipe/R2PipeJNI.java b/java/src/main/java/org/radare/r2pipe/R2PipeJNI.java similarity index 99% rename from java/org/radare/r2pipe/R2PipeJNI.java rename to java/src/main/java/org/radare/r2pipe/R2PipeJNI.java index 413fe3e..fc4491b 100644 --- a/java/org/radare/r2pipe/R2PipeJNI.java +++ b/java/src/main/java/org/radare/r2pipe/R2PipeJNI.java @@ -34,9 +34,11 @@ public String cmd(String str) throws Exception { return r2pipeCmd(this.core, str); } + /* protected void finalize() throws Throwable { quit(); } + */ public void quit() throws Exception { r2pipeFree(this.core);