[code-reflection] RFR: Adjusted tests to use execution of a method and implementation of the execution model cache [v2]
Adam Sotona
asotona at openjdk.org
Fri Feb 28 10:04:01 UTC 2025
On Fri, 28 Feb 2025 09:56:07 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> I believe `ClassValue` is similar to a thread local in how it's used -- e.g. you create an instance of it and stick it in a static final (the javadoc of `ClassValue` is useless in that respect):
>>
>>
>> ClassValue<CachedModel> CACHED_MODEL = new ClassValue<>() {
>> @Override
>> CachedModel computeValue() { <logic here> }
>> };
>>
>>
>> That should work here.
>
> Yes, I'm just having troubles to initiate the ClassValue when I need it (when I have additional arguments).
> See my solution.
There is a design flaw in the ClassValue, the only way to initialize it is by ClassValue::computeValue(Class<?>).
It has been designed to attach some value to a class, however if your value needs some arguments to be computed, you need to attach them to the class, which you cannot. So it is a Catch-22.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/331#discussion_r1975144551
More information about the babylon-dev
mailing list