JDK-8338774 : AttributeMapper type parameter should be bounded by Attribute
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang.classfile
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 24
  • Submitted: 2024-08-21
  • Updated: 2024-08-23
  • Resolved: 2024-08-23
Related Reports
CSR :  
Relates :  
Description
Summary
-------

AttributeMapper's type parameter `A` is now bounded by `Attribute<A>`.

Problem
-------

AttributeMapper's type parameter `A` is supposed to be bounded by `Attribute<A>` but is not declared so.

Solution
--------

Make it bounded by `Attribute<A>`. This only affects one use site in implementation that it no longer needs to cast a user AttributeMapper return value to `Attribute<?>`; other places that can access AttributeMapper, such as `Attribute::attributeMapper`, already bounds the returned type argument.

Note this change affects method descriptors, so technically the `readAttribute` and `writeAttribute` methods are now removed and re-added due to descriptor update from `Object` to `Attribute`.

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

    -public interface AttributeMapper<A> {
    +public interface AttributeMapper<A extends Attribute<A>> {



Comments
Looks like a reasonable change; moving to Approved.
23-08-2024