java: add close() method to avoid some unknown crash caused by finallize() on Ubuntu 14.04. FIXME

This commit is contained in:
Nguyen Anh Quynh 2014-11-19 10:58:31 +08:00
parent fadbddcbf8
commit 0ea529a6f3
10 changed files with 34 additions and 1 deletions

View File

@ -170,6 +170,9 @@ public class Test {
all_insn[i].mnemonic, all_insn[i].opStr));
}
System.out.printf("0x%x:\n\n", all_insn[all_insn.length-1].address + all_insn[all_insn.length-1].size);
// Close when done
cs.close();
}
}
}

View File

@ -131,6 +131,9 @@ public class TestArm {
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}

View File

@ -117,6 +117,9 @@ public class TestArm64 {
}
System.out.printf("0x%x: \n\n", all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size);
// Close when done
cs.close();
}
}

View File

@ -82,6 +82,9 @@ public class TestMips {
}
System.out.printf("0x%x:\n\n", all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size);
// Close when done
cs.close();
}
}

View File

@ -87,6 +87,9 @@ public class TestPpc {
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}

View File

@ -88,6 +88,9 @@ public class TestSparc {
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}

View File

@ -87,6 +87,9 @@ public class TestSystemz {
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}

View File

@ -163,6 +163,9 @@ public class TestX86 {
}
System.out.printf("0x%x:\n\n", all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size);
// Close when done
cs.close();
}
}

View File

@ -80,6 +80,9 @@ public class TestXcore {
System.out.println();
}
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
// Close when done
cs.close();
}
}

View File

@ -419,7 +419,13 @@ public class Capstone {
// destructor automatically caled at destroyed time.
protected void finalize() {
cs.cs_close(ns.handleRef);
// FIXME: crashed on Ubuntu 14.04 64bit, OpenJDK java 1.6.0_33
// cs.cs_close(ns.handleRef);
}
// destructor automatically caled at destroyed time.
public int close() {
return cs.cs_close(ns.handleRef);
}
// disassemble until either no more code, or encounter broken insn.