We don't need jdk.internal.ref.Cleaner any more

Peter Levart peter.levart at gmail.com
Sun Feb 7 22:32:34 UTC 2016


Hi,

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: 
build/linux-x86_64-normal-server-release/images/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:

http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.02/


Regards, Peter


On 02/07/2016 11:53 AM, Peter Levart wrote:
> Hi,
>
> sun.misc.Cleaner has been moved to internal package jdk.internal.ref 
> recently [1] to clean-up sun.misc namespace. But now that:
>
> - we have comparable public API (java.lang.ref.Cleaner & Cleanable) [2]
> - we have an internal shared java.lang.ref.Cleaner instance 
> (jdk.internal.ref.CleanerFactory.cleaner())
> - sun.misc.Cleaner is not a special kind of Reference any more in the 
> JVM [3]
>
> ...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 [4].
>
> What do you say?
>
> Regards, Peter
>
>
> [1] https://bugs.openjdk.java.net/browse/JDK-8148117
> [2] https://bugs.openjdk.java.net/browse/JDK-8138696
> [3] https://bugs.openjdk.java.net/browse/JDK-8143847
> [4] 
> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.01/
>
>
>
>
>
>




More information about the core-libs-dev mailing list