JEP draft: Better-defined JVM class file validation

Harold Seigel harold.seigel at oracle.com
Fri Jun 11 18:38:58 UTC 2021


Hi Dan,

      *

        Rejecting non-static field declarations
        with|ConstantValue|attributes, similarly on the basis that if
        the attribute appears in the|attributes|table of
        a|field_info|structure, it should be recognized and checked.

I tried implementing the above change and encountered errors when 
building the JDK because ConstantValue attributes were generated by 
javac for private final fields that were not static.  For example, these 
fields in jdk.tools.jlink.internal.plugins.SystemModulesPlugin had 
ConstantValue attributes:

             private final int BUILDER_VAR    = 0;
             private final int MD_VAR         = 1;  // variable for
    ModuleDescriptor
             private final int MT_VAR         = 1;  // variable for
    ModuleTarget
             private final int MH_VAR         = 1;  // variable for
    ModuleHashes

There were a few other additional cases such as field MAX_FLATER in 
ZipFileSystem.java and NUM_COMMON_CPOOL_ENTRIES in AccessorGenerator.java.

Should  the above check be class file version dependent?

Thanks, Harold


On 6/4/2021 12:41 PM, Dan Smith wrote:
> Posted a new JEP draft, here:
>
> http://openjdk.java.net/jeps/8267650
>
> This is some preparatory work to allow us to more cleanly introduce the variety of new JVM features coming with primitive objects (JEP 401).
>
> Most of the spec work is already done; you can browse the proposed spec changes here:
> http://cr.openjdk.java.net/~dlsmith/8267650/8267650-20210603/specs/
>


More information about the valhalla-spec-observers mailing list