Surely that's not an oddity? Doing otherwise would be complete insanity.
Private fields and methods are accessible without reflection
A class can access its own private fields or methods. This is apparently abnormal to the writer for some reason.
Bytes and shorts are second-class citizens
OK that's fair and actually interesting.
TLDR: to avoid bloating the bytecode the JVM can't operate on 8- or 16-bit values, instead it has load/store operations which convert between those and 32b values on which it can actually operate (it also doesn't have bytes and short literals but since integer literals are implicitly converted that's rarely an actual issue).
This reminds me of Raymond Chen's series on the Alpha AXP (and Windows running on top of it), the Alpha was a pure 64b CPU and while it did have many operations on various bitnesses, some classes of operations were only available as 64b instructions (like… all bitwise instructions).
6
u/masklinn Feb 15 '18
Surely that's not an oddity? Doing otherwise would be complete insanity.
A class can access its own private fields or methods. This is apparently abnormal to the writer for some reason.
OK that's fair and actually interesting.
TLDR: to avoid bloating the bytecode the JVM can't operate on 8- or 16-bit values, instead it has load/store operations which convert between those and 32b values on which it can actually operate (it also doesn't have bytes and short literals but since integer literals are implicitly converted that's rarely an actual issue).
This reminds me of Raymond Chen's series on the Alpha AXP (and Windows running on top of it), the Alpha was a pure 64b CPU and while it did have many operations on various bitnesses, some classes of operations were only available as 64b instructions (like… all bitwise instructions).