[lworld] RFR: 8265423: [lworld] Provide experimental support for generating a single class file per primitive class

Srikanth Adayapalam sadayapalam at openjdk.java.net
Tue Apr 27 12:46:48 UTC 2021

On Tue, 27 Apr 2021 12:22:13 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Use -XDunifiedValRefClass option to javac to get unified class file generation for primitive classes. Note: Javac will require some tweaks to consume such files, this is WIP.
> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java line 2690:
>> 2688:             if (referenceProjection != null) {
>> 2689:                 if (referenceProjection.name != names.ref && referenceProjection.owner.kind == PCK) {
>> 2690:                     referenceProjection.complete();
> This change seems sneaky - what caused it?

Indeed. I should push this as a separate change set. I discovered this bug while working on the now aborted attempt to evolve the code generation scheme to match SoV4. The right way to internalize the class is by calling complete() on the symbol and not by directly calling readClassFileInternal(). Doing the latter, could result in com.sun.tools.javac.code.ClassFinder#fillIn(com.sun.tools.javac.code.Symbol.ClassSymbol) from being re-entered resulting in an assertion failure.

This change is not required for the present feature, but is a crucial fix that should be made independently.

> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java line 848:
>> 846:             databuf.appendChar(flags);
>> 847:             icCount++;
>> 848:             if (inner.isPrimitiveClass() && types.splitPrimitiveClass) {
> the test `sym.isPrimitiveClass() && types.splitPrimitiveClass` is so common which I think would be better refactored into a separate predicate, to make the code clearer.
> e.g. `Symbol.isSplitPrimitiveClass(Types)`

Thanks, I will take a look


PR: https://git.openjdk.java.net/valhalla/pull/394

More information about the valhalla-dev mailing list