From 84ea54eb1e2c68091080951a3024cca98f70aca2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 29 Aug 2014 14:31:45 +0400 Subject: java-decompiler: post-import cleanup (code style issues) --- .../java/decompiler/struct/IDecompiledData.java | 4 +- .../java/decompiler/struct/ISaveClass.java | 6 +-- .../java/decompiler/struct/StructContext.java | 4 +- .../java/decompiler/struct/StructMethod.java | 7 +-- .../struct/attr/StructExceptionsAttribute.java | 4 +- .../decompiler/struct/consts/ConstantPool.java | 2 +- .../decompiler/struct/consts/LinkConstant.java | 1 - .../decompiler/struct/consts/VariableTypeEnum.java | 52 +++++++++++----------- .../decompiler/struct/gen/FieldDescriptor.java | 8 ++-- .../java/decompiler/struct/gen/VarType.java | 28 ++++++------ .../struct/gen/generics/GenericMain.java | 4 +- .../struct/gen/generics/GenericType.java | 2 +- .../java/decompiler/struct/lazy/LazyLoader.java | 2 +- 13 files changed, 59 insertions(+), 65 deletions(-) (limited to 'src/org/jetbrains/java/decompiler/struct') diff --git a/src/org/jetbrains/java/decompiler/struct/IDecompiledData.java b/src/org/jetbrains/java/decompiler/struct/IDecompiledData.java index 1976216..f309b0e 100644 --- a/src/org/jetbrains/java/decompiler/struct/IDecompiledData.java +++ b/src/org/jetbrains/java/decompiler/struct/IDecompiledData.java @@ -17,7 +17,7 @@ package org.jetbrains.java.decompiler.struct; public interface IDecompiledData { - public String getClassEntryName(StructClass cl, String entryname); + String getClassEntryName(StructClass cl, String entryname); - public String getClassContent(StructClass cl); + String getClassContent(StructClass cl); } diff --git a/src/org/jetbrains/java/decompiler/struct/ISaveClass.java b/src/org/jetbrains/java/decompiler/struct/ISaveClass.java index 69a90f9..c8a5a45 100644 --- a/src/org/jetbrains/java/decompiler/struct/ISaveClass.java +++ b/src/org/jetbrains/java/decompiler/struct/ISaveClass.java @@ -22,9 +22,9 @@ import java.io.IOException; public interface ISaveClass { - public String getClassEntryName(StructClass cl, String entryname); + String getClassEntryName(StructClass cl, String entryname); - public void saveClassToFile(StructClass cl, File file) throws FileNotFoundException, IOException; + void saveClassToFile(StructClass cl, File file) throws FileNotFoundException, IOException; - public void saveClassToStream(StructClass cl, DataOutputStream out); + void saveClassToStream(StructClass cl, DataOutputStream out); } diff --git a/src/org/jetbrains/java/decompiler/struct/StructContext.java b/src/org/jetbrains/java/decompiler/struct/StructContext.java index 3728a2a..ecca95a 100644 --- a/src/org/jetbrains/java/decompiler/struct/StructContext.java +++ b/src/org/jetbrains/java/decompiler/struct/StructContext.java @@ -41,8 +41,6 @@ public class StructContext { private HashMap units = new HashMap(); - private ContextUnit defaultUnit; - private IDecompilatSaver saver; private IDecompiledData decdata; @@ -53,7 +51,7 @@ public class StructContext { this.decdata = decdata; this.loader = loader; - defaultUnit = new ContextUnit(ContextUnit.TYPE_FOLDER, null, "", true, saver, decdata); + ContextUnit defaultUnit = new ContextUnit(ContextUnit.TYPE_FOLDER, null, "", true, saver, decdata); units.put("", defaultUnit); } diff --git a/src/org/jetbrains/java/decompiler/struct/StructMethod.java b/src/org/jetbrains/java/decompiler/struct/StructMethod.java index baaf633..08101d2 100644 --- a/src/org/jetbrains/java/decompiler/struct/StructMethod.java +++ b/src/org/jetbrains/java/decompiler/struct/StructMethod.java @@ -78,8 +78,6 @@ public class StructMethod implements CodeConstants { private boolean containsCode = false; - private boolean own; - private StructClass classStruct; @@ -104,7 +102,6 @@ public class StructMethod implements CodeConstants { public StructMethod(DataInputFullStream in, boolean lazy, boolean own, StructClass clstruct) throws IOException { - this.own = own; this.lazy = lazy; this.expanded = !lazy; this.classStruct = clstruct; @@ -125,7 +122,7 @@ public class StructMethod implements CodeConstants { String attrname = pool.getPrimitiveConstant(attr_nameindex).getString(); if (StructGeneralAttribute.ATTRIBUTE_CODE.equals(attrname)) { - if (!this.own) { + if (!own) { // skip code in foreign classes in.skip(8); in.skip(in.readInt()); @@ -478,7 +475,7 @@ public class StructMethod implements CodeConstants { int[] ops = new int[operands.size()]; for (int j = 0; j < operands.size(); j++) { - ops[j] = ((Integer)operands.get(j)).intValue(); + ops[j] = operands.get(j).intValue(); } Instruction instr = ConstantsUtil.getInstructionInstance(opcode, wide, group, bytecode_version, ops); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java index 930db78..c52fcc7 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java @@ -51,7 +51,7 @@ public class StructExceptionsAttribute extends StructGeneralAttribute { if (len > 0) { info = new byte[len * 2]; for (int i = 0, j = 0; i < len; i++, j += 2) { - int index = ((Integer)throwsExceptions.get(i)).intValue(); + int index = throwsExceptions.get(i).intValue(); info[j] = (byte)(index >> 8); info[j + 1] = (byte)(index & 0xFF); } @@ -63,7 +63,7 @@ public class StructExceptionsAttribute extends StructGeneralAttribute { } public String getExcClassname(int index, ConstantPool pool) { - return pool.getPrimitiveConstant(((Integer)throwsExceptions.get(index)).intValue()).getString(); + return pool.getPrimitiveConstant(throwsExceptions.get(index).intValue()).getString(); } public List getThrowsExceptions() { diff --git a/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java b/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java index 5a593af..ac3c5a5 100644 --- a/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java +++ b/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java @@ -129,7 +129,7 @@ public class ConstantPool { out.writeShort(pool.size()); for (int i = 1; i < pool.size(); i++) { - PooledConstant cnst = (PooledConstant)pool.get(i); + PooledConstant cnst = pool.get(i); if (cnst != null) { cnst.writeToStream(out); } diff --git a/src/org/jetbrains/java/decompiler/struct/consts/LinkConstant.java b/src/org/jetbrains/java/decompiler/struct/consts/LinkConstant.java index c20b5af..71bf146 100644 --- a/src/org/jetbrains/java/decompiler/struct/consts/LinkConstant.java +++ b/src/org/jetbrains/java/decompiler/struct/consts/LinkConstant.java @@ -40,7 +40,6 @@ public class LinkConstant extends PooledConstant { public int paramCount = 0; public boolean isVoid = false; - ; public boolean returnCategory2 = false; diff --git a/src/org/jetbrains/java/decompiler/struct/consts/VariableTypeEnum.java b/src/org/jetbrains/java/decompiler/struct/consts/VariableTypeEnum.java index ef949aa..7950d5b 100644 --- a/src/org/jetbrains/java/decompiler/struct/consts/VariableTypeEnum.java +++ b/src/org/jetbrains/java/decompiler/struct/consts/VariableTypeEnum.java @@ -17,31 +17,31 @@ package org.jetbrains.java.decompiler.struct.consts; public interface VariableTypeEnum { - public final static int BOOLEAN = 1; - public final static int BYTE = 2; - public final static int CHAR = 3; - public final static int SHORT = 4; - public final static int INT = 5; - public final static int FLOAT = 6; - public final static int LONG = 7; - public final static int DOUBLE = 8; - public final static int RETURN_ADDRESS = 9; - public final static int REFERENCE = 10; - public final static int INSTANCE_UNINITIALIZED = 11; - public final static int VALUE_UNKNOWN = 12; - public final static int VOID = 13; + int BOOLEAN = 1; + int BYTE = 2; + int CHAR = 3; + int SHORT = 4; + int INT = 5; + int FLOAT = 6; + int LONG = 7; + int DOUBLE = 8; + int RETURN_ADDRESS = 9; + int REFERENCE = 10; + int INSTANCE_UNINITIALIZED = 11; + int VALUE_UNKNOWN = 12; + int VOID = 13; - public final static Integer BOOLEAN_OBJ = new Integer(BOOLEAN); - public final static Integer BYTE_OBJ = new Integer(BYTE); - public final static Integer CHAR_OBJ = new Integer(CHAR); - public final static Integer SHORT_OBJ = new Integer(SHORT); - public final static Integer INT_OBJ = new Integer(INT); - public final static Integer FLOAT_OBJ = new Integer(FLOAT); - public final static Integer LONG_OBJ = new Integer(LONG); - public final static Integer DOUBLE_OBJ = new Integer(DOUBLE); - public final static Integer RETURN_ADDRESS_OBJ = new Integer(RETURN_ADDRESS); - public final static Integer REFERENCE_OBJ = new Integer(REFERENCE); - public final static Integer INSTANCE_UNINITIALIZED_OBJ = new Integer(INSTANCE_UNINITIALIZED); - public final static Integer VALUE_UNKNOWN_OBJ = new Integer(VALUE_UNKNOWN); - public final static Integer VOID_OBJ = new Integer(VOID); + Integer BOOLEAN_OBJ = new Integer(BOOLEAN); + Integer BYTE_OBJ = new Integer(BYTE); + Integer CHAR_OBJ = new Integer(CHAR); + Integer SHORT_OBJ = new Integer(SHORT); + Integer INT_OBJ = new Integer(INT); + Integer FLOAT_OBJ = new Integer(FLOAT); + Integer LONG_OBJ = new Integer(LONG); + Integer DOUBLE_OBJ = new Integer(DOUBLE); + Integer RETURN_ADDRESS_OBJ = new Integer(RETURN_ADDRESS); + Integer REFERENCE_OBJ = new Integer(REFERENCE); + Integer INSTANCE_UNINITIALIZED_OBJ = new Integer(INSTANCE_UNINITIALIZED); + Integer VALUE_UNKNOWN_OBJ = new Integer(VALUE_UNKNOWN); + Integer VOID_OBJ = new Integer(VOID); } diff --git a/src/org/jetbrains/java/decompiler/struct/gen/FieldDescriptor.java b/src/org/jetbrains/java/decompiler/struct/gen/FieldDescriptor.java index ff731ae..fd213f0 100644 --- a/src/org/jetbrains/java/decompiler/struct/gen/FieldDescriptor.java +++ b/src/org/jetbrains/java/decompiler/struct/gen/FieldDescriptor.java @@ -17,10 +17,10 @@ package org.jetbrains.java.decompiler.struct.gen; public class FieldDescriptor { - public static final FieldDescriptor INTEGER_DESCRIPTOR = FieldDescriptor.parseDescriptor("Ljava/lang/Integer;"); - public static final FieldDescriptor LONG_DESCRIPTOR = FieldDescriptor.parseDescriptor("Ljava/lang/Long;"); - public static final FieldDescriptor FLOAT_DESCRIPTOR = FieldDescriptor.parseDescriptor("Ljava/lang/Float;"); - public static final FieldDescriptor DOUBLE_DESCRIPTOR = FieldDescriptor.parseDescriptor("Ljava/lang/Double;"); + public static final FieldDescriptor INTEGER_DESCRIPTOR = parseDescriptor("Ljava/lang/Integer;"); + public static final FieldDescriptor LONG_DESCRIPTOR = parseDescriptor("Ljava/lang/Long;"); + public static final FieldDescriptor FLOAT_DESCRIPTOR = parseDescriptor("Ljava/lang/Float;"); + public static final FieldDescriptor DOUBLE_DESCRIPTOR = parseDescriptor("Ljava/lang/Double;"); public VarType type; diff --git a/src/org/jetbrains/java/decompiler/struct/gen/VarType.java b/src/org/jetbrains/java/decompiler/struct/gen/VarType.java index 79e2cbf..1b6ff99 100644 --- a/src/org/jetbrains/java/decompiler/struct/gen/VarType.java +++ b/src/org/jetbrains/java/decompiler/struct/gen/VarType.java @@ -119,7 +119,7 @@ public class VarType { // TODO: optimize switch } public boolean isFalseBoolean() { - return (convinfo & VarType.FALSEBOOLEAN) != 0; + return (convinfo & FALSEBOOLEAN) != 0; } public boolean isSuperset(VarType val) { @@ -189,13 +189,13 @@ public class VarType { // TODO: optimize switch case CodeConstants.TYPE_FAMILY_INTEGER: if ((type1.type == CodeConstants.TYPE_CHAR && type2.type == CodeConstants.TYPE_SHORT) || (type1.type == CodeConstants.TYPE_SHORT && type2.type == CodeConstants.TYPE_CHAR)) { - return VarType.VARTYPE_SHORTCHAR; + return VARTYPE_SHORTCHAR; } else { - return VarType.VARTYPE_BYTECHAR; + return VARTYPE_BYTECHAR; } case CodeConstants.TYPE_FAMILY_OBJECT: - return VarType.VARTYPE_NULL; + return VARTYPE_NULL; } } @@ -220,13 +220,13 @@ public class VarType { // TODO: optimize switch case CodeConstants.TYPE_FAMILY_INTEGER: if ((type1.type == CodeConstants.TYPE_SHORTCHAR && type2.type == CodeConstants.TYPE_BYTE) || (type1.type == CodeConstants.TYPE_BYTE && type2.type == CodeConstants.TYPE_SHORTCHAR)) { - return VarType.VARTYPE_SHORT; + return VARTYPE_SHORT; } else { - return VarType.VARTYPE_INT; + return VARTYPE_INT; } case CodeConstants.TYPE_FAMILY_OBJECT: - return VarType.VARTYPE_OBJECT; + return VARTYPE_OBJECT; } } @@ -236,19 +236,19 @@ public class VarType { // TODO: optimize switch public static VarType getMinTypeInFamily(int family) { switch (family) { case CodeConstants.TYPE_FAMILY_BOOLEAN: - return VarType.VARTYPE_BOOLEAN; + return VARTYPE_BOOLEAN; case CodeConstants.TYPE_FAMILY_INTEGER: - return VarType.VARTYPE_BYTECHAR; + return VARTYPE_BYTECHAR; case CodeConstants.TYPE_FAMILY_OBJECT: - return VarType.VARTYPE_NULL; + return VARTYPE_NULL; case CodeConstants.TYPE_FAMILY_FLOAT: - return VarType.VARTYPE_FLOAT; + return VARTYPE_FLOAT; case CodeConstants.TYPE_FAMILY_LONG: - return VarType.VARTYPE_LONG; + return VARTYPE_LONG; case CodeConstants.TYPE_FAMILY_DOUBLE: - return VarType.VARTYPE_DOUBLE; + return VARTYPE_DOUBLE; case CodeConstants.TYPE_FAMILY_UNKNOWN: - return VarType.VARTYPE_UNKNOWN; + return VARTYPE_UNKNOWN; default: throw new RuntimeException("invalid type family!"); } diff --git a/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericMain.java b/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericMain.java index db7d84b..6a4f52e 100644 --- a/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericMain.java +++ b/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericMain.java @@ -127,7 +127,7 @@ public class GenericMain { List lstBounds = new ArrayList(); - for (; ; ) { + while (true) { if (value.charAt(0) == ':') { // empty superclass, skip value = value.substring(1); @@ -199,7 +199,7 @@ public class GenericMain { GenericType genpar = type.getArguments().get(i); if (genpar != null) { - buffer.append(GenericMain.getGenericCastTypeName(genpar)); + buffer.append(getGenericCastTypeName(genpar)); } } buffer.append(">"); diff --git a/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericType.java b/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericType.java index e2faa4a..61d07a0 100644 --- a/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericType.java +++ b/src/org/jetbrains/java/decompiler/struct/gen/generics/GenericType.java @@ -70,7 +70,7 @@ public class GenericType { type = CodeConstants.TYPE_OBJECT; sig = sig.substring(index + 1, sig.length() - 1); - for (; ; ) { + while (true) { String cl = getNextClassSignature(sig); String name = cl; diff --git a/src/org/jetbrains/java/decompiler/struct/lazy/LazyLoader.java b/src/org/jetbrains/java/decompiler/struct/lazy/LazyLoader.java index 46a334e..ad87235 100644 --- a/src/org/jetbrains/java/decompiler/struct/lazy/LazyLoader.java +++ b/src/org/jetbrains/java/decompiler/struct/lazy/LazyLoader.java @@ -109,7 +109,7 @@ public class LazyLoader { int name_index = in.readUnsignedShort(); int descriptor_index = in.readUnsignedShort(); - String elem_arr[] = pool.getClassElement(ConstantPool.METHOD, this_class, name_index, descriptor_index); + String[] elem_arr = pool.getClassElement(ConstantPool.METHOD, this_class, name_index, descriptor_index); String name = elem_arr[0]; if (mt.getName().equals(name)) { -- cgit v1.2.3