RFR: 8285364: Remove REF_ enum for java.lang.ref.Reference [v4]

Kim Barrett kbarrett at openjdk.java.net
Fri Apr 29 11:00:44 UTC 2022


On Thu, 28 Apr 2022 20:06:47 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

>> src/hotspot/share/oops/instanceKlass.cpp line 497:
>> 
>>> 495:   _nest_host_index(0),
>>> 496:   _init_state(allocated),
>>> 497:   _reference_type(REF_NONE),
>> 
>> This is initializing `_reference_type` to the wrong value for a `InstanceRefKlass` object, which then needs to reset it in the derived constructor.  Why not get the reference type from the parser?  The (currently file-scoped static) determine_reference_type function in instanceRefKlass.cpp doesn't have any dependency on the klass object being constructed, just the parser.
>
> The current approach limits the knowledge of non-strong ref types to `instanceRefKlass` file.

The `_reference_type` used to be initialized correctly in most cases, but
needed fixing up for a few cases during bootstrapping. With this change it is
*never* initialized correctly for Reference subtypes and always needs an
initialization kludge for them. That's not an improvement.

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

PR: https://git.openjdk.java.net/jdk/pull/8332


More information about the serviceability-dev mailing list