diff --git a/jode/jode/bytecode/TypeSignature.java b/jode/jode/bytecode/TypeSignature.java index 53e9b56..566fba6 100644 --- a/jode/jode/bytecode/TypeSignature.java +++ b/jode/jode/bytecode/TypeSignature.java @@ -216,6 +216,28 @@ public class TypeSignature { return params; } + public static Object getDefaultValue(String typeSig) { + switch(typeSig.charAt(0)) { + case 'Z': + case 'B': + case 'S': + case 'C': + case 'I': + return new Integer(0); + case 'J': + return new Long(0L); + case 'D': + return new Double(0.0); + case 'F': + return new Float(0.0F); + case 'L': + case '[': + return null; + default: + throw new IllegalArgumentException(typeSig); + } + } + /** * Returns the number of words, an object of the given simple type * signature takes. diff --git a/jode/jode/obfuscator/ConstantRuntimeEnvironment.java b/jode/jode/obfuscator/ConstantRuntimeEnvironment.java index bbd66f8..ebf7893 100644 --- a/jode/jode/obfuscator/ConstantRuntimeEnvironment.java +++ b/jode/jode/obfuscator/ConstantRuntimeEnvironment.java @@ -222,25 +222,6 @@ public class ConstantRuntimeEnvironment extends SimpleRuntimeEnvironment { interpreter = new Interpreter(this); } - public static Object getDefaultValue(String typeSig) { - switch(typeSig.charAt(0)) { - case 'Z': - case 'B': - case 'S': - case 'C': - case 'I': - return new Integer(0); - case 'J': - return new Long(0L); - case 'D': - return new Double(0.0); - case 'F': - return new Float(0.0F); - default: - return null; - } - } - public Object getField(Reference ref, Object obj) throws InterpreterException { if (isWhite(ref)) diff --git a/jode/jode/obfuscator/modules/ConstantAnalyzer.java b/jode/jode/obfuscator/modules/ConstantAnalyzer.java index c5672fa..cd94dff 100644 --- a/jode/jode/obfuscator/modules/ConstantAnalyzer.java +++ b/jode/jode/obfuscator/modules/ConstantAnalyzer.java @@ -1479,7 +1479,7 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { } else { Object obj = fi.getConstant(); if (obj == null) - obj = runtime.getDefaultValue(ref.getType()); + obj = TypeSignature.getDefaultValue(ref.getType()); ConstantInfo constInfo = new ConstantInfo(CONSTANT, obj); constantInfos.put(instr, constInfo); result = new ConstValue(obj);