I'm modifying a Java class bytecode through an hexadecimal editor, and I want to force a method to always return true.
- Replaced all its bytecode with nops to keep the size intact (original size is 1890).
- Execute a popto restore the stack height since it receives an argument.
- Return true with iconst_1followed byireturn.
public static boolean test(java.lang.String);
        descriptor: (Ljava/lang/String;)Z
        flags: ACC_PUBLIC, ACC_STATIC
        Code:
          stack=5, locals=12, args_size=1
             0: nop
             1: nop
             2: nop
             3: nop
             4: nop
             [...]
          1886: nop
          1887: nop
          1888: pop
          1889: iconst_1
          1890: ireturn
But when executing it, I'm getting the following error
java.lang.VerifyError: (class: com/example/test/TestBytecode, method: test signature: (Ljava/lang/String;)Z) Inconsistent stack height 0 != 1
NOTE: with or without pop the result is exactly the same.
 
     
     
     
    