On Fri, 29 Apr 2022 11:39:39 GMT, Albert Mingkun Yang <ay...@openjdk.org> wrote:
>> 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. > > `_reference_type` always gets the correct value after the constructor is run. > The member initializer list just follows the convention of having all fields > set. One could move this field inside the constructor body to ensure this > field is set only once. > The current approach limits the knowledge of non-strong ref types to > `instanceRefKlass` file. The mechanism used to compute the correct reftype is purely derived from the parser, and to me looks like "parsing". So I think it would be better placed with the parser. And that would also remove the need for the two-step initialization of the InstanceKlass member. With that in mind, I think the file scoped function determine_reference_type in instanceRefKlass.cpp should instead be an ordinary public member function `ClassFileParser::reference_type() const` (with appropriate adjustment of it's implementation), called by the InstanceKlass constructor to initialize `_reference_type`. Associated with that are some other changes: - The new InstanceRefKlass::set_reference_type is no longer needed. - The new ClassFileParser::super_reference_type and ClassFileParser::is_java_lang_ref_Reference_subclass don't need to be public. (Assuming they exist at all after adjustment of ClassFileParser::reference_type.) ------------- PR: https://git.openjdk.org/jdk/pull/8332