diff --git a/bindings/java/capstone/Capstone.java b/bindings/java/capstone/Capstone.java index a15fc63944..a5468e0b03 100644 --- a/bindings/java/capstone/Capstone.java +++ b/bindings/java/capstone/Capstone.java @@ -358,6 +358,8 @@ protected class NativeStruct { private NativeLongByReference handleRef; } + private static final CsInsn[] EMPTY_INSN = new CsInsn[0]; + protected NativeStruct ns; // for memory retention private CS cs; public int arch; @@ -434,7 +436,7 @@ public int close() { * * @param code The source machine code bytes. * @param address The address of the first machine code byte. - * @return the array of successfully disassembled instructions, null if no instruction could be disassembled. + * @return the array of successfully disassembled instructions, empty if no instruction could be disassembled. */ public CsInsn[] disasm(byte[] code, long address) { return disasm(code, address, 0); @@ -447,7 +449,7 @@ public CsInsn[] disasm(byte[] code, long address) { * @param code The source machine code bytes. * @param address The address of the first machine code byte. * @param count The maximum number of instructions to disassemble, 0 for no maximum. - * @return the array of successfully disassembled instructions, null if no instruction could be disassembled. + * @return the array of successfully disassembled instructions, empty if no instruction could be disassembled. */ public CsInsn[] disasm(byte[] code, long address, long count) { PointerByReference insnRef = new PointerByReference(); @@ -455,7 +457,7 @@ public CsInsn[] disasm(byte[] code, long address, long count) { NativeLong c = cs.cs_disasm(ns.csh, code, new NativeLong(code.length), address, new NativeLong(count), insnRef); if (0 == c.intValue()) { - return null; + return EMPTY_INSN; } Pointer p = insnRef.getValue();