We don't need jdk.internal.ref.Cleaner any more
peter.levart at gmail.com
Sun Feb 7 22:32:34 UTC 2016
I 1st thought that my version of jtreg did not want to parse the new JDK
9 version strings as it kept saying:
Error: cannot determine version for JDK:
...but the fact was that the patched JDK did not even want to boot-up.
So in order to make this actually work, I had to make some adjustments:
- lambdas and method references in the java.lang.ref.Cleaner
implementation had to be replaced with alternatives as the Cleaner is
needed early in the startup sequence.
- [sun.misc|jdk.internal.ref].Cleaner.create(referent, action) allowed
null action and just returned null in that case while
java.lang.ref.Cleaner.register(referent, action) throws NPE. There was
only one such usage where null action could get passed-in - when a
zero-sized MappedByteBuffer was constructed.
Here's the version which passes java/lang/ref and java/nio tests:
On 02/07/2016 11:53 AM, Peter Levart wrote:
> sun.misc.Cleaner has been moved to internal package jdk.internal.ref
> recently  to clean-up sun.misc namespace. But now that:
> - we have comparable public API (java.lang.ref.Cleaner & Cleanable) 
> - we have an internal shared java.lang.ref.Cleaner instance
> - sun.misc.Cleaner is not a special kind of Reference any more in the
> JVM 
> ...I think there's no reason to keep this special internal API any
> more. It can be replaced with public API.
> I propose to remove jdk.internal.ref.Cleaner class and replace its
> usages with java.lang.ref.Cleaner and friends .
> What do you say?
> Regards, Peter
>  https://bugs.openjdk.java.net/browse/JDK-8148117
>  https://bugs.openjdk.java.net/browse/JDK-8138696
>  https://bugs.openjdk.java.net/browse/JDK-8143847
More information about the core-libs-dev