Cleanup (formatting)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000-2015 JetBrains s.r.o.
|
* Copyright 2000-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -37,48 +37,39 @@ import java.util.*;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class ClassReference14Processor {
|
public class ClassReference14Processor {
|
||||||
|
private static final ExitExprent BODY_EXPR;
|
||||||
public static final ExitExprent bodyexprent;
|
private static final ExitExprent HANDLER_EXPR;
|
||||||
|
|
||||||
public static final ExitExprent handlerexprent;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
InvocationExprent invFor = new InvocationExprent();
|
||||||
|
invFor.setName("forName");
|
||||||
|
invFor.setClassname("java/lang/Class");
|
||||||
|
invFor.setStringDescriptor("(Ljava/lang/String;)Ljava/lang/Class;");
|
||||||
|
invFor.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/String;)Ljava/lang/Class;"));
|
||||||
|
invFor.setStatic(true);
|
||||||
|
invFor.setLstParameters(Collections.singletonList(new VarExprent(0, VarType.VARTYPE_STRING, null)));
|
||||||
|
BODY_EXPR = new ExitExprent(ExitExprent.EXIT_RETURN, invFor, VarType.VARTYPE_CLASS, null);
|
||||||
|
|
||||||
InvocationExprent invfor = new InvocationExprent();
|
InvocationExprent ctor = new InvocationExprent();
|
||||||
invfor.setName("forName");
|
ctor.setName(CodeConstants.INIT_NAME);
|
||||||
invfor.setClassname("java/lang/Class");
|
ctor.setClassname("java/lang/NoClassDefFoundError");
|
||||||
invfor.setStringDescriptor("(Ljava/lang/String;)Ljava/lang/Class;");
|
ctor.setStringDescriptor("()V");
|
||||||
invfor.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/String;)Ljava/lang/Class;"));
|
ctor.setFunctype(InvocationExprent.TYP_INIT);
|
||||||
invfor.setStatic(true);
|
ctor.setDescriptor(MethodDescriptor.parseDescriptor("()V"));
|
||||||
invfor.setLstParameters(Arrays.asList(new Exprent[]{new VarExprent(0, VarType.VARTYPE_STRING, null)}));
|
|
||||||
|
|
||||||
bodyexprent = new ExitExprent(ExitExprent.EXIT_RETURN,
|
NewExprent newExpr = new NewExprent(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/NoClassDefFoundError"), new ArrayList<>(), null);
|
||||||
invfor,
|
newExpr.setConstructor(ctor);
|
||||||
VarType.VARTYPE_CLASS, null);
|
|
||||||
|
|
||||||
InvocationExprent constr = new InvocationExprent();
|
InvocationExprent invCause = new InvocationExprent();
|
||||||
constr.setName(CodeConstants.INIT_NAME);
|
invCause.setName("initCause");
|
||||||
constr.setClassname("java/lang/NoClassDefFoundError");
|
invCause.setClassname("java/lang/NoClassDefFoundError");
|
||||||
constr.setStringDescriptor("()V");
|
invCause.setStringDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
|
||||||
constr.setFunctype(InvocationExprent.TYP_INIT);
|
invCause.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;"));
|
||||||
constr.setDescriptor(MethodDescriptor.parseDescriptor("()V"));
|
invCause.setInstance(newExpr);
|
||||||
|
invCause.setLstParameters(
|
||||||
|
Collections.singletonList(new VarExprent(2, new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"), null)));
|
||||||
|
|
||||||
NewExprent newexpr =
|
HANDLER_EXPR = new ExitExprent(ExitExprent.EXIT_THROW, invCause, null, null);
|
||||||
new NewExprent(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/NoClassDefFoundError"), new ArrayList<>(), null);
|
|
||||||
newexpr.setConstructor(constr);
|
|
||||||
|
|
||||||
InvocationExprent invcause = new InvocationExprent();
|
|
||||||
invcause.setName("initCause");
|
|
||||||
invcause.setClassname("java/lang/NoClassDefFoundError");
|
|
||||||
invcause.setStringDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
|
|
||||||
invcause.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;"));
|
|
||||||
invcause.setInstance(newexpr);
|
|
||||||
invcause.setLstParameters(
|
|
||||||
Arrays.asList(new Exprent[]{new VarExprent(2, new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"), null)}));
|
|
||||||
|
|
||||||
handlerexprent = new ExitExprent(ExitExprent.EXIT_THROW,
|
|
||||||
invcause,
|
|
||||||
null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processClassReferences(ClassNode node) {
|
public static void processClassReferences(ClassNode node) {
|
||||||
@@ -176,8 +167,8 @@ public class ClassReference14Processor {
|
|||||||
BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1);
|
BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1);
|
||||||
|
|
||||||
if (body.getExprents().size() == 1 && handler.getExprents().size() == 1) {
|
if (body.getExprents().size() == 1 && handler.getExprents().size() == 1) {
|
||||||
if (bodyexprent.equals(body.getExprents().get(0)) &&
|
if (BODY_EXPR.equals(body.getExprents().get(0)) &&
|
||||||
handlerexprent.equals(handler.getExprents().get(0))) {
|
HANDLER_EXPR.equals(handler.getExprents().get(0))) {
|
||||||
map.put(wrapper, method);
|
map.put(wrapper, method);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,12 +388,7 @@ public class ClassWriter {
|
|||||||
buffer.append('{').appendLineSeparator();
|
buffer.append('{').appendLineSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fieldToJava(ClassWrapper wrapper,
|
private void fieldToJava(ClassWrapper wrapper, StructClass cl, StructField fd, TextBuffer buffer, int indent, BytecodeMappingTracer tracer) {
|
||||||
StructClass cl,
|
|
||||||
StructField fd,
|
|
||||||
TextBuffer buffer,
|
|
||||||
int indent,
|
|
||||||
BytecodeMappingTracer tracer) {
|
|
||||||
int start = buffer.length();
|
int start = buffer.length();
|
||||||
boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE);
|
boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE);
|
||||||
boolean isDeprecated = fd.getAttributes().containsKey("Deprecated");
|
boolean isDeprecated = fd.getAttributes().containsKey("Deprecated");
|
||||||
@@ -680,8 +675,7 @@ public class ClassWriter {
|
|||||||
}
|
}
|
||||||
else if (isEnum && init) actualParams -= 2;
|
else if (isEnum && init) actualParams -= 2;
|
||||||
if (actualParams != descriptor.params.size()) {
|
if (actualParams != descriptor.params.size()) {
|
||||||
String message =
|
String message = "Inconsistent generic signature in method " + mt.getName() + " " + mt.getDescriptor() + " in " + cl.qualifiedName;
|
||||||
"Inconsistent generic signature in method " + mt.getName() + " " + mt.getDescriptor() + " in " + cl.qualifiedName;
|
|
||||||
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
|
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
|
||||||
descriptor = null;
|
descriptor = null;
|
||||||
}
|
}
|
||||||
@@ -743,8 +737,7 @@ public class ClassWriter {
|
|||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
GenericType parameterType = descriptor.params.get(i);
|
GenericType parameterType = descriptor.params.get(i);
|
||||||
|
|
||||||
boolean isVarArg =
|
boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0);
|
||||||
(i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0);
|
|
||||||
if (isVarArg) {
|
if (isVarArg) {
|
||||||
parameterType = parameterType.decreaseArrayDim();
|
parameterType = parameterType.decreaseArrayDim();
|
||||||
}
|
}
|
||||||
@@ -764,8 +757,7 @@ public class ClassWriter {
|
|||||||
else {
|
else {
|
||||||
VarType parameterType = md.params[i];
|
VarType parameterType = md.params[i];
|
||||||
|
|
||||||
boolean isVarArg =
|
boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0);
|
||||||
(i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0);
|
|
||||||
if (isVarArg) {
|
if (isVarArg) {
|
||||||
parameterType = parameterType.decreaseArrayDim();
|
parameterType = parameterType.decreaseArrayDim();
|
||||||
}
|
}
|
||||||
@@ -995,7 +987,6 @@ public class ClassWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Integer, String> MODIFIERS;
|
private static final Map<Integer, String> MODIFIERS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
MODIFIERS = new LinkedHashMap<>();
|
MODIFIERS = new LinkedHashMap<>();
|
||||||
MODIFIERS.put(CodeConstants.ACC_PUBLIC, "public");
|
MODIFIERS.put(CodeConstants.ACC_PUBLIC, "public");
|
||||||
@@ -1018,14 +1009,8 @@ public class ClassWriter {
|
|||||||
CodeConstants.ACC_PUBLIC | CodeConstants.ACC_PROTECTED | CodeConstants.ACC_PRIVATE | CodeConstants.ACC_STATIC |
|
CodeConstants.ACC_PUBLIC | CodeConstants.ACC_PROTECTED | CodeConstants.ACC_PRIVATE | CodeConstants.ACC_STATIC |
|
||||||
CodeConstants.ACC_FINAL | CodeConstants.ACC_TRANSIENT | CodeConstants.ACC_VOLATILE;
|
CodeConstants.ACC_FINAL | CodeConstants.ACC_TRANSIENT | CodeConstants.ACC_VOLATILE;
|
||||||
private static final int METHOD_ALLOWED =
|
private static final int METHOD_ALLOWED =
|
||||||
CodeConstants.ACC_PUBLIC |
|
CodeConstants.ACC_PUBLIC | CodeConstants.ACC_PROTECTED | CodeConstants.ACC_PRIVATE | CodeConstants.ACC_ABSTRACT |
|
||||||
CodeConstants.ACC_PROTECTED |
|
CodeConstants.ACC_STATIC | CodeConstants.ACC_FINAL | CodeConstants.ACC_SYNCHRONIZED | CodeConstants.ACC_NATIVE |
|
||||||
CodeConstants.ACC_PRIVATE |
|
|
||||||
CodeConstants.ACC_ABSTRACT |
|
|
||||||
CodeConstants.ACC_STATIC |
|
|
||||||
CodeConstants.ACC_FINAL |
|
|
||||||
CodeConstants.ACC_SYNCHRONIZED |
|
|
||||||
CodeConstants.ACC_NATIVE |
|
|
||||||
CodeConstants.ACC_STRICT;
|
CodeConstants.ACC_STRICT;
|
||||||
|
|
||||||
private static final int CLASS_EXCLUDED = CodeConstants.ACC_ABSTRACT | CodeConstants.ACC_STATIC;
|
private static final int CLASS_EXCLUDED = CodeConstants.ACC_ABSTRACT | CodeConstants.ACC_STATIC;
|
||||||
|
|||||||
Reference in New Issue
Block a user