Hello. No, you can't, Java doesn't provide such mechanism in it's sdk. Only via profiler, with heap dumps, and I'm still not totally sure that it's possible. Anyway, why the hell you need the full contents of the pool? I can suggest you a simple way to check whether the string is in the pool: boolean isInPool = (str.intern() == str); Since some Java version (8 or 7) string pool is stored in heap like all user objects and is a target for garbage collection, i.e. string that was temporarily added to pool will be gc'd once. Beware of using following approach on old jvms, as pool is sorted in permgen that is if fixed size
Обсуждают сегодня