nr: #3 dodano: 2016-12-30 11:12
Why .class is UTF-8
For classes written for a Western audience, which are usually mostly ASCII, this is the most compact encoding.
but runtime .class is UTF-16?
At runtime it's quicker to manipulate strings that use a fixed-width encoding (Why Java char uses UTF-16?), so UCS-2 was chosen. This is complicated by the change from UCS-2 to UTF-16 making this another variable-width encoding.
As noted in the comments of that question, JEP 254 allows for the runtime representation to change to something more space efficient (e.g., Latin-1).