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

Phil Race prr at openjdk.org
Mon Jan 5 21:00:21 UTC 2026


> The problem is that Boolean will be a value type in the future (Project Valhalla)
> and so it can't be the referent of a Reference.
> 
> In this code, the abstract class that creates the Reference accepts a generic type so isn't in control of what it receives.
> 
> The concrete class that extends the generic class has no idea what the super class implementation does,
> so has no way to know that it might do something that is invalid for  a value type.
> 
> That's an interesting observation for Valhalla (that the code that does something inappropriate for a value type
> isn't the source of the value type) but I don't think we need to be concerned
> about that here because we can see reasons to do this anyway.
> 
> The specific classes exist because a nominal singleton for the VM may need to be private to an AppContext.
> This is  a concept from applets but also from webstart where we have a single JVM that may be running code
> from different origins that needs to be partitioned and sand boxed.
> 
> This concept is obsolete now as applets and webstart are no longer supported, and the Security Manager
> is disabled, further undermining any way to support partitioning.
> 
> This specific case of a Boolean created from the value of a Java System Property looks like it never needed
> this partitioning, so the minimal fix is to stop using RecyclableSingleton for it, and just cache the value of that.
> 
> The next  level of fix is to note that since AppContext is obsolete, there is no need for RecyclableSingleton
> to use AppContext specific values, making RecyclableSingleton just a lazy initialization mechanism for the singleton.
> 
> Given that removing the obsolete AppContext is on the TBD list - and some JDK components have already
> removed per-AppContext code - and we'd probably come back to this in JDK 25 anyway it seems best
> to get it over with.
> 
> That does mean that one other place in sun.awt.ImageCache needed to be updated too.
> 
> Also one test that explicitly checked that AppContexts were used for UI instances is obsolete and removed.
> 
> Note that RecyclableSingleton also offers some lazy initialisation benefit, and is widely used in Aqua,
> so going further and removing that probably isn't something we want to do at all, and certainly not here.

Phil Race has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:

 - Merge
 - 8336654

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

Changes: https://git.openjdk.org/jdk/pull/22868/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22868&range=01
  Stats: 129 lines in 3 files changed: 7 ins; 117 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/22868.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22868/head:pull/22868

PR: https://git.openjdk.org/jdk/pull/22868


More information about the client-libs-dev mailing list