I have a large (legacy) application that I have to make a fix in, with terrible code structure and so much code smell that I'm choking. I can't really figure out where a string in the gui is populated. Therefore it would be nice if i somehow could have an expression/breakpoint once ANY string (I don't know the name of the variable, or where it is) is equal to "foobar" so I can backtrack from there.
So, what am I looking for? :)
This trick works as long as the string that you want to find isn't hard-coded in any way. If the string was getting passed to the compiler, then this trick may not work.
java.lang.String
class file. Your IDE should be automatically show the source-code for this class.char[]
field variable. The variable name may vary for each JDK. On my machine it is private final char value[];
.Put a condition on this breakpoint, e.g.:
value!=null && value.length==6 && value[0]=='f' && value[1]=='o' && value[2]=='o' ....
Please note that the performance will be slower due to this breakpoint.
I have tested this on a simple application that read the string from a file, and the breakpoint is being hit properly when the file is being read into a string.