[10] RFR: 8176041: Optimize handling of comment lines in Properties$LineReader.readLine

John Rose john.r.rose at oracle.com
Thu Mar 2 11:28:21 UTC 2017

On Mar 1, 2017, at 5:11 PM, Claes Redestad <claes.redestad at oracle.com> wrote:
> It seems javac optimizes byte-char comparisons pretty well

This happened because of the JVM's bytecode ISA, which requires that javac must "erase" all integer subrange types (boolean, char, byte, short) internally to int, when emitting bytecode.  So whether you say true, '\1', (byte)1, (short)1, or just 1, javac will emit an "iconst_1" instruction and push 32 bits on the stack.  This tends to "smooth out" differences between types of 32 bits or less.  This is especially surprising in the case of booleans, which are not convertible to ints at the source level.

More JVM trivia:

The only places in the bytecode ISA where subrange types are fully significant are (1) field get/set, (2) array element get/set, and (3) the type-checking of primitive arrays.

The i2x/x2i conversions and xipush constants can be viewed as always operating on ints.  Method descriptor types are "partially significant", in a way that has evolved over time and is too complicated to describe here.

— John

More information about the core-libs-dev mailing list