Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 527
Jivings Avatar asked Oct 10 '22 10:10

Jivings


1 Answers

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

like image 138
axtavt Avatar answered Oct 13 '22 12:10

axtavt