Added subpackage built by jdk8 to allow looking into jdk8 apps

- for some reason, jdk8 vm can not look into jdk11 vm, even if agent is correctly jdk8 version
- the config is still share, which is stupid, but I doubt there is another target audeince then me
This commit is contained in:
Jiri 2020-12-08 18:54:53 +01:00
commit 628b22e7d5
3 changed files with 241 additions and 10 deletions

View file

@ -1,13 +1,15 @@
Summary: Application for extraction and decompilation of JVM byte code
Name: java-runtime-decompiler
Version: 4.0
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv3
URL: https://github.com/pmikova/java-runtime-decompiler
Source0: https://github.com/pmikova/%{name}/archive/%{name}-%{version}.tar.gz
Source1: java-runtime-decompiler
Source2: java-runtime-decompiler.1
Source3: jrd.desktop
Source4: java-runtime-decompiler8
Patch0: remove_rsyntaxtextarea.patch
Patch1: systemFernflower.patch
Patch2: systemProcyon.patch
Patch3: rsyntaxVersion.patch
@ -23,8 +25,10 @@ BuildRequires: maven-surefire-provider-junit
BuildRequires: maven-surefire-provider-junit5
BuildRequires: maven-surefire
BuildRequires: maven-surefire-plugin
# depends on devel, not runtime (needs tools.jar)
BuildRequires: maven-clean-plugin
# depends on devel, not runtime (needs tools.jar, javap attach and manyn others)
BuildRequires: java-11-devel
BuildRequires: java-1.8.0-devel
BuildRequires: google-gson
BuildRequires: desktop-file-utils
Requires: java-11-devel
@ -34,28 +38,50 @@ Recommends: procyon-decompiler
%description
This application can access JVM memory at runtime,
extract byte code from the JVM and decompile it.
%package javadoc
Summary: Javadoc for %{name}
Requires: %{name} = %{version}-%{release}
%description javadoc
This package contains the API documentation for %{name}.
%package jdk8
Summary: jdk8 comaptible version of %{name}, may miss sme features
Requires: java-1.8.0-devel
Recommends: fernflower
Recommends: procyon-decompiler
%description jdk8
jdk8 comaptible version of %{name}, may miss sme features.
Eg rich text area is missng or the agent need to be adjusted manually
%prep
%setup -q -n %{name}-%{name}-%{version}
%patch0 -p1
%patch1 -p0
%patch2 -p0
%patch3 -p0
%build
pushd runtime-decompiler
# not manipuling com.sun:tools in jdk11 phases
#%%pom_remove_dep com.sun:tools
#%%pom_add_dep com.sun:tools
%pom_remove_plugin :maven-jar-plugin
popd
# seting up build jdk, as most likely we will build separate binary by jdk8
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
pushd runtime-decompiler
%pom_add_dep com.sun:tools
popd
%mvn_build --xmvn-javadoc --skip-javadoc --skip-install -- -Plegacy
find | grep .jar$
mv -v ./decompiler_agent/target/decompiler-agent-%{version}.0-SNAPSHOT.jar ../decompiler-agent8.jarx #to avoid being mvn installed
mv -v ./runtime-decompiler/target/runtime-decompiler-%{version}.0-SNAPSHOT.jar ../runtime-decompiler8.jarx #to avoid being mvn installed
xmvn clean
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
patch -p1 -R < %{PATCH0}
patch -p0 < %{PATCH3}
pushd runtime-decompiler
%pom_remove_dep com.sun:tools
popd
%mvn_build --xmvn-javadoc
%install
@ -65,6 +91,7 @@ install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man1/
install -d -m 755 $RPM_BUILD_ROOT%{_bindir}
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/
install -m 755 %{SOURCE4} $RPM_BUILD_ROOT%{_bindir}/
install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/
cp -r %{_builddir}/%{name}-%{name}-%{version}/runtime-decompiler/src/plugins/ $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/
@ -72,11 +99,15 @@ install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/applications
desktop-file-install --vendor="fedora" \
--dir=${RPM_BUILD_ROOT}%{_datadir}/applications %{SOURCE3}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/java/%{name}-jdk8
cp -v %{_builddir}/decompiler-agent8.jarx $RPM_BUILD_ROOT%{_datadir}/java/%{name}-jdk8/decompiler-agent8.jar
cp -v %{_builddir}/runtime-decompiler8.jarx $RPM_BUILD_ROOT%{_datadir}/java/%{name}-jdk8/runtime-decompiler8.jar
%files -f .mfiles
%attr(755, root, -) %{_bindir}/java-runtime-decompiler
%{_mandir}/man1/java-runtime-decompiler.1*
# wrappers for decompilers
# wrappers for decompilers shared with jdk8 subpackage
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/plugins
%config %{_sysconfdir}/%{name}/plugins/FernflowerDecompilerWrapper.java
@ -91,7 +122,26 @@ desktop-file-install --vendor="fedora" \
%files javadoc -f .mfiles-javadoc
%license LICENSE
%files jdk8
%attr(755, root, -) %{_bindir}/java-runtime-decompiler8
%dir %{_datadir}/java/%{name}-jdk8
%{_datadir}/java/%{name}-jdk8/runtime-decompiler8.jar
%{_datadir}/java/%{name}-jdk8/decompiler-agent8.jar
# wrappers for decompilers shared with main
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/plugins
%config %{_sysconfdir}/%{name}/plugins/FernflowerDecompilerWrapper.java
%config(noreplace) %{_sysconfdir}/%{name}/plugins/FernflowerDecompilerWrapper.json
%config %{_sysconfdir}/%{name}/plugins/ProcyonDecompilerWrapper.java
%config(noreplace) %{_sysconfdir}/%{name}/plugins/ProcyonDecompilerWrapper.json
%license LICENSE
%changelog
* Tue Dec 08 2020 Jiri Vanek <jvanek@redhat.com> - 4.0-2
- Added subpackage built by jdk8 to allow looking into jdk8 apps
- for some reason, jdk8 vm can not look into jdk11 vm, even if agent is correctly jdk8 version
- the config is still share, which is stupid, but I doubt there is another target audeince then me
* Tue Dec 08 2020 Jiri Vanek <jvanek@redhat.com> - 4.0-1
- built by jdk11

94
java-runtime-decompiler8 Normal file
View file

@ -0,0 +1,94 @@
#!/usr/bin/bash
# java runtime decompiler launch script
# JPackage Project <http://www.jpackage.org/>
# Source functions library
echo "Special jdk8 build of JRD. "
echo "You will most likely set agent manually to java-runtime-decompiler-jdk8/decompiler-agent8.jar"
echo "Normal, jdk11 JRD should be able to reuse jdk8 agent, but not the oposite"
echo "No one can guarantee the bytecode level of decompilers. You may need to download older versions from somewhere"
if [ "x$JAVA_HOME" = "x" ] ; then
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
fi
. /usr/share/java-utils/java-functions
# identify directory tree
JRD=`java-runtime-decompiler`
CONF_HOME=$XDG_CONFIG_HOME
if [ "$CONF_HOME" = "" ] ; then
CONF_HOME=$HOME/.config/$JRD
else
CONF_HOME=$CONF_HOME/$JRD
fi
LOG_DIR=$CONF_HOME/logs
CONF_DIR=$CONF_HOME/conf
# create directory tree
PLUGIN_HOME=$CONF_HOME/plugins
mkdir -p $LOG_DIR
mkdir -p $CONF_DIR
mkdir -p $PLUGIN_HOME
: ${MAIN_CLASS:=org.jrd.backend.data.Main}
# set java and jvm arguments
export _prefer_jre=false
_set_java_home
set_jvm
# all dependencies must be on classpath
set_classpath byteman google-gson
CLASSPATH=$CLASSPATH:${JAVA_HOME}/lib/tools.jar:/usr/share/java/java-runtime-decompiler-jdk8/runtime-decompiler8.jar:/usr/share/java/java-runtime-decompiler-jdk8/decompiler-agent8.jar
# set path to agent automatically
AGENT="/usr/share/java/java-runtime-decompiler/decompiler-agent8.jar"
CONFIG_FILE=$CONF_DIR/config.cfg
AGENT_PREFIX="AGENT_PATH==="
AGENT_STRING=$AGENT_PREFIX$AGENT
# copy json wrappers information to home so the users can edit
CP_FILES="$(ls /etc/$JRD/plugins/*.json)"
for cpfile in $CP_FILES; do
FILE_NAME="$(basename -- $cpfile)"
if [ ! -e "$PLUGIN_HOME/$FILE_NAME" ]
then
cp $cpfile $PLUGIN_HOME
else
echo "Configuration files were not copied for $FILE_NAME - the existing configuration would be overwritten." >&2
fi
done
# create config file and add agent default path
touch $CONFIG_FILE
if [ -e $AGENT ]
then
if grep -Fxq $AGENT_STRING $CONFIG_FILE
then
echo "Default agent path is already set in $CONFIG_FILE. Skipping agent path setting." >&2
elif grep -rq $AGENT_PREFIX $CONFIG_FILE
then
RESULT_OF_GREP="$(grep -rq $AGENT_PREFIX $CONFIG_FILE)"
echo "Agent path is already set in $CONFIG_FILE as ${RESULT_OF_GREP}. Skipping agent path setting." >&2
else
echo $AGENT_STRING >> $CONFIG_FILE
fi
else
echo "Agent was not found and agent path was not set correctly. This has to be done manually in the decompiler GUI, or set AGENT_PATH===path_to_agent_jar in the configuration file: $CONFIG_FILE" >&2
fi
export FLAGS="$FLAGS -Djdk.attach.allowAttachSelf=true"
run "$@"

View file

@ -0,0 +1,87 @@
diff --git a/runtime-decompiler/pom.xml b/runtime-decompiler/pom.xml
index 26a416e..e6e2425 100644
--- a/runtime-decompiler/pom.xml
+++ b/runtime-decompiler/pom.xml
@@ -135,11 +135,6 @@
<artifactId>directories</artifactId>
<version>10</version>
</dependency>-->
- <dependency>
- <groupId>com.fifesoft</groupId>
- <artifactId>rsyntaxtextarea</artifactId>
- <version>2.6.1</version>
- </dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-install</artifactId>
diff --git a/runtime-decompiler/src/main/java/org/jrd/frontend/BytecodeDecompilerView.java b/runtime-decompiler/src/main/java/org/jrd/frontend/BytecodeDecompilerView.java
index 9c19e2c..8d17775 100644
--- a/runtime-decompiler/src/main/java/org/jrd/frontend/MainFrame/BytecodeDecompilerView.java
+++ b/runtime-decompiler/src/main/java/org/jrd/frontend/MainFrame/BytecodeDecompilerView.java
@@ -1,11 +1,11 @@
package org.jrd.frontend.MainFrame;
-import org.fife.ui.rsyntaxtextarea.*;
-import org.fife.ui.rtextarea.SearchContext;
-import org.fife.ui.rtextarea.SearchEngine;
+//import org.fife.ui.rsyntaxtextarea.*;
+//import org.fife.ui.rtextarea.SearchContext;
+//import org.fife.ui.rtextarea.SearchEngine;
import org.jrd.backend.core.OutputController;
import org.jrd.backend.decompiling.DecompilerWrapperInformation;
-import org.fife.ui.rtextarea.RTextScrollPane;
+//import org.fife.ui.rtextarea.RTextScrollPane;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
@@ -30,8 +30,8 @@ public class BytecodeDecompilerView {
private JPanel rightMainPanel;
private JScrollPane leftScrollPanel;
private JList<String> filteredClassesJlist;
- private RTextScrollPane bytecodeScrollPane;
- private RSyntaxTextArea bytecodeSyntaxTextArea;
+ private JScrollPane bytecodeScrollPane;
+ private JTextArea bytecodeSyntaxTextArea;
private ActionListener bytesActionListener;
private ActionListener classesActionListener;
private ActionListener rewriteActionListener;
@@ -147,10 +147,10 @@ public class BytecodeDecompilerView {
}
});
- bytecodeSyntaxTextArea = new RSyntaxTextArea();
- bytecodeSyntaxTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
- bytecodeSyntaxTextArea.setCodeFoldingEnabled(true);
- bytecodeScrollPane = new RTextScrollPane(bytecodeSyntaxTextArea);
+ bytecodeSyntaxTextArea = new JTextArea();
+ //bytecodeSyntaxTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
+ //bytecodeSyntaxTextArea.setCodeFoldingEnabled(true);
+ bytecodeScrollPane = new JScrollPane(bytecodeSyntaxTextArea);
leftMainPanel = new JPanel();
leftMainPanel.setLayout(new BorderLayout());
@@ -297,14 +297,14 @@
Search string in decompiled code
*/
private void searchCode() {
- SearchContext context = new SearchContext();
- String match = searchCodeField.getText();
- context.setSearchFor(match);
- context.setWholeWord(false);
- SearchEngine.markAll(bytecodeSyntaxTextArea, context);
- int line = SearchEngine.getNextMatchPos(match, bytecodeSyntaxTextArea.getText(), true, true, false);
- if(line >= 0) {
- bytecodeSyntaxTextArea.setCaretPosition(line);
- }
+ //SearchContext context = new SearchContext();
+ //String match = searchCodeField.getText();
+ //context.setSearchFor(match);
+ //context.setWholeWord(false);
+ //SearchEngine.markAll(bytecodeSyntaxTextArea, context);
+ //int line = SearchEngine.getNextMatchPos(match, bytecodeSyntaxTextArea.getText(), true, true, false);
+ //if(line >= 0) {
+ //bytecodeSyntaxTextArea.setCaretPosition(line);
+ //}
}
}