On Wed, 10 Jun 2026 16:47:01 GMT, Chen Liang <[email protected]> wrote:

>> Core reflection has its own type conversion behavior that is somewhat poorly 
>> specified; it is scattered around a few places, and its boxing and unboxing 
>> deviates from that of Java language assignment contexts. In addition, core 
>> reflection has a somewhat erroneous access check system. We can improve the 
>> overview of java.lang.reflect to address these shortcomings and recommend 
>> users to use java.lang.invoke for better functionality in these areas.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Chen Liang has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains 20 additional commits since 
> the last revision:
> 
>  - Tweaks
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 
> doc/reflect-accessor-conversion
>  - Years
>  - Formatting and add an example
>  - Drop 2
>  - typos and consistency
>  - Merge branch 'doc/reflect-accessor-conversion' into m1
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 
> doc/reflect-accessor-conversion
>  - formatting
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 
> doc/reflect-accessor-conversion
>  - ... and 10 more: https://git.openjdk.org/jdk/compare/c6822d24...86002208

src/java.base/share/classes/java/lang/reflect/Field.java line 58:

> 56:  * A {@code Field} provides information about, and dynamic access to, a
> 57:  * single field of a class or an interface.  The reflected field may
> 58:  * be a class (static) field or an instance field.

Regarding https://github.com/openjdk/jdk/pull/28685/changes#r3403371935 it 
would seem like there's a bit of variation in how what "Field" represents 
within the javadoc. Not that I'm saying it needs to get fixed in this PR, but I 
think there's some value in harmonizing the descriptive term(s).

src/java.base/share/classes/java/lang/reflect/Field.java line 446:

> 444:      * converted} to the return type of the accessor.  This conversion 
> never
> 445:      * fails for {@code get}, but may fail for other primitive-typed 
> accessors,
> 446:      * which would fail with an {@code IllegalArgumentException}.

Perhaps elaborating a bit: "This conversion never fails for get, but may fail 
with an IllegalArgumentException when <insert conditions>" It is not clear 
reading the text above what those circumstances actually are (and how to avoid).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28685#discussion_r3403398329
PR Review Comment: https://git.openjdk.org/jdk/pull/28685#discussion_r3403409919

Reply via email to