Search code examples
javaclassbytecodejavap

Javap Asciz Strings


Little question about the output generated from the javap command regarding the constant pool. When javap prints the pool it defines string constants as Asciz strings, which I understand means null terminated Ascii:

const #20 = Asciz       hello world;

This would imply that the length of the string is not known, and to parse you would read each byte until you encounter the null.

However, the length of constant pool string constants is defined by the two bytes preceding the string and there is no null appended. (Constant pool specification).

Does javap define strings as Asciz incorrectly or does Asciz have another meaning I'm not aware of?


Solution

  • See bug #6868539. It's fixed in OpenJDK7, now javap prints Utf8 instead.