RFR: 8294982: Implementation of Classfile API [v20]
Adam Sotona
asotona at openjdk.org
Fri Feb 17 09:38:36 UTC 2023
On Thu, 16 Feb 2023 12:11:06 GMT, Jens Lidestrom <duke at openjdk.org> wrote:
>> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>>
>> added 4-byte Unicode text to Utf8EntryTest
>
> src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPoolBuilder.java line 96:
>
>> 94: * @param <T> the type of the option value
>> 95: */
>> 96: <T> T optionValue(Classfile.Option.Key option);
>
> This unconstrained type parameter will result in and implicit conversion to any type that the caller assigns it to, which might result in a `ClassCastException` if the caller gets the type wrong.
>
> Is this intentional?
>
> The same idiom is used in a few other places in the code.
>
> Alternative solutions:
>
> * Convert `Key` to an ordinary class or sealed interface, and add a type parameter to it, for the value type. (Enums unfortunately don't support type parameters.)
> * Add a parameter the the method of type `Class<T>`.
Thanks for pointing it out.
I've re-visited the API re-accessing already provided options and found no relevant use case.
This method (and similar on other places), plus the `Classfile.Option.Key` will be pulled from API to the implementation.
Please let us know if there is a need to read option values from user perspective.
-------------
PR: https://git.openjdk.org/jdk/pull/10982
More information about the build-dev
mailing list