Class ConstantUtf8

  • All Implemented Interfaces:
    Cloneable, Node

    public final class ConstantUtf8
    extends Constant
    Extends the abstract Constant to represent a reference to a UTF-8 encoded string.

    The following system properties govern caching this class performs.

    • "bcel.maxcached" (since 6.4): The size of the cache, by default 0, meaning caching is disabled.
    • "bcel.maxcached.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.
    • "bcel.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:
    Constant
    • Constructor Detail

      • ConstantUtf8

        public ConstantUtf8​(ConstantUtf8 constantUtf8)
        Initializes from another object.
        Parameters:
        constantUtf8 - the value.
      • ConstantUtf8

        public ConstantUtf8​(String value)
        Parameters:
        value - Data
    • Method Detail

      • clearCache

        public static void clearCache()
        Clears the cache.
        Since:
        6.4.0
      • getCachedInstance

        public static ConstantUtf8 getCachedInstance​(String value)
        Gets a new or cached instance of the given value.

        See ConstantUtf8 class Javadoc for details.

        Parameters:
        value - the value.
        Returns:
        a new or cached instance of the given value.
        Since:
        6.0
      • getInstance

        public static ConstantUtf8 getInstance​(DataInput dataInput)
                                        throws IOException
        Gets a new or cached instance of the given value.

        See ConstantUtf8 class 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

        public static ConstantUtf8 getInstance​(String value)
        Gets a new or cached instance of the given value.

        See ConstantUtf8 class Javadoc for details.

        Parameters:
        value - the value.
        Returns:
        a new or cached instance of the given value.
        Since:
        6.0
      • accept

        public void accept​(Visitor v)
        Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
        Specified by:
        accept in interface Node
        Specified by:
        accept in class Constant
        Parameters:
        v - Visitor object
      • getBytes

        public String getBytes()
        Returns:
        Data converted to string.
      • setBytes

        @Deprecated
        public void setBytes​(String bytes)
        Deprecated.
        (since 6.0)
        Parameters:
        bytes - the raw bytes of this UTF-8