The question does not have a good answer.
The string pool used by String.intern is based on a weak map, and there is no way to synchronize the user code on this map, so any answer you receive may not be acceptable before you can use it.
Even string literals can disappear from the inner pool. Class unloading can cause string literals to become unavailable, and since loading classes depends on the GC, this is unpredictable.
I repeat, very little useful information can be obtained by analyzing the internal pool, with the exception of the total amount of memory, and JVMs, as a rule, have more efficient ways to access them through their logging and debugging.
source share