The below java(android) source works on debug build, release(signed) build, and allatori obsfucation build(signed).
SomeActivity.java
//Sends event to an async event processing class
public void emitEvent(){
EventHandlerClass.emit("myEvent");
}
....
//Recieves callback from EventHandlerClass
public void handleEvent(Event event){//Event object has a String field named eventField;
if(event.eventField == "myEvent"){
}else if (event.eventField == "myEvent2"){
.......
}
}
EventHandlerClass.java
public void emit(String eventName){
...//process async event
eventSource.handleEvent(new Event(eventName));
}
As you can see, the callback gets a string and compares it with the "==" operator. Somehow, this works, but I really don't know why this should work. As far as I know, the "==" should be a reference comparison.
This means that the 'event.eventField' has the same reference as the hardcoded String "myEvent". Is there a special rule on java for storing hardcoded Strings?