diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index d67eb86b2..649c64255 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -154,7 +154,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { case AVM2Code.OPT_CASE_OFFSETS: s.add(new Long(operands[i])); for (int j = i + 1; j < operands.length; j++) { - s.add(new Long(offset + operands[j])); + s.add(offset + operands[j]); } break; default: diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java index dfd6cf6c8..7495f1a4d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java @@ -41,16 +41,16 @@ public class AddIns extends InstructionDefinition { Object o1 = lda.operandStack.pop(); Object o2 = lda.operandStack.pop(); if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = Long.valueOf(((Long) o1).longValue() + ((Long) o2).longValue()); + Long ret = ((Long) o1) + ((Long) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = Double.valueOf(((Double) o1).doubleValue() + ((Double) o2).doubleValue()); + Double ret = ((Double) o1) + ((Double) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() + ((Double) o2).doubleValue()); + Double ret = ((Long) o1) + ((Double) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() + ((Long) o2).longValue()); + Double ret = ((Double) o1) + ((Long) o2); lda.operandStack.push(ret); } else { String s = o1.toString() + o2.toString(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java index 8dbdc6d52..a8a3e2c5b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java @@ -40,10 +40,10 @@ public class DecrementIIns extends InstructionDefinition { public void execute(LocalDataArea lda, AVM2ConstantPool constants, List arguments) { Object obj = lda.operandStack.pop(); if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; + Long obj2 = ((Long) obj) - 1; lda.operandStack.push(obj2); } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; + Double obj2 = ((Double) obj) - 1; lda.operandStack.push(obj2); } if (obj instanceof String) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java index beb63cfc4..bcca14a02 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java @@ -40,10 +40,10 @@ public class DecrementIns extends InstructionDefinition { public void execute(LocalDataArea lda, AVM2ConstantPool constants, List arguments) { Object obj = lda.operandStack.pop(); if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; + Long obj2 = ((Long) obj) - 1; lda.operandStack.push(obj2); } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; + Double obj2 = ((Double) obj) - 1; lda.operandStack.push(obj2); } if (obj instanceof String) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java index e68132c9c..3d75dd908 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java @@ -41,16 +41,16 @@ public class DivideIns extends InstructionDefinition { Object o2 = lda.operandStack.pop(); Object o1 = lda.operandStack.pop(); if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = Long.valueOf(((Long) o1).longValue() / ((Long) o2).longValue()); + Long ret = ((Long) o1) / ((Long) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = Double.valueOf(((Double) o1).doubleValue() / ((Double) o2).doubleValue()); + Double ret = ((Double) o1) / ((Double) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() / ((Double) o2).doubleValue()); + Double ret = ((Long) o1) / ((Double) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() / ((Long) o2).longValue()); + Double ret = ((Double) o1) / ((Long) o2); lda.operandStack.push(ret); } else { throw new RuntimeException("Cannot divide"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java index 27bb3c79e..60a66b557 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java @@ -42,7 +42,7 @@ public class ModuloIns extends InstructionDefinition { Object o2 = lda.operandStack.pop(); if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = Long.valueOf(((Long) o2).longValue() % ((Long) o1).longValue()); + Long ret = ((Long) o2) % ((Long) o1); lda.operandStack.push(ret); } else { throw new RuntimeException("Cannot modulo"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java index e09c43bdd..1e6d5ee00 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java @@ -41,16 +41,16 @@ public class MultiplyIns extends InstructionDefinition { Object o1 = lda.operandStack.pop(); Object o2 = lda.operandStack.pop(); if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = Long.valueOf(((Long) o1).longValue() * ((Long) o2).longValue()); + Long ret = ((Long) o1) * ((Long) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = Double.valueOf(((Double) o1).doubleValue() * ((Double) o2).doubleValue()); + Double ret = ((Double) o1) * ((Double) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() * ((Double) o2).doubleValue()); + Double ret = ((Long) o1) * ((Double) o2); lda.operandStack.push(ret); } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() * ((Long) o2).longValue()); + Double ret = ((Double) o1) * ((Long) o2); lda.operandStack.push(ret); } else { throw new RuntimeException("Cannot multiply"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java index 2540583b0..64e94c7b7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java @@ -39,7 +39,7 @@ public class BitNotIns extends InstructionDefinition { @Override public void execute(LocalDataArea lda, AVM2ConstantPool constants, List arguments) { Long value = (Long) lda.operandStack.pop(); - Long ret = Long.valueOf(-value.longValue()); + Long ret = -value; lda.operandStack.push(ret); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java index f38adbf70..79a8ab4f2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java @@ -43,10 +43,10 @@ public class DecLocalIIns extends InstructionDefinition { int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); Object obj = lda.localRegisters.get(locRegIndex); if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; + Long obj2 = ((Long) obj) - 1; lda.localRegisters.put(locRegIndex, obj2); } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; + Double obj2 = ((Double) obj) - 1; lda.localRegisters.put(locRegIndex, obj2); } if (obj instanceof String) { @@ -62,7 +62,7 @@ public class DecLocalIIns extends InstructionDefinition { int regId = ins.operands[0]; output.add(new DecLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { - localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, 1L))); } else { //localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1)))); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java index 53280cad3..56e68b37f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java @@ -43,10 +43,10 @@ public class DecLocalIns extends InstructionDefinition { int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); Object obj = lda.localRegisters.get(locRegIndex); if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; + Long obj2 = ((Long) obj) - 1; lda.localRegisters.put(locRegIndex, obj2); } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; + Double obj2 = ((Double) obj) - 1; lda.localRegisters.put(locRegIndex, obj2); } if (obj instanceof String) { @@ -62,7 +62,7 @@ public class DecLocalIns extends InstructionDefinition { int regId = ins.operands[0]; output.add(new DecLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { - localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, 1L))); } else { //localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1)))); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java index 886b1cac9..0ea50dfa4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java @@ -42,7 +42,7 @@ public class IncLocalIIns extends InstructionDefinition { int regId = ins.operands[0]; output.add(new IncLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { - localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, 1L))); } else { //localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1)))); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java index cb1681be8..671932eca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java @@ -42,7 +42,7 @@ public class IncLocalIns extends InstructionDefinition { int regId = ins.operands[0]; output.add(new IncLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { - localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, 1L))); } else { //localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1)))); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java index e983e6a6d..3c33198fc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java @@ -43,7 +43,7 @@ public class PushByteIns extends InstructionDefinition implements PushIntegerTyp @Override public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new IntegerValueAVM2Item(ins, Long.valueOf(ins.operands[0]))); + stack.push(new IntegerValueAVM2Item(ins, (long) ins.operands[0])); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java index 8dc44f659..1002d4040 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java @@ -43,7 +43,7 @@ public class PushShortIns extends InstructionDefinition implements PushIntegerTy @Override public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new IntegerValueAVM2Item(ins, Long.valueOf((long) (short) ins.operands[0]))); + stack.push(new IntegerValueAVM2Item(ins, (long) (short) ins.operands[0])); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 73ce7272a..c71209430 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -44,7 +44,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver if (value instanceof Boolean) { bval = (Boolean) value; } else if (value instanceof Long) { - bval = ((Long) value).longValue() != 0; + bval = (Long) value != 0; } else if (value instanceof String) { bval = !((String) value).isEmpty(); } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index 08206aec2..d591b127e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -44,21 +44,21 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver if (value == null) { ret = 0; } else if (value instanceof Boolean) { - if (((Boolean) value).booleanValue()) { + if ((Boolean) value) { ret = 1; } else { ret = 0; } } else if (value instanceof Long) { - ret = ((Long) value).longValue(); + ret = (Long) value; } else if (value instanceof Double) { - ret = ((Double) value).doubleValue(); + ret = (Double) value; } else if (value instanceof String) { ret = Double.parseDouble((String) value); } else { ret = 1; //must call toPrimitive } - lda.operandStack.push(Double.valueOf(ret)); + lda.operandStack.push(ret); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index 9182fe15e..7525ff10b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -44,19 +44,19 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver if (value == null) { ret = 0; } else if (value instanceof Boolean) { - if (((Boolean) value).booleanValue()) { + if ((Boolean) value) { ret = 1; } else { ret = 0; } } else if (value instanceof Long) { - ret = ((Long) value).longValue(); + ret = (Long) value; } else if (value instanceof String) { ret = Long.parseLong((String) value); } else { ret = 1; //must call toPrimitive } - lda.operandStack.push(Long.valueOf(ret)); + lda.operandStack.push(ret); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/Flasm3Lexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/Flasm3Lexer.java index 7f682d142..f26cb2014 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/Flasm3Lexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/Flasm3Lexer.java @@ -3183,7 +3183,7 @@ public final class Flasm3Lexer { yybegin(PARAMETERS); // length also includes the trailing quote if (isMultiname) { - return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); + return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, multinameId); } else { return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); } @@ -3222,7 +3222,7 @@ public final class Flasm3Lexer { case 140: break; case 10: { - return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); + return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, Long.parseLong((yytext()))); } case 141: break; @@ -3288,7 +3288,7 @@ public final class Flasm3Lexer { case 152: break; case 29: { - return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); + return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext()))); } case 153: break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java index e1f945de3..3f528ed4b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java @@ -1383,7 +1383,7 @@ public final class ActionScriptLexer { case 172: break; case 13: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong((yytext())))); + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong((yytext()))); } case 173: break; @@ -1603,7 +1603,7 @@ public final class ActionScriptLexer { case 209: break; case 50: { - return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, new Double(Double.parseDouble((yytext())))); + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble((yytext()))); } case 210: break; @@ -1670,7 +1670,7 @@ public final class ActionScriptLexer { case 222: break; case 63: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext(), 8))); + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext(), 8)); } case 223: break; @@ -1899,7 +1899,7 @@ public final class ActionScriptLexer { case 260: break; case 101: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext().substring(2), 16))); + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext().substring(2), 16)); } case 261: break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java index 13e9f46c6..824f78fe9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java @@ -909,7 +909,7 @@ public final class MethodInfoLexer { case 39: break; case 3: { - return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); + return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, Long.parseLong((yytext()))); } case 40: break; @@ -967,7 +967,7 @@ public final class MethodInfoLexer { case 35: { String s = yytext(); long ns = Long.parseLong(s.substring(3, s.length() - 2)); - return new ParsedSymbol(ParsedSymbol.TYPE_NAMESPACE, new Long(ns)); + return new ParsedSymbol(ParsedSymbol.TYPE_NAMESPACE, ns); } case 51: break; @@ -980,7 +980,7 @@ public final class MethodInfoLexer { yybegin(YYINITIAL); // length also includes the trailing quote if (isMultiname) { - return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); + return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, multinameId); } else { return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); } @@ -1015,7 +1015,7 @@ public final class MethodInfoLexer { case 58: break; case 12: { - return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); + return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext()))); } case 59: break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java index fe999f0f0..62e1eddff 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -70,7 +71,7 @@ public class PostDecrementActionItem extends ActionItem implements SetTypeAction @Override public GraphTargetItem getValue() { - return new SubtractActionItem(null, object, new DirectValueActionItem(null, 0, new Long(1), null)); + return new SubtractActionItem(null, object, new DirectValueActionItem(null, 0, 1L, null)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java index ee48a168b..2bb50c480 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -70,7 +71,7 @@ public class PostIncrementActionItem extends ActionItem implements SetTypeAction @Override public GraphTargetItem getValue() { - return new AddActionItem(null, object, new DirectValueActionItem(null, 0, new Long(1), null), true); + return new AddActionItem(null, object, new DirectValueActionItem(null, 0, 1L, null), true); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/FlasmLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/FlasmLexer.java index dc5a4613a..26a5dfd17 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/FlasmLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/FlasmLexer.java @@ -963,7 +963,7 @@ public final class FlasmLexer { case 44: break; case 24: { - return new ASMParsedSymbol(ASMParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); + return new ASMParsedSymbol(ASMParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext()))); } case 45: break; @@ -1017,7 +1017,7 @@ public final class FlasmLexer { case 54: break; case 10: { - return new ASMParsedSymbol(ASMParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); + return new ASMParsedSymbol(ASMParsedSymbol.TYPE_INTEGER, Long.parseLong((yytext()))); } case 55: break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java index f46358a22..ac343edc7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java @@ -1629,7 +1629,7 @@ public final class ActionScriptLexer { case 194: break; case 13: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong((yytext())))); + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong((yytext()))); } case 195: break; @@ -1788,7 +1788,7 @@ public final class ActionScriptLexer { case 224: break; case 43: { - return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, new Double(Double.parseDouble((yytext())))); + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble((yytext()))); } case 225: break; @@ -1823,7 +1823,7 @@ public final class ActionScriptLexer { case 231: break; case 50: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext(), 8))); + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext(), 8)); } case 232: break; @@ -2002,7 +2002,7 @@ public final class ActionScriptLexer { case 265: break; case 84: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext().substring(2), 16))); + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext().substring(2), 16)); } case 266: break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java index ffb32855e..082220b97 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java @@ -857,7 +857,7 @@ public class ActionScriptParser { lockCenter = (expression(registerVars, inFunction, inMethod, true, variables)); s = lex(); if (s.type == SymbolType.COMMA) { - constrain = new DirectValueActionItem(null, 0, new Long(1), new ArrayList()); + constrain = new DirectValueActionItem(null, 0, 1L, new ArrayList()); x1 = (expression(registerVars, inFunction, inMethod, true, variables)); s = lex(); if (s.type == SymbolType.COMMA) { @@ -870,28 +870,28 @@ public class ActionScriptParser { y2 = (expression(registerVars, inFunction, inMethod, true, variables)); } else { lexer.pushback(s); - y2 = new DirectValueActionItem(null, 0, (Long) 0L, new ArrayList()); + y2 = new DirectValueActionItem(null, 0, 0L, new ArrayList()); } } else { lexer.pushback(s); - x2 = new DirectValueActionItem(null, 0, (Long) 0L, new ArrayList()); - y2 = new DirectValueActionItem(null, 0, (Long) 0L, new ArrayList()); + x2 = new DirectValueActionItem(null, 0, 0L, new ArrayList()); + y2 = new DirectValueActionItem(null, 0, 0L, new ArrayList()); } } else { lexer.pushback(s); - x2 = new DirectValueActionItem(null, 0, (Long) 0L, new ArrayList()); - y2 = new DirectValueActionItem(null, 0, (Long) 0L, new ArrayList()); - y1 = new DirectValueActionItem(null, 0, (Long) 0L, new ArrayList()); + x2 = new DirectValueActionItem(null, 0, 0L, new ArrayList()); + y2 = new DirectValueActionItem(null, 0, 0L, new ArrayList()); + y1 = new DirectValueActionItem(null, 0, 0L, new ArrayList()); } } else { lexer.pushback(s); - constrain = new DirectValueActionItem(null, 0, new Long(0), new ArrayList()); + constrain = new DirectValueActionItem(null, 0, 0L, new ArrayList()); //ret.add(new ActionPush(Boolean.FALSE)); } } else { - lockCenter = new DirectValueActionItem(null, 0, new Long(0), new ArrayList()); - constrain = new DirectValueActionItem(null, 0, new Long(0), new ArrayList()); + lockCenter = new DirectValueActionItem(null, 0, 0L, new ArrayList()); + constrain = new DirectValueActionItem(null, 0, 0L, new ArrayList()); lexer.pushback(s); } expectedType(SymbolType.PARENT_CLOSE); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java index 512c2256f..b494859ea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java @@ -743,7 +743,7 @@ public class ActionSourceGenerator implements SourceGenerator { globImp.addAll(impList); constr.addAll(typeToActions(globImp, null)); } - constr.add(new ActionPush(new Long(implementsStr.size()))); + constr.add(new ActionPush((long) implementsStr.size())); constr.addAll(typeToActions(globalClassTypeStr, null)); constr.add(new ActionImplementsOp()); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 4e8bfaa03..4155b4652 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -28,7 +28,6 @@ import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; -import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.base.RemoveTag; import com.jpexs.decompiler.flash.types.CLIPACTIONS; @@ -59,7 +58,7 @@ public class Timeline { public RECT displayRect; public int frameRate; public List tags; - public Map depthMaxFrame= new HashMap(); + public Map depthMaxFrame = new HashMap<>(); public int getMaxDepth() { int max_depth = 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java index 9e0469723..e6f4b057c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.graph.model; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -46,7 +47,7 @@ public class IntegerValueItem extends GraphTargetItem { @Override public Object getResult() { - return Double.valueOf(intValue); + return (double) intValue; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 2f00d24ad..a67603dd0 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -30,10 +30,7 @@ import com.jpexs.decompiler.flash.console.ContextMenuTools; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; import com.jpexs.decompiler.flash.tags.base.FontTag; -import com.jpexs.decompiler.flash.timeline.Timeline; -import com.jpexs.decompiler.flash.timeline.TweenDetector; import com.jpexs.decompiler.flash.treeitems.SWFList; -import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -53,7 +50,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.geom.AffineTransform; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 6a2f78fb1..4bee16386 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -178,7 +178,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi public void exec() { HashMap args = new HashMap<>(); args.put(0, new Object()); //object "this" - args.put(1, new Long(466561)); //param1 + args.put(1, 466561L); //param1 Object o = abc.bodies.get(bodyIndex).getCode().execute(args, abc.constants); View.showMessageDialog(this, "Returned object:" + o.toString()); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java b/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java index 4c7ec0833..225f8ed14 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java @@ -1,128 +1,128 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui.abc; - -import com.jpexs.decompiler.flash.gui.AppDialog; -import com.jpexs.decompiler.flash.gui.View; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Hashtable; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSlider; - -/** - * - * @author JPEXS - */ -public class DeobfuscationDialog extends AppDialog implements ActionListener { - - static final String ACTION_OK = "OK"; - static final String ACTION_CANCEL = "CANCEL"; - - public JCheckBox processAllCheckbox = new JCheckBox(translate("processallclasses")); - public JSlider codeProcessingLevel; - public boolean ok = false; - public static final int LEVEL_REMOVE_DEAD_CODE = 1; - public static final int LEVEL_REMOVE_TRAPS = 2; - public static final int LEVEL_RESTORE_CONTROL_FLOW = 3; - - @SuppressWarnings("unchecked") - public DeobfuscationDialog() { - setDefaultCloseOperation(HIDE_ON_CLOSE); - setSize(new Dimension(330, 270)); - setTitle(translate("dialog.title")); - Container cp = getContentPane(); - cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS)); - codeProcessingLevel = new JSlider(JSlider.VERTICAL, 1, 3, 3); - codeProcessingLevel.setMajorTickSpacing(1); - codeProcessingLevel.setPaintTicks(true); - codeProcessingLevel.setMinorTickSpacing(1); - codeProcessingLevel.setSnapToTicks(true); - JLabel lab1 = new JLabel(translate("deobfuscation.level")); - //lab1.setBounds(30, 0, getWidth() - 60, 25); - lab1.setAlignmentX(0.5f); - cp.add(lab1); - Hashtable labelTable = new Hashtable(); - //labelTable.put(new Integer(LEVEL_NONE), new JLabel("None")); - - labelTable.put(new Integer(LEVEL_REMOVE_DEAD_CODE), new JLabel(translate("deobfuscation.removedeadcode"))); - labelTable.put(new Integer(LEVEL_REMOVE_TRAPS), new JLabel(translate("deobfuscation.removetraps"))); - labelTable.put(new Integer(LEVEL_RESTORE_CONTROL_FLOW), new JLabel(translate("deobfuscation.restorecontrolflow"))); - codeProcessingLevel.setLabelTable(labelTable); - - codeProcessingLevel.setPaintLabels(true); - codeProcessingLevel.setAlignmentX(Component.CENTER_ALIGNMENT); - //codeProcessingLevel.setSize(300, 200); - - //codeProcessingLevel.setBounds(30, 25, getWidth() - 60, 125); - codeProcessingLevel.setAlignmentX(0.5f); - add(codeProcessingLevel); - //processAllCheckbox.setBounds(50, 150, getWidth() - 100, 25); - processAllCheckbox.setAlignmentX(0.5f); - add(processAllCheckbox); - - processAllCheckbox.setSelected(true); - - JButton cancelButton = new JButton(translate("button.cancel")); - cancelButton.addActionListener(this); - cancelButton.setActionCommand(ACTION_CANCEL); - JButton okButton = new JButton(translate("button.ok")); - okButton.addActionListener(this); - okButton.setActionCommand(ACTION_OK); - - JPanel buttonsPanel = new JPanel(new FlowLayout()); - buttonsPanel.add(okButton); - buttonsPanel.add(cancelButton); - buttonsPanel.setAlignmentX(0.5f); - cp.add(buttonsPanel); - - setModal(true); - View.centerScreen(this); - //View.setWindowIcon(this); - setIconImage(View.loadImage("deobfuscate16")); - } - - @Override - public void actionPerformed(ActionEvent e) { - switch (e.getActionCommand()) { - case ACTION_OK: - ok = true; - setVisible(false); - break; - case ACTION_CANCEL: - ok = false; - setVisible(false); - break; - } - } - - @Override - public void setVisible(boolean b) { - if (b) { - ok = false; - } - super.setVisible(b); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.abc; + +import com.jpexs.decompiler.flash.gui.AppDialog; +import com.jpexs.decompiler.flash.gui.View; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Hashtable; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSlider; + +/** + * + * @author JPEXS + */ +public class DeobfuscationDialog extends AppDialog implements ActionListener { + + static final String ACTION_OK = "OK"; + static final String ACTION_CANCEL = "CANCEL"; + + public JCheckBox processAllCheckbox = new JCheckBox(translate("processallclasses")); + public JSlider codeProcessingLevel; + public boolean ok = false; + public static final int LEVEL_REMOVE_DEAD_CODE = 1; + public static final int LEVEL_REMOVE_TRAPS = 2; + public static final int LEVEL_RESTORE_CONTROL_FLOW = 3; + + @SuppressWarnings("unchecked") + public DeobfuscationDialog() { + setDefaultCloseOperation(HIDE_ON_CLOSE); + setSize(new Dimension(330, 270)); + setTitle(translate("dialog.title")); + Container cp = getContentPane(); + cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS)); + codeProcessingLevel = new JSlider(JSlider.VERTICAL, 1, 3, 3); + codeProcessingLevel.setMajorTickSpacing(1); + codeProcessingLevel.setPaintTicks(true); + codeProcessingLevel.setMinorTickSpacing(1); + codeProcessingLevel.setSnapToTicks(true); + JLabel lab1 = new JLabel(translate("deobfuscation.level")); + //lab1.setBounds(30, 0, getWidth() - 60, 25); + lab1.setAlignmentX(0.5f); + cp.add(lab1); + Hashtable labelTable = new Hashtable<>(); + //labelTable.put(LEVEL_NONE, new JLabel("None")); + + labelTable.put(LEVEL_REMOVE_DEAD_CODE, new JLabel(translate("deobfuscation.removedeadcode"))); + labelTable.put(LEVEL_REMOVE_TRAPS, new JLabel(translate("deobfuscation.removetraps"))); + labelTable.put(LEVEL_RESTORE_CONTROL_FLOW, new JLabel(translate("deobfuscation.restorecontrolflow"))); + codeProcessingLevel.setLabelTable(labelTable); + + codeProcessingLevel.setPaintLabels(true); + codeProcessingLevel.setAlignmentX(Component.CENTER_ALIGNMENT); + //codeProcessingLevel.setSize(300, 200); + + //codeProcessingLevel.setBounds(30, 25, getWidth() - 60, 125); + codeProcessingLevel.setAlignmentX(0.5f); + add(codeProcessingLevel); + //processAllCheckbox.setBounds(50, 150, getWidth() - 100, 25); + processAllCheckbox.setAlignmentX(0.5f); + add(processAllCheckbox); + + processAllCheckbox.setSelected(true); + + JButton cancelButton = new JButton(translate("button.cancel")); + cancelButton.addActionListener(this); + cancelButton.setActionCommand(ACTION_CANCEL); + JButton okButton = new JButton(translate("button.ok")); + okButton.addActionListener(this); + okButton.setActionCommand(ACTION_OK); + + JPanel buttonsPanel = new JPanel(new FlowLayout()); + buttonsPanel.add(okButton); + buttonsPanel.add(cancelButton); + buttonsPanel.setAlignmentX(0.5f); + cp.add(buttonsPanel); + + setModal(true); + View.centerScreen(this); + //View.setWindowIcon(this); + setIconImage(View.loadImage("deobfuscate16")); + } + + @Override + public void actionPerformed(ActionEvent e) { + switch (e.getActionCommand()) { + case ACTION_OK: + ok = true; + setVisible(false); + break; + case ACTION_CANCEL: + ok = false; + setVisible(false); + break; + } + } + + @Override + public void setVisible(boolean b) { + if (b) { + ok = false; + } + super.setVisible(b); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java index 51bed4a2a..838711e1e 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java @@ -1,303 +1,303 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui.generictageditors; - -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author JPEXS - */ -public class ReflectionTools { - - public static Object getValue(Object obj, Field field, int index) throws IllegalArgumentException, IllegalAccessException { - if (getFieldSubSize(obj, field) <= index) { - return null; - } - Object value = field.get(obj); - if (List.class.isAssignableFrom(field.getType())) { - return ((List) value).get(index); - } - - if (field.getType().isArray()) { - return Array.get(value, index); - } - - return value; - } - - public static boolean needsIndex(Field field) { - if (List.class.isAssignableFrom(field.getType())) { - return true; - } else if (field.getType().isArray()) { - return true; - } - return false; - } - - @SuppressWarnings("unchecked") - public static int getFieldSubSize(Object obj, Field field) { - Object val; - try { - val = field.get(obj); - } catch (IllegalArgumentException | IllegalAccessException ex) { - return 0; - } - if (List.class.isAssignableFrom(field.getType())) { - return ((List) val).size(); - } else if (field.getType().isArray()) { - return Array.getLength(val); - } - return 0; - } - - @SuppressWarnings("unchecked") - public static void setValue(Object obj, Field field, int index, Object newValue) throws IllegalArgumentException, IllegalAccessException { - Object value = field.get(obj); - if (needsIndex(field) && index >= getFieldSubSize(obj, field)) { //outofbounds, ignore - return; - } - if (List.class.isAssignableFrom(field.getType())) { - ((List) value).set(index, newValue); - } else if (field.getType().isArray()) { - Array.set(value, index, newValue); - } else { - field.set(obj, newValue); - } - } - - public static boolean canInstantiate(Class cls) { - if (cls.isInterface()) { - return false; - } - if (Modifier.isAbstract(cls.getModifiers())) { - return false; - } - return true; - } - - public static boolean canAddToField(Object object, Field field) { - if (List.class.isAssignableFrom(field.getType())) { - - ParameterizedType listType = (ParameterizedType) field.getGenericType(); - Class parameterClass = (Class) listType.getActualTypeArguments()[0]; - return canInstantiate(parameterClass); - } - - if (field.getType().isArray()) { - Object arrValue; - try { - arrValue = field.get(object); - } catch (IllegalArgumentException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - Class componentClass = arrValue.getClass().getComponentType(); - if (componentClass.isPrimitive()) { - return true; - } - return canInstantiate(componentClass); - } - return false; - - } - - public static Object newInstanceOf(Class cls) throws InstantiationException, IllegalAccessException { - if (cls == Integer.class || cls == int.class) { - return new Integer(0); - } else if (cls == Float.class || cls == float.class) { - return new Float(0.0f); - } else if (cls == Double.class || cls == double.class) { - return new Double(0); - } else if (cls == Long.class || cls == long.class) { - return new Long(0L); - } - if (cls.isInterface()) { - return null; - } - if (Modifier.isAbstract(cls.getModifiers())) { - return null; - } - return cls.newInstance(); - } - - @SuppressWarnings("unchecked") - public static boolean addToList(Object object, Field field, int index) { - if (!List.class.isAssignableFrom(field.getType())) { - return false; - } - List list; - try { - list = (List) field.get(object); - } catch (IllegalArgumentException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - ParameterizedType listType = (ParameterizedType) field.getGenericType(); - Class parameterClass = (Class) listType.getActualTypeArguments()[0]; - try { - Object val = newInstanceOf(parameterClass); - if (val == null) { - return false; - } - list.add(index, val); - } catch (InstantiationException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - return true; - } - - public static Class getFieldSubType(Object object, Field field) { - if (field.getType().isArray()) { - Object arrValue; - try { - arrValue = field.get(object); - return arrValue.getClass().getComponentType(); - } catch (IllegalArgumentException | IllegalAccessException ex) { - return null; - } - } - if (List.class.isAssignableFrom(field.getType())) { - ParameterizedType listType = (ParameterizedType) field.getGenericType(); - return (Class) listType.getActualTypeArguments()[0]; - } - return null; - } - - public static boolean addToArray(Object object, Field field, int index, boolean notnull) { - if (!field.getType().isArray()) { - return false; - } - Object arrValue; - try { - arrValue = field.get(object); - } catch (IllegalArgumentException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - Class componentClass = arrValue.getClass().getComponentType(); - Object val = null; - if (!componentClass.isPrimitive()) { - try { - val = newInstanceOf(componentClass); - } catch (InstantiationException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - if (val == null) { - return false; - } - } - - int originalSize = Array.getLength(arrValue); - Object copy = Array.newInstance(componentClass, originalSize + 1); - - //Copy items before - for (int i = 0; i < index; i++) { - Array.set(copy, i, Array.get(arrValue, i)); - } - if (val != null) { - Array.set(copy, index, val); - } - //Copy items after - for (int i = index; i < originalSize; i++) { - Array.set(copy, i + 1, Array.get(arrValue, i)); - } - try { - field.set(object, copy); - } catch (IllegalArgumentException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - return true; - } - - public static boolean addToField(Object object, Field field, int index, boolean notnull) { - if (List.class.isAssignableFrom(field.getType())) { - return addToList(object, field, index); - } - - if (field.getType().isArray()) { - return addToArray(object, field, index, notnull); - } - return false; - } - - public static boolean removeFromField(Object object, Field field, int index) { - if (List.class.isAssignableFrom(field.getType())) { - return removeFromList(object, field, index); - } - - if (field.getType().isArray()) { - return removeFromArray(object, field, index); - } - return false; - } - - public static boolean removeFromList(Object object, Field field, int index) { - List list; - try { - list = (List) field.get(object); - } catch (IllegalArgumentException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - if (index < 0 || index >= list.size()) { - return false; - } - list.remove(index); - return true; - } - - public static boolean removeFromArray(Object object, Field field, int index) { - Object arrValue; - try { - arrValue = field.get(object); - } catch (IllegalArgumentException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - Class componentClass = arrValue.getClass().getComponentType(); - int originalSize = Array.getLength(arrValue); - Object copy = Array.newInstance(componentClass, originalSize - 1); - int pos = 0; - //copy all before index - for (int i = 0; i < index; i++) { - Array.set(copy, pos, Array.get(arrValue, i)); - pos++; - } - //copy all after index - for (int i = index + 1; i < originalSize; i++) { - Array.set(copy, pos, Array.get(arrValue, i)); - pos++; - } - try { - field.set(object, copy); - } catch (IllegalArgumentException | IllegalAccessException ex) { - Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - return true; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.generictageditors; + +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class ReflectionTools { + + public static Object getValue(Object obj, Field field, int index) throws IllegalArgumentException, IllegalAccessException { + if (getFieldSubSize(obj, field) <= index) { + return null; + } + Object value = field.get(obj); + if (List.class.isAssignableFrom(field.getType())) { + return ((List) value).get(index); + } + + if (field.getType().isArray()) { + return Array.get(value, index); + } + + return value; + } + + public static boolean needsIndex(Field field) { + if (List.class.isAssignableFrom(field.getType())) { + return true; + } else if (field.getType().isArray()) { + return true; + } + return false; + } + + @SuppressWarnings("unchecked") + public static int getFieldSubSize(Object obj, Field field) { + Object val; + try { + val = field.get(obj); + } catch (IllegalArgumentException | IllegalAccessException ex) { + return 0; + } + if (List.class.isAssignableFrom(field.getType())) { + return ((List) val).size(); + } else if (field.getType().isArray()) { + return Array.getLength(val); + } + return 0; + } + + @SuppressWarnings("unchecked") + public static void setValue(Object obj, Field field, int index, Object newValue) throws IllegalArgumentException, IllegalAccessException { + Object value = field.get(obj); + if (needsIndex(field) && index >= getFieldSubSize(obj, field)) { //outofbounds, ignore + return; + } + if (List.class.isAssignableFrom(field.getType())) { + ((List) value).set(index, newValue); + } else if (field.getType().isArray()) { + Array.set(value, index, newValue); + } else { + field.set(obj, newValue); + } + } + + public static boolean canInstantiate(Class cls) { + if (cls.isInterface()) { + return false; + } + if (Modifier.isAbstract(cls.getModifiers())) { + return false; + } + return true; + } + + public static boolean canAddToField(Object object, Field field) { + if (List.class.isAssignableFrom(field.getType())) { + + ParameterizedType listType = (ParameterizedType) field.getGenericType(); + Class parameterClass = (Class) listType.getActualTypeArguments()[0]; + return canInstantiate(parameterClass); + } + + if (field.getType().isArray()) { + Object arrValue; + try { + arrValue = field.get(object); + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + Class componentClass = arrValue.getClass().getComponentType(); + if (componentClass.isPrimitive()) { + return true; + } + return canInstantiate(componentClass); + } + return false; + + } + + public static Object newInstanceOf(Class cls) throws InstantiationException, IllegalAccessException { + if (cls == Integer.class || cls == int.class) { + return 0; + } else if (cls == Float.class || cls == float.class) { + return 0.0f; + } else if (cls == Double.class || cls == double.class) { + return (double) 0; + } else if (cls == Long.class || cls == long.class) { + return 0L; + } + if (cls.isInterface()) { + return null; + } + if (Modifier.isAbstract(cls.getModifiers())) { + return null; + } + return cls.newInstance(); + } + + @SuppressWarnings("unchecked") + public static boolean addToList(Object object, Field field, int index) { + if (!List.class.isAssignableFrom(field.getType())) { + return false; + } + List list; + try { + list = (List) field.get(object); + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + ParameterizedType listType = (ParameterizedType) field.getGenericType(); + Class parameterClass = (Class) listType.getActualTypeArguments()[0]; + try { + Object val = newInstanceOf(parameterClass); + if (val == null) { + return false; + } + list.add(index, val); + } catch (InstantiationException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + return true; + } + + public static Class getFieldSubType(Object object, Field field) { + if (field.getType().isArray()) { + Object arrValue; + try { + arrValue = field.get(object); + return arrValue.getClass().getComponentType(); + } catch (IllegalArgumentException | IllegalAccessException ex) { + return null; + } + } + if (List.class.isAssignableFrom(field.getType())) { + ParameterizedType listType = (ParameterizedType) field.getGenericType(); + return (Class) listType.getActualTypeArguments()[0]; + } + return null; + } + + public static boolean addToArray(Object object, Field field, int index, boolean notnull) { + if (!field.getType().isArray()) { + return false; + } + Object arrValue; + try { + arrValue = field.get(object); + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + Class componentClass = arrValue.getClass().getComponentType(); + Object val = null; + if (!componentClass.isPrimitive()) { + try { + val = newInstanceOf(componentClass); + } catch (InstantiationException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + if (val == null) { + return false; + } + } + + int originalSize = Array.getLength(arrValue); + Object copy = Array.newInstance(componentClass, originalSize + 1); + + //Copy items before + for (int i = 0; i < index; i++) { + Array.set(copy, i, Array.get(arrValue, i)); + } + if (val != null) { + Array.set(copy, index, val); + } + //Copy items after + for (int i = index; i < originalSize; i++) { + Array.set(copy, i + 1, Array.get(arrValue, i)); + } + try { + field.set(object, copy); + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + return true; + } + + public static boolean addToField(Object object, Field field, int index, boolean notnull) { + if (List.class.isAssignableFrom(field.getType())) { + return addToList(object, field, index); + } + + if (field.getType().isArray()) { + return addToArray(object, field, index, notnull); + } + return false; + } + + public static boolean removeFromField(Object object, Field field, int index) { + if (List.class.isAssignableFrom(field.getType())) { + return removeFromList(object, field, index); + } + + if (field.getType().isArray()) { + return removeFromArray(object, field, index); + } + return false; + } + + public static boolean removeFromList(Object object, Field field, int index) { + List list; + try { + list = (List) field.get(object); + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + if (index < 0 || index >= list.size()) { + return false; + } + list.remove(index); + return true; + } + + public static boolean removeFromArray(Object object, Field field, int index) { + Object arrValue; + try { + arrValue = field.get(object); + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + Class componentClass = arrValue.getClass().getComponentType(); + int originalSize = Array.getLength(arrValue); + Object copy = Array.newInstance(componentClass, originalSize - 1); + int pos = 0; + //copy all before index + for (int i = 0; i < index; i++) { + Array.set(copy, pos, Array.get(arrValue, i)); + pos++; + } + //copy all after index + for (int i = index + 1; i < originalSize; i++) { + Array.set(copy, pos, Array.get(arrValue, i)); + pos++; + } + try { + field.set(object, copy); + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + return true; + } +}