From d50e8a860e9070c1f6685fcf0009316f55034a8f Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 16 Mar 2016 17:34:59 +0100 Subject: [PATCH] Cleanup (formatting) --- .../main/ClassReference14Processor.java | 79 ++++++++----------- .../java/decompiler/main/ClassWriter.java | 29 ++----- 2 files changed, 42 insertions(+), 66 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java b/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java index a36c88e..e97c47e 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java +++ b/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.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"); * you may not use this file except in compliance with the License. @@ -37,48 +37,39 @@ import java.util.*; import java.util.Map.Entry; public class ClassReference14Processor { - - public static final ExitExprent bodyexprent; - - public static final ExitExprent handlerexprent; + private static final ExitExprent BODY_EXPR; + private static final ExitExprent HANDLER_EXPR; 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(Arrays.asList(new Exprent[]{new VarExprent(0, VarType.VARTYPE_STRING, null)})); - - bodyexprent = new ExitExprent(ExitExprent.EXIT_RETURN, - invfor, - VarType.VARTYPE_CLASS, null); - - InvocationExprent constr = new InvocationExprent(); - constr.setName(CodeConstants.INIT_NAME); - constr.setClassname("java/lang/NoClassDefFoundError"); - constr.setStringDescriptor("()V"); - constr.setFunctype(InvocationExprent.TYP_INIT); - constr.setDescriptor(MethodDescriptor.parseDescriptor("()V")); - - NewExprent newexpr = - 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); + 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 ctor = new InvocationExprent(); + ctor.setName(CodeConstants.INIT_NAME); + ctor.setClassname("java/lang/NoClassDefFoundError"); + ctor.setStringDescriptor("()V"); + ctor.setFunctype(InvocationExprent.TYP_INIT); + ctor.setDescriptor(MethodDescriptor.parseDescriptor("()V")); + + NewExprent newExpr = new NewExprent(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/NoClassDefFoundError"), new ArrayList<>(), null); + newExpr.setConstructor(ctor); + + 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( + Collections.singletonList(new VarExprent(2, new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"), null))); + + HANDLER_EXPR = new ExitExprent(ExitExprent.EXIT_THROW, invCause, null, null); } public static void processClassReferences(ClassNode node) { @@ -176,8 +167,8 @@ public class ClassReference14Processor { BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1); if (body.getExprents().size() == 1 && handler.getExprents().size() == 1) { - if (bodyexprent.equals(body.getExprents().get(0)) && - handlerexprent.equals(handler.getExprents().get(0))) { + if (BODY_EXPR.equals(body.getExprents().get(0)) && + HANDLER_EXPR.equals(handler.getExprents().get(0))) { map.put(wrapper, method); break; } @@ -273,4 +264,4 @@ public class ClassReference14Processor { return null; } -} +} \ No newline at end of file diff --git a/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/src/org/jetbrains/java/decompiler/main/ClassWriter.java index ed7c99d..f79198f 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -388,12 +388,7 @@ public class ClassWriter { buffer.append('{').appendLineSeparator(); } - private void fieldToJava(ClassWrapper wrapper, - StructClass cl, - StructField fd, - TextBuffer buffer, - int indent, - BytecodeMappingTracer tracer) { + private void fieldToJava(ClassWrapper wrapper, StructClass cl, StructField fd, TextBuffer buffer, int indent, BytecodeMappingTracer tracer) { int start = buffer.length(); boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE); boolean isDeprecated = fd.getAttributes().containsKey("Deprecated"); @@ -680,8 +675,7 @@ public class ClassWriter { } else if (isEnum && init) actualParams -= 2; if (actualParams != descriptor.params.size()) { - String message = - "Inconsistent generic signature in method " + mt.getName() + " " + mt.getDescriptor() + " in " + cl.qualifiedName; + String message = "Inconsistent generic signature in method " + mt.getName() + " " + mt.getDescriptor() + " in " + cl.qualifiedName; DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN); descriptor = null; } @@ -743,8 +737,7 @@ public class ClassWriter { if (descriptor != null) { GenericType parameterType = descriptor.params.get(i); - boolean isVarArg = - (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0); + boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0); if (isVarArg) { parameterType = parameterType.decreaseArrayDim(); } @@ -764,8 +757,7 @@ public class ClassWriter { else { VarType parameterType = md.params[i]; - boolean isVarArg = - (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0); + boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0); if (isVarArg) { parameterType = parameterType.decreaseArrayDim(); } @@ -995,7 +987,6 @@ public class ClassWriter { } private static final Map MODIFIERS; - static { MODIFIERS = new LinkedHashMap<>(); 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_FINAL | CodeConstants.ACC_TRANSIENT | CodeConstants.ACC_VOLATILE; private static final int METHOD_ALLOWED = - CodeConstants.ACC_PUBLIC | - CodeConstants.ACC_PROTECTED | - CodeConstants.ACC_PRIVATE | - CodeConstants.ACC_ABSTRACT | - CodeConstants.ACC_STATIC | - CodeConstants.ACC_FINAL | - CodeConstants.ACC_SYNCHRONIZED | - CodeConstants.ACC_NATIVE | + CodeConstants.ACC_PUBLIC | CodeConstants.ACC_PROTECTED | CodeConstants.ACC_PRIVATE | CodeConstants.ACC_ABSTRACT | + CodeConstants.ACC_STATIC | CodeConstants.ACC_FINAL | CodeConstants.ACC_SYNCHRONIZED | CodeConstants.ACC_NATIVE | CodeConstants.ACC_STRICT; private static final int CLASS_EXCLUDED = CodeConstants.ACC_ABSTRACT | CodeConstants.ACC_STATIC; @@ -1065,4 +1050,4 @@ public class ClassWriter { buffer.append('>'); } -} +} \ No newline at end of file