I use Krakatau to edit java code.
class test{
public boolean Func2(String text)
{
if(text=="aaaaaa")
return true;
return false;
}
}
When I compile it I get this java bytecode
.version 53 0
.class super [3]
.super [4]
.method [5] : [6]
.attribute [7] .code stack 1 locals 1
L0: aload_0
L1: invokespecial [1]
L4: return
L5:
.attribute [8] .linenumbertable
L0 1
.end linenumbertable
.end code
.end method
.method public [9] : [10]
.attribute [7] .code stack 2 locals 2
**L0: aload_1
L1: ldc [2]
L3: if_acmpne L8
L6: iconst_1
L7: ireturn**
.stack same
L8: iconst_0
L9: ireturn
L10:
.attribute [8] .linenumbertable
L0 5
L6 6
L8 7
.end linenumbertable
.attribute [11] .stackmaptable
.end code
.end method
.attribute [12] .sourcefile [13]
.const [1] = Method [4] [14]
.const [2] = String [15]
.const [3] = Class [16]
.const [4] = Class [17]
.const [5] = Utf8 <init>
.const [6] = Utf8 ()V
.const [7] = Utf8 Code
.const [8] = Utf8 LineNumberTable
.const [9] = Utf8 Func2
.const [10] = Utf8 (Ljava/lang/String;)Z
.const [11] = Utf8 StackMapTable
.const [12] = Utf8 SourceFile
.const [13] = Utf8 'test.java'
.const [14] = NameAndType [5] [6]
.const [15] = Utf8 aaaaaa
.const [16] = Utf8 test
.const [17] = Utf8 java/lang/Object
.end class
Now I want to replace text=="aaaaaa"
with text.equals("ABCD")
I know I need to reaplce
L3: if_acmpne L8
with
invokevirtual java/lang/String/equals(Ljava/lang/Object;)Z
ifeq (the line I want to jump)
But Krakatau not get this line
invokevirtual java/lang/String/equals(Ljava/lang/Object;)Z
what is the right and easy way to replace ==
with equals
with Krakatau? I dont want to recompile my code .