jad command better support unicode. #1169

pull/1182/head
hengyunabc 5 years ago
parent 3204c0ad36
commit 4a950140dc

@ -56,6 +56,7 @@ public class JadCommand extends AnnotatedCommand {
private String methodName;
private String code = null;
private boolean isRegEx = false;
private boolean hideUnicode = false;
/**
* jad output source code only
@ -87,6 +88,12 @@ public class JadCommand extends AnnotatedCommand {
isRegEx = regEx;
}
@Option(longName = "hideUnicode", flag = true)
@Description("hide unicode, default value false")
public void setHideUnicode(boolean hideUnicode) {
this.hideUnicode = hideUnicode;
}
@Option(longName = "source-only", flag = true)
@Description("Output source code only")
public void setSourceOnly(boolean sourceOnly) {
@ -153,7 +160,7 @@ public class JadCommand extends AnnotatedCommand {
Map<Class<?>, File> classFiles = transformer.getDumpResult();
File classFile = classFiles.get(c);
String source = Decompiler.decompile(classFile.getAbsolutePath(), methodName);
String source = Decompiler.decompile(classFile.getAbsolutePath(), methodName, hideUnicode);
if (source != null) {
source = pattern.matcher(source).replaceAll("");
} else {

@ -16,12 +16,17 @@ import org.benf.cfr.reader.api.OutputSinkFactory;
*/
public class Decompiler {
public static String decompile(String classFilePath, String methodName) {
return decompile(classFilePath, methodName, false);
}
/**
* @param classFilePath
* @param methodName
* @param hideUnicode
* @return
*/
public static String decompile(String classFilePath, String methodName) {
public static String decompile(String classFilePath, String methodName, boolean hideUnicode) {
final StringBuilder result = new StringBuilder(8192);
OutputSinkFactory mySink = new OutputSinkFactory() {
@ -52,6 +57,7 @@ public class Decompiler {
* the cfr version is wrong. so disable show cfr version.
*/
options.put("showversion", "false");
options.put("hideutf", String.valueOf(hideUnicode));
if (!StringUtils.isBlank(methodName)) {
options.put("methodname", methodName);
}

Loading…
Cancel
Save