Is there any way to check, currently which Strings are there in the String pool.
Can I programmatically list all Strings exist in pool?
or
Any IDE already have this kind of plugins ?
Is there any way to check, currently which Strings are there in the String pool.
Can I programmatically list all Strings exist in pool?
or
Any IDE already have this kind of plugins ?
You are not able to access the string pool from Java code, at least not in the HotSpot implementation of Java VM.
String pool in Java is implemented using string interning. According to JLS §3.10.5:
And according to JLS §15.28:
String.intern
is a native method, as we can see in its declaration in OpenJDK:The native code for this method calls
JVM_InternString
function.That is, string interning is implemented using native code, and there's no Java API to access the string pool directly. You may, however, be able to write a native method yourself for this purpose.