JDK-8334720 : Implement JEP 484: Class-File API
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang.classfile
  • Priority: P4
  • Status: Finalized
  • Resolution: Unresolved
  • Fix Versions: 24
  • Submitted: 2024-06-21
  • Updated: 2024-11-08
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Class-File API is leaving preview.

Problem
-------

- All `@PreviewFeature` annotations must be removed from Class-File API.
- All `@since` tags of Class-File API classes and packages must be updated to the actual version.
- `jdk.internal.javac.PreviewFeature.Feature.CLASSFILE_API` must be removed.

Solution
--------

- Remove all `@PreviewFeature` annotations from Class-File API
- Update all  `@since` tags in Class-File API.
- Remove  `jdk.internal.javac.PreviewFeature.Feature.CLASSFILE_API`.

Specification
-------------

Patch is too big to inline, so attached as `pr19826.patch`.


Comments
We believe we have finished our changes. The main changes made besides smaller removals include: - Moving around of constant fields to promote using abstraction instead of raw values - Make Opcode more algebraic - loadConstant for performance and specific computational types on stack - Hide internal writing hooks WritableElement from API - TypeKind facelift (enum naming style, utility methods, subword treatments in docs) - AnnotationConstantValue methods to emphasize representational difference (subwords mainly) - TypeAnnotation remodel - Hide transform implementation hooks - CodeBuilder::if_nonnull and if_null didn't match mnemonic ifnonnull ifnull - ClassFile::transform to transformClass, consistency with builder transformXxx and avoid confusion with builder transform - Remove AccessFlag factories to avoid ambiguous interpretation with valhalla IDENTITY bit in the future Changes we decided against: - Remove AnnotationConstantValueEntry - Enhanced exception type with OOB label offsets or bad CP index getters - Extended encapsulation of ClassReader to prohibit reading out of the range of an attribute, etc. - Proposal to rename StackMapsOption elements (its transformation and direct write behaviors were a bit different) Other future considerations (non-blocking): - Access to Labels in attribute read/write - Explicit Code counters in writing - Instruction.sizeInBytes for unbound switches - Identity of bound instructions loaded from Code attribute (ease for instr-based mappings, such as in Babylon) [~asotona] Do you think we should move this CSR to proposed?
26-09-2024

Moving to Provisional.
03-07-2024

This is a purely procedural CSR for removing the `@PreviewFeature` annotations from the Class-File API and bumping the `@since` tags. It does not contain any other changes to the API nor documentation. Any API or documentation changes will be discussed individually, solved in individual CSRs and linked to the [JEP bug](https://bugs.openjdk.org/browse/JDK-8334712).
21-06-2024