RFR: 8336654: [lworld] Tests depending on sun.awt.AppContext can fail when run with migrated classes [v5]

Phil Race prr at openjdk.org
Wed Jan 7 20:23:52 UTC 2026


On Wed, 7 Jan 2026 01:48:31 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> All uses of this are stored in static final fields and typically it is a singleton or fixed size list/map
>> I don't see anything that will grow without bounds, and SoftReference isn't a great way to manage
>> such cases anyway.
>> 
>> So I don't see any problem with doing away with SoftReference.
>> If we keep it, I think it is just more overhead.
>> 
>> And I don't see any way that isn't tricky and messy to do this whilst still allowing value types.
>> It might be easier once Valhalla actually lands so we could check if it is an identity type.
>> 
>> So if we keep the reference then a point fix of the Boolean case seems the practical solution.
>> There's no great value to keeping a SoftRef to a Boolean so we can do without it.
>> But it meant I had to look for any other similar cases by hand. I didn't find any.
>> 
>> Doing this means no changes to the existing RecyclableSingleton class are necessary to resolve the specific issue.
>> But I think we want to soon enough get rid of AppContext anyway, so I am moving the ref usage
>> directly into RecyclableSingleton and keeping the deletion of the method from AppContext.
>> The ImageCache doesn't need it. The cached images are managed by the cache code itself.
>> 
>> The most recent commit implements the above but I don't see a problem with pushing without that commit.
>
> That looks fine. What about LazyConstant? It seems to have similar functionality to the new LazySingleton, aside from the name. Personally, I do not think LazyConstant is a great name....

You mean the new incarnation of StableValue ?
That crossed my mind, but I don't think this case is important enough to bring in that preview feature.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22868#discussion_r2669956234


More information about the client-libs-dev mailing list