Interface NameGenerator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int NAME_MAX_LENGTH
      According to JVM specification, the name is limited to 65535 characters by the 16-bit unsigned length item of the CONSTANT_Utf8_info structure.
    • Field Detail

      • NAME_MAX_LENGTH

        static final int NAME_MAX_LENGTH
        According to JVM specification, the name is limited to 65535 characters by the 16-bit unsigned length item of the CONSTANT_Utf8_info structure. As the limit is on the number of bytes and UTF-8 encodes some characters using two or three bytes, we assume that in worst case number or characters is 65535 / 3
        See Also:
        Constant Field Values
    • Method Detail

      • generateName

        String generateName​(int size)
        Generates random name of required length that can be used as Java identifier.
        Parameters:
        size - the expected size
        Returns:
        the name of expected length
        Throws:
        IllegalArgumentException - when passed size is more than NAME_MAX_LENGTH