hg: valhalla/valhalla: Use requested class name for non-findable class

Mandy Chung mandy.chung at oracle.com
Fri Nov 9 17:04:49 UTC 2018



On 11/9/18 7:24 AM, Lois Foltan wrote:
> On 11/9/2018 2:18 AM, Remi Forax wrote:
>
>> Hi Mandy,
>>
>> The code here
>> http://hg.openjdk.java.net/valhalla/valhalla/rev/248cd28491c1#l1.7
>> is dubious to me.
>>
>> You're patching only the class name not all other occurences of that 
>> same class in the constant pool (as a class or in a NameAndType).
>> How can it works if the class reference itself, like by example, a 
>> call to a private method of itself ?
>
> Hi Remi,
>
> It works because later on within 
> ClassFileParser::fill_instance_klass() the _this_class_index within 
> the constant pool for unsafe anonymous and future nonfindable classes 
> are eagerly resolved
>
> if (_is_nonfindable || is_unsafe_anonymous()) {
>     // _this_class_index is a CONSTANT_Class entry that refers to this
>     // anonymous class itself. If this class needs to refer to its own 
> methods or
>     // fields, it would use a CONSTANT_MethodRef, etc, which would 
> reference
>     // _this_class_index. However, because this class is nonfindlabe 
> or anonymous (it's
>     // not stored in SystemDictionary), _this_class_index cannot be 
> resolved
>     // with ConstantPool::klass_at_impl, which does a SystemDictionary 
> lookup.
>     // Therefore, we must eagerly resolve _this_class_index now.
>     ik->constants()->klass_at_put(_this_class_index, ik);
>   }
>

Patching the class name work around the Class::getName to get the class 
name of non-findable class and also Class::isHidden to work properly.

W.r.t. resolution, we're teasing out various issues.    The above is how 
the unsafe VM anonymous gets resolved symbolic reference to itself.  I 
am still seeing CNFE or NCDFE in some test cases including your pro test 
case.  I suspect there is somewhere that triggers class loading of 
this_class since it's not registered in the system dictionary.

Mandy


More information about the valhalla-dev mailing list