常见反编译错误
来源:互联网 发布:网络污蔑 编辑:程序博客网 时间:2024/06/07 06:28
常见错误 一
try--catch--catch--finally
public class test
{
public HashMap f5()
{
Connection conn = null;
HashMap map = new HashMap();
try
{
Class.forName("");
conn = DriverManager.getConnection("jdbc:odbc:");
PreparedStatement pstmt = conn.prepareStatement("select * from table");
pstmt.setString(1, "param");
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
String columnVallue = rs.getString("column");
map.put(columnVallue, "");
}
return map;
}
catch (ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (SQLException sqlce)
{
sqlce.printStackTrace();
}
}
}
return null;
}
}
反编译
public class test
{
public test()
{
}
public HashMap f5()
{
Connection conn;
HashMap map;
conn = null; ---------声明和初始化分开了
map = new HashMap();
HashMap hashmap; ---------多了hashmap ,是为了逻辑的需要
Class.forName(""); ---------缺少try,看不出try入口在这里
conn = DriverManager.getConnection("jdbc:odbc:");
PreparedStatement pstmt = conn.prepareStatement("select * from table");
pstmt.setString(1, "param");
String columnVallue; ---------缺少while,且把块里的声明和初始化分开了
for(ResultSet rs = pstmt.executeQuery(); rs.next(); map.put(columnVallue, "")) ---------while变成for,逻辑也适当改变了
columnVallue = rs.getString("column");
hashmap = map;
if(conn != null)
try
{
conn.close();
}
catch(SQLException sqlce)
{
sqlce.printStackTrace();
}
return hashmap; ---------原来try里的return跑这里来了,这是原try块结束点
ClassNotFoundException cnfe; ---------第一个catch块异常
cnfe;
cnfe.printStackTrace();
if(conn != null) ---------if没有块{},break为if块结束标志
try
{
conn.close();
}
catch(SQLException sqlce)
{
sqlce.printStackTrace();
}
break MISSING_BLOCK_LABEL_188; ---------这是栈标志,字面意思是"信息块标签",反编译时,把各路径块存入堆栈,然后依次弹出,这表示为一个语句块的分界点,也就是说有一个“}”
SQLException sqle; ---------第二个catch块异常
sqle;
sqle.printStackTrace();
if(conn != null) ---------if没有块,break为if块结束标志
try ---------finally块的代码多次出现是因为他在多条路径中,故多次从堆栈弹出
{
conn.close();
}
catch(SQLException sqlce)
{
sqlce.printStackTrace();
}
break MISSING_BLOCK_LABEL_188; ---------又一个块结束标志,第二个catch块结束标志
Exception exception; ---------finally块总是以Exception 为标志
exception;
if(conn != null)
try
{
conn.close();
}
catch(SQLException sqlce)
{
sqlce.printStackTrace();
}
throw exception;
return null; ---------finally块后的return,在throw后面
}
}
常见错误二
try--catch--finally+if--else
public class test
{
public String f4()
{
Integer i = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try
{
i =Integer.parseInt(br.readLine());
if (i.intValue() > 0)
{
System.out.println(1);
return String.valueOf(1);
}
else if(i.intValue() == 0)
{
System.out.println(0);
return String.valueOf(0);
}else
{
System.err.println(-1);
return String.valueOf(-1);
}
}
catch (Exception dae)
{
System.err.println("有错");
}
finally
{
if (i.intValue() == 3 )
{
try
{
i = new Integer(3);
}
catch (Exception sqlce)
{
sqlce.printStackTrace();
}
}
}
return String.valueOf(i);
}
}
反编译:
public class test
{
public test()
{
}
public String f4()
{
Integer i;
BufferedReader br; ---------变量声明和初始化分开了
i = Integer.valueOf(0);
br = new BufferedReader(new InputStreamReader(System.in));
String s;
i = Integer.valueOf(Integer.parseInt(br.readLine()));
if(i.intValue() <= 0) ---------if块遗失,这里到return为if块,但需剔除其中finally块的代码
break MISSING_BLOCK_LABEL_84; ---------注意:全部if的条件取反了,即==变!=,&&变||,<变>=...
System.out.println(1);
s = String.valueOf(1);
if(i.intValue() == 3) ---------因为if到finally为一条路径,故有finally块代码
try
{
i = new Integer(3);
}
catch(Exception sqlce)
{
sqlce.printStackTrace();
}
return s;
if(i.intValue() != 0) ---------第二个if块,可见反编译吧if--else if--else拆散为多个单独的if块了
break MISSING_BLOCK_LABEL_134;
System.out.println(0);
s = String.valueOf(0);
if(i.intValue() == 3)
try
{
i = new Integer(3);
}
catch(Exception sqlce)
{
sqlce.printStackTrace();
}
return s;
System.err.println(-1); ---------最后一个else没有变为if,而是直接写出逻辑,和前面if块相似
s = String.valueOf(-1);
if(i.intValue() == 3)
try
{
i = new Integer(3);
}
catch(Exception sqlce)
{
sqlce.printStackTrace();
}
return s;
Exception dae; ---------catch块
dae;
System.err.println("/u6709/u9519");
if(i.intValue() == 3)
try
{
i = new Integer(3);
}
catch(Exception sqlce)
{
sqlce.printStackTrace();
}
break MISSING_BLOCK_LABEL_248; ---------catch块结束
Exception exception; ---------finally块
exception;
if(i.intValue() == 3)
try
{
i = new Integer(3);
}
catch(Exception sqlce)
{
sqlce.printStackTrace();
}
throw exception;
return String.valueOf(i); ---------finally后的语句
}
}
常见错误三
多个标记跳转(一般是while--for--if的嵌套)
public class Conn
{ //死循环
public static void main(String args[])
{
int[] list = new int[] { 1, 2, 3, 4 };
if (Boolean.getBoolean("sys")) {
System.out.println("sys");
} else {
check: while (true) {
for (int i = 0; i < list.length; i++) {
System.out.println(list[i]);
if (list[i] == 2) {
continue check;
}
}
break;
}
}
}
}
反编译:
public class Conn
{
public Conn() -----------自动生成无参构造函数
{
}
public static void main(String args[])
{
int list[] = { -----------改变数组声明方式
1, 2, 3, 4
};
if(!Boolean.getBoolean("sys")) goto _L2; else goto _L1 -----------if条件取反,if模块为_L1-->_L3-->OVER
_L1:
System.out.println("sys");
goto _L3 -----------注:_L3为结束点,if,else,for,while块的结束点,即 "}".
_L2:
int i = 0; -----------for循环条件被拆散,注意路径 _L2-->_L4-->_L6-->_L5,可还原
goto _L4
_L6:
System.out.println(list[i]);
if(list[i] != 2) goto _L5; else goto _L2 -----------标记 'L1--->L6'以栈方式存取
_L5:
i++; -----------注: i++在
_L4:
if(i < list.length) goto _L6; else goto _L3 -----------L2的条件初始化和这里的if,说明是一个for循环
_L3:
}
}
常见错误四
enum
public enum Test {
MERCURY (3.303e+23, 2.4397e6),
VENUS (4.869e+24, 6.0518e6),
EARTH (5.976e+24, 6.37814e6),
MARS (6.421e+23, 3.3972e6),
JUPITER (1.9e+27, 7.1492e7),
SATURN (5.688e+26, 6.0268e7),
URANUS (8.686e+25, 2.5559e7),
NEPTUNE (1.024e+26, 2.4746e7),
PLUTO (1.27e+22, 1.137e6);
private final double mass; // in kilograms
private final double radius; // in meters
Test(double mass, double radius) {
this.mass = mass;
this.radius = radius;
}
public double mass() { return mass; }
public double radius() { return radius; }
// universal gravitational constant (m 3 kg -1 s-2)
public static final double G = 6.67300E-11;
public double surfaceGravity() {
return G * mass / (radius * radius);
}
public double surfaceWeight(double otherMass) {
return otherMass * surfaceGravity();
}
public static void main(String[] args) {
double earthWeight = Double.parseDouble(args[0]);
double mass = earthWeight/EARTH.surfaceGravity();
for (Test p : Test.values())
System.out.printf("Your weight on %s is %f%n",
p, p.surfaceWeight(mass));
}
}
反编译:
public final class Test extends Enum
{
public static final Test MERCURY;
public static final Test VENUS;
public static final Test EARTH;
public static final Test MARS;
public static final Test JUPITER;
public static final Test SATURN;
public static final Test URANUS;
public static final Test NEPTUNE;
public static final Test PLUTO;
private final double mass;
private final double radius;
public static final double G = 6.6729999999999999E-011D;
private static final Test ENUM$VALUES[];
private Test(String s, int i, double mass, double radius)
{
super(s, i);
this.mass = mass;
this.radius = radius;
}
public double mass()
{
return mass;
}
public double radius()
{
return radius;
}
public double surfaceGravity()
{
return (6.6729999999999999E-011D * mass) / (radius * radius);
}
public double surfaceWeight(double otherMass)
{
return otherMass * surfaceGravity();
}
public static void main(String args[])
{
double earthWeight = Double.parseDouble(args[0]);
double mass = earthWeight / EARTH.surfaceGravity();
Test atest[];
int j = (atest = values()).length;
for(int i = 0; i < j; i++)
{
Test p = atest[i];
System.out.printf("Your weight on %s is %f%n", new Object[] {
p, Double.valueOf(p.surfaceWeight(mass))
});
}
}
public static Test[] values()
{
Test atest[];
int i;
Test atest1[];
System.arraycopy(atest = ENUM$VALUES, 0, atest1 = new Test[i = atest.length], 0, i);
return atest1;
}
public static Test valueOf(String s)
{
return (Test)Enum.valueOf(test/Test, s);
}
static
{
MERCURY = new Test("MERCURY", 0, 3.3030000000000001E+023D, 2439700D);
VENUS = new Test("VENUS", 1, 4.8690000000000001E+024D, 6051800D);
EARTH = new Test("EARTH", 2, 5.9760000000000004E+024D, 6378140D);
MARS = new Test("MARS", 3, 6.4209999999999999E+023D, 3397200D);
JUPITER = new Test("JUPITER", 4, 1.9000000000000001E+027D, 71492000D);
SATURN = new Test("SATURN", 5, 5.6879999999999998E+026D, 60268000D);
URANUS = new Test("URANUS", 6, 8.686E+025D, 25559000D);
NEPTUNE = new Test("NEPTUNE", 7, 1.0239999999999999E+026D, 24746000D);
PLUTO = new Test("PLUTO", 8, 1.2700000000000001E+022D, 1137000D);
ENUM$VALUES = (new Test[] {
MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO
});
}
}
- 常见反编译错误
- sothink swf decompiler反编译的常见错误
- apk反编译常见工具
- apk 反编译常见命令
- 反编译 错误提示解决方法
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 常见错误
- 机器视觉软件
- 关于/proc/self
- VS SDK 命令
- Ext.MessageBox工具类简介
- C++ 应用软件开发
- 常见反编译错误
- State 模式
- Python-1
- SAS的数据步和过程步以及书写规则
- 代码自动生成-宏带来的奇技淫巧
- emacs windows配置笔记
- yum下载下来的文件保存在
- fflush(stdin)
- Strategy 策略模式