diff --git a/bindings/java/java/src/main/java/org/ethereum/evmc/Host.java b/bindings/java/java/src/main/java/org/ethereum/evmc/Host.java index 3818e54c2..21a5df080 100644 --- a/bindings/java/java/src/main/java/org/ethereum/evmc/Host.java +++ b/bindings/java/java/src/main/java/org/ethereum/evmc/Host.java @@ -79,10 +79,10 @@ static ByteBuffer copy_code(int context_index, byte[] address, int code_offset) if (code != null && code_offset > 0 && code_offset < code.length) { int length = code.length - code_offset; - return ByteBuffer.wrap(code, 0, length); + return ByteBuffer.allocateDirect(length).put(code, code_offset, length); } - return ByteBuffer.wrap(new byte[0]); + return ByteBuffer.allocateDirect(0); } /** Selfdestruct callback function. */