Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define IntelliJ java breakpoint on first construction of a String

I am debugging into some pretty complex software. Some string is constructed and replaced with a modified form in several different places (the stack is pages long), but I want to find out quickly where the String with a given value is first time constructed. Conditional breakpoints seem to be tricky on this as the condition itself constructs the string I want to detect...

Any ideas? I am using IntelliJ

like image 880
Kai Avatar asked Dec 31 '25 13:12

Kai


1 Answers

To avoid creating a new string inside the condition, you can compare the content, not the String objects. For example like this:

Arrays.equals(str.toCharArray(), new char[]{'c', 'o', 'n', 't', 'e', 'n', 't'});

like image 96
Egor Avatar answered Jan 03 '26 04:01

Egor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!