Cleanup (formatting)

master
Roman Shevchenko 9 years ago
parent c32fce0d02
commit d50e8a860e
  1. 77
      src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java
  2. 27
      src/org/jetbrains/java/decompiler/main/ClassWriter.java

@ -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();
InvocationExprent invfor = new InvocationExprent(); invFor.setName("forName");
invfor.setName("forName"); invFor.setClassname("java/lang/Class");
invfor.setClassname("java/lang/Class"); invFor.setStringDescriptor("(Ljava/lang/String;)Ljava/lang/Class;");
invfor.setStringDescriptor("(Ljava/lang/String;)Ljava/lang/Class;"); invFor.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/String;)Ljava/lang/Class;"));
invfor.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/String;)Ljava/lang/Class;")); invFor.setStatic(true);
invfor.setStatic(true); invFor.setLstParameters(Collections.singletonList(new VarExprent(0, VarType.VARTYPE_STRING, null)));
invfor.setLstParameters(Arrays.asList(new Exprent[]{new VarExprent(0, VarType.VARTYPE_STRING, null)})); BODY_EXPR = new ExitExprent(ExitExprent.EXIT_RETURN, invFor, VarType.VARTYPE_CLASS, null);
bodyexprent = new ExitExprent(ExitExprent.EXIT_RETURN, InvocationExprent ctor = new InvocationExprent();
invfor, ctor.setName(CodeConstants.INIT_NAME);
VarType.VARTYPE_CLASS, null); ctor.setClassname("java/lang/NoClassDefFoundError");
ctor.setStringDescriptor("()V");
InvocationExprent constr = new InvocationExprent(); ctor.setFunctype(InvocationExprent.TYP_INIT);
constr.setName(CodeConstants.INIT_NAME); ctor.setDescriptor(MethodDescriptor.parseDescriptor("()V"));
constr.setClassname("java/lang/NoClassDefFoundError");
constr.setStringDescriptor("()V"); NewExprent newExpr = new NewExprent(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/NoClassDefFoundError"), new ArrayList<>(), null);
constr.setFunctype(InvocationExprent.TYP_INIT); newExpr.setConstructor(ctor);
constr.setDescriptor(MethodDescriptor.parseDescriptor("()V"));
InvocationExprent invCause = new InvocationExprent();
NewExprent newexpr = invCause.setName("initCause");
new NewExprent(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/NoClassDefFoundError"), new ArrayList<>(), null); invCause.setClassname("java/lang/NoClassDefFoundError");
newexpr.setConstructor(constr); invCause.setStringDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
invCause.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;"));
InvocationExprent invcause = new InvocationExprent(); invCause.setInstance(newExpr);
invcause.setName("initCause"); invCause.setLstParameters(
invcause.setClassname("java/lang/NoClassDefFoundError"); Collections.singletonList(new VarExprent(2, new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"), null)));
invcause.setStringDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
invcause.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;")); HANDLER_EXPR = new ExitExprent(ExitExprent.EXIT_THROW, invCause, null, null);
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;

Loading…
Cancel
Save