Package org.apache.bcel.classfile
Class ConstantUtf8
java.lang.Object
org.apache.bcel.classfile.Constant
org.apache.bcel.classfile.ConstantUtf8
Extends the abstract
Constant to represent a reference to a UTF-8 encoded string.
The following system properties govern caching this class performs.
SYS_PROP_CACHE_MAX_ENTRIES(since 6.4): The size of the cache, by default 0, meaning caching is disabled.SYS_PROP_CACHE_MAX_ENTRY_SIZE(since 6.0): The maximum size of the values to cache, by default 200, 0 disables caching. Values larger than this are not cached.SYS_PROP_STATISTICS(since 6.0): Prints statistics on the console when the JVM exits.
Here is a sample Maven invocation with caching disabled:
mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=0 -Dbcel.maxcached=0
Here is a sample Maven invocation with caching enabled:
mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=100000 -Dbcel.maxcached=5000000
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstantUtf8(DataInput dataInput) Initializes instance from file data.ConstantUtf8(String value) ConstantUtf8(ConstantUtf8 constantUtf8) Initializes from another object. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.static voidClears the cache.(package private) static voidprivate static voidvoiddump(DataOutputStream file) Dumps String in Utf8 format to file stream.getBytes()static ConstantUtf8getCachedInstance(String value) Gets a new or cached instance of the given value.static ConstantUtf8getInstance(DataInput dataInput) Gets a new or cached instance of the given value.static ConstantUtf8getInstance(String value) Gets a new or cached instance of the given value.(package private) static voidvoidDeprecated.(since 6.0)toString()Methods inherited from class org.apache.bcel.classfile.Constant
clone, copy, equals, getComparator, getTag, hashCode, readConstant, setComparator
-
Field Details
-
considered
private static volatile int considered -
created
private static volatile int created -
hits
private static volatile int hits -
skipped
private static volatile int skipped -
SYS_PROP_CACHE_MAX_ENTRIES
- See Also:
-
SYS_PROP_CACHE_MAX_ENTRY_SIZE
- See Also:
-
SYS_PROP_STATISTICS
- See Also:
-
value
-
-
Constructor Details
-
ConstantUtf8
Initializes from another object.- Parameters:
constantUtf8- the value.
-
ConstantUtf8
ConstantUtf8(DataInput dataInput) throws IOException Initializes instance from file data.- Parameters:
dataInput- Input stream- Throws:
IOException- if an I/O error occurs.
-
ConstantUtf8
- Parameters:
value- Data
-
-
Method Details
-
clearCache
public static void clearCache()Clears the cache.- Since:
- 6.4.0
-
clearStats
static void clearStats() -
countCreated
private static void countCreated() -
getCachedInstance
Gets a new or cached instance of the given value.See
ConstantUtf8class Javadoc for details.- Parameters:
value- the value.- Returns:
- a new or cached instance of the given value.
- Since:
- 6.0
-
getInstance
Gets a new or cached instance of the given value.See
ConstantUtf8class Javadoc for details.- Parameters:
dataInput- the value.- Returns:
- a new or cached instance of the given value.
- Throws:
IOException- if an I/O error occurs.- Since:
- 6.0
-
getInstance
Gets a new or cached instance of the given value.See
ConstantUtf8class Javadoc for details.- Parameters:
value- the value.- Returns:
- a new or cached instance of the given value.
- Since:
- 6.0
-
printStats
static void printStats() -
accept
Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. -
dump
Dumps String in Utf8 format to file stream.- Specified by:
dumpin classConstant- Parameters:
file- Output file stream- Throws:
IOException- if an I/O error occurs.
-
getBytes
- Returns:
- Data converted to string.
-
setBytes
Deprecated.(since 6.0)- Parameters:
bytes- the raw bytes of this UTF-8
-
toString
-