The action of caching Strings in a shared pool is technically called interningstring literals where "to intern" means "to cache in a pool that the String class stores internally" and "string literal" means "a unique instance of a String (like "Hello")."
I'm not sure if I am misreading the last line but the reason for interning string literals is explicitly to optimize for safely sharing String values in a given JVM. There should be no possible negative side effects as a result.
A couple of minor additional details:
The action of caching Strings in a shared pool is technically called interning string literals where "to intern" means "to cache in a pool that the String class stores internally" and "string literal" means "a unique instance of a String (like "Hello")."
I'm not sure if I am misreading the last line but the reason for interning string literals is explicitly to optimize for safely sharing String values in a given JVM. There should be no possible negative side effects as a result.
JSR 3.10.5 is a great reference for more detail.