Categories
Hints

Java String.isEmpty interrupts method call or thread

Does your call of String.isEmpty in your code cause strange behaviour such as:

– sudden interruption of method call (as if return was called)

– thread interruption

?

The problem is quite simple – you had build your code using JDK 1.6 with language compatibility set to previous version (1.4, 1.5) hoping the compiler would use the correct classes. This is, however, not true.

When you use the version switch the current JDK classes signatures are used. That means isEmpty is present as method of String class in 1.6. It is not present in previous releases.

Solution: Remove call of isEmpty and use the JDK you need without language compatibility to build against required version.