Skip to content

Commit

Permalink
gui: fix build for java 10 and update dependencies (skylot#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jun 2, 2018
1 parent 188bfd1 commit 7b4321e
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 66 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ build/
classes/
idea/
.gradle/
gradle.properties

jadx-output/
*-tmp/
Expand Down
64 changes: 37 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
language: java
jdk:
- oraclejdk8
sudo: false
dist: trusty

before_install:
- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh
- chmod +x gradlew

env:
- TERM=dumb GRADLE_OPTS="-Dorg.gradle.daemon=false"
global:
- TERM=dumb

before_install:
- chmod +x gradlew
matrix:
include:
- env: JDK=oracle-8
jdk: oraclejdk8
- env: JDK=oracle-10
install: . ./install-jdk.sh -F 10 -L BCL

script:
- sed -i " 1 s/.*/&-b$TRAVIS_BUILD_NUMBER-$(git rev-parse --short HEAD)/" version
- cat version
- sed -i "s/BUILD_VERSION/$(head -c -1 version)/g" bintray.json
- ./gradlew clean build
- java -version
- sed -i " 1 s/.*/&-b$TRAVIS_BUILD_NUMBER-$(git rev-parse --short HEAD)/" version
- cat version
- sed -i "s/BUILD_VERSION/$(head -c -1 version)/g" bintray.json
- ./gradlew clean build

after_success:
- ./gradlew clean build jacocoTestReport
- bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
- ./gradlew clean sonarqube -Dsonar.host.url=$SONAR_HOST -Dsonar.organization=$SONAR_ORG -Dsonar.login=$SONAR_TOKEN
- ./gradlew clean dist
- test $JDK = "oracle-8" && ./gradlew clean build jacocoTestReport && bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
- test $JDK = "oracle-8" && ./gradlew clean sonarqube -Dsonar.host.url=$SONAR_HOST -Dsonar.organization=$SONAR_ORG -Dsonar.login=$SONAR_TOKEN || echo "Skip sonar build and upload"

deploy:
provider: bintray
edge:
branch: v1.8.47
file: bintray.json
user: skylot
key: $BINTRAY_KEY
skip_cleanup: true
on:
branch: master
tags: false
before_deploy:
- ./gradlew clean dist

sudo: false
deploy:
provider: bintray
edge:
branch: v1.8.47
file: bintray.json
user: skylot
key: $BINTRAY_KEY
skip_cleanup: true
on:
branch: master
tags: false
condition: $JDK = oracle-8

notifications:
email:
- [email protected]
email:
- [email protected]
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ allprojects {
testCompile 'ch.qos.logback:logback-classic:1.2.3'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.mockito:mockito-core:2.15.0'
testCompile 'org.mockito:mockito-core:2.18.3'
testCompile 'org.spockframework:spock-core:1.1-groovy-2.4'
testCompile 'cglib:cglib-nodep:3.2.6'
}
Expand All @@ -53,7 +53,7 @@ allprojects {
}

jacoco {
toolVersion = "0.8.0"
toolVersion = "0.8.1"
}
jacocoTestReport {
reports {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.daemon=false
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
2 changes: 1 addition & 1 deletion jadx-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ applicationName = 'jadx'

dependencies {
compile(project(':jadx-core'))
compile 'com.beust:jcommander:1.72'
compile 'com.beust:jcommander:1.74'
compile 'ch.qos.logback:logback-classic:1.2.3'
}

Expand Down
10 changes: 5 additions & 5 deletions jadx-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ dependencies {

compile files('lib/dx-1.14.jar')
compile 'commons-io:commons-io:2.6'
compile 'org.ow2.asm:asm:6.0'
compile 'org.jetbrains:annotations:15.0'
compile 'uk.com.robust-it:cloning:1.9.9'
compile 'org.ow2.asm:asm:6.2'
compile 'org.jetbrains:annotations:16.0.2'
compile 'uk.com.robust-it:cloning:1.9.10'

testCompile 'org.smali:smali:2.2.2'
testCompile 'org.smali:baksmali:2.2.2'
testCompile 'org.smali:smali:2.2.3'
testCompile 'org.smali:baksmali:2.2.3'

testCompile 'org.apache.commons:commons-lang3:3.7'
}
Expand Down
18 changes: 9 additions & 9 deletions jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,9 @@ private static void processAnonymousConstructor(MethodNode mth, ConstructorInsn
|| !parentClass.getInnerClasses().contains(classNode)) {
return;
}
if (!classNode.getAccessFlags().isStatic()
&& (callMth.getArgsCount() == 0
|| !callMth.getArgumentsTypes().get(0).equals(parentClass.getClassInfo().getType()))) {
return;
}
// TODO: calculate this constructor and other constructor usage
Map<InsnArg, FieldNode> argsMap = getArgsToFieldsMapping(callMthNode, co);
if (argsMap.isEmpty()) {
if (argsMap.isEmpty() && !callMthNode.getArguments(true).isEmpty()) {
return;
}

Expand Down Expand Up @@ -285,9 +280,14 @@ private static void processAnonymousConstructor(MethodNode mth, ConstructorInsn

private static Map<InsnArg, FieldNode> getArgsToFieldsMapping(MethodNode callMthNode, ConstructorInsn co) {
Map<InsnArg, FieldNode> map = new LinkedHashMap<>();
ClassNode parentClass = callMthNode.getParentClass();
MethodInfo callMth = callMthNode.getMethodInfo();
ClassNode cls = callMthNode.getParentClass();
ClassNode parentClass = cls.getParentClass();
List<RegisterArg> argList = callMthNode.getArguments(false);
int startArg = parentClass.getAccessFlags().isStatic() ? 0 : 1;
int startArg = 0;
if (callMth.getArgsCount() != 0 && callMth.getArgumentsTypes().get(0).equals(parentClass.getClassInfo().getType())) {
startArg = 1;
}
int argsCount = argList.size();
for (int i = startArg; i < argsCount; i++) {
RegisterArg arg = argList.get(i);
Expand All @@ -298,7 +298,7 @@ private static Map<InsnArg, FieldNode> getArgsToFieldsMapping(MethodNode callMth
FieldNode fieldNode = null;
if (useInsn.getType() == InsnType.IPUT) {
FieldInfo field = (FieldInfo) ((IndexInsnNode) useInsn).getIndex();
fieldNode = parentClass.searchField(field);
fieldNode = cls.searchField(field);
if (fieldNode == null || !fieldNode.getAccessFlags().isSynthetic()) {
return Collections.emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ private static InsnNode convertInvoke(MethodNode mth, InsnNode insn) {
} // end of if constructor is for StringBuilder
} // end of if we found a constructor early in the chain

} catch (Throwable e) {
LOG.debug("Can't convert string concatenation: {} insn: {}", mth, insn, e);
} catch (Exception e) {
LOG.warn("Can't convert string concatenation: {} insn: {}", mth, insn, e);
}
}
return null;
Expand Down
2 changes: 2 additions & 0 deletions jadx-core/src/main/java/jadx/core/utils/DebugUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.Set;

import org.jetbrains.annotations.TestOnly;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -32,6 +33,7 @@
import jadx.core.utils.exceptions.JadxRuntimeException;

@Deprecated
@TestOnly
public class DebugUtils {
private static final Logger LOG = LoggerFactory.getLogger(DebugUtils.class);

Expand Down
11 changes: 5 additions & 6 deletions jadx-gui/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'edu.sc.seis.launch4j' version '2.4.3'
id 'com.github.johnrengelman.shadow' version '2.0.2'
id 'edu.sc.seis.launch4j' version '2.4.4'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}

apply plugin: 'application'
Expand All @@ -11,14 +11,14 @@ dependencies {
compile(project(":jadx-core"))
compile(project(":jadx-cli"))
compile 'com.fifesoft:rsyntaxtextarea:2.6.1'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.google.code.gson:gson:2.8.5'
compile files('libs/jfontchooser-1.0.5.jar')
compile 'hu.kazocsaba:image-viewer:1.2.3'

compile 'org.apache.commons:commons-lang3:3.7'

compile 'io.reactivex.rxjava2:rxjava:2.1.13'
compile "com.github.akarnokd:rxjava2-swing:0.2.12"
compile 'io.reactivex.rxjava2:rxjava:2.1.14'
compile "com.github.akarnokd:rxjava2-swing:0.2.13"
}

applicationDistribution.with {
Expand Down Expand Up @@ -63,7 +63,6 @@ launch4j {
initialHeapPercent = 5
maxHeapSize = 4096
maxHeapPercent = 70

}

test {
Expand Down
2 changes: 1 addition & 1 deletion jadx-gui/src/main/java/jadx/gui/ui/CodePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CodePanel extends ContentPanel {
add(searchBar, BorderLayout.NORTH);
add(scrollPane);

KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK);
KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK);
Utils.addKeyBinding(codeArea, key, "SearchAction", new SearchAction());
}

Expand Down
16 changes: 5 additions & 11 deletions jadx-gui/src/main/java/jadx/gui/utils/TextStandardActions.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package jadx.gui.utils;

import javax.swing.*;
import javax.swing.event.UndoableEditEvent;
import javax.swing.event.UndoableEditListener;
import javax.swing.text.JTextComponent;
import javax.swing.undo.UndoManager;
import java.awt.*;
Expand Down Expand Up @@ -102,26 +100,22 @@ void addPopupItems() {
}

private void addKeyActions() {
KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK);
KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK);
textComponent.getInputMap().put(undoKey, undoAction);
KeyStroke redoKey = KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_MASK);
KeyStroke redoKey = KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK);
textComponent.getInputMap().put(redoKey, redoAction);
}

private void registerListeners() {
textComponent.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.getModifiers() == InputEvent.BUTTON3_MASK
&& e.getSource() == textComponent) {
if (e.getButton() == 3 && e.getSource() == textComponent) {
process(e);
}
}
});
textComponent.getDocument().addUndoableEditListener(new UndoableEditListener() {
public void undoableEditHappened(UndoableEditEvent event) {
undoManager.addEdit(event.getEdit());
}
});
textComponent.getDocument().addUndoableEditListener(event -> undoManager.addEdit(event.getEdit()));
}

private void process(MouseEvent e) {
Expand Down

0 comments on commit 7b4321e

Please sign in to comment.