RFR: 8301684: Fix test code to not get finalizer deprecation warnings [v3]
Afshin Zafari
duke at openjdk.org
Wed Mar 15 10:19:08 UTC 2023
> To replace the finalizer use in the code, the `Cleaner` approach is used as stated in [Oracle doc on deprecated finalize() method](https://docs.oracle.com/javase/10/docs/api/java/lang/Object.html#finalize()).
> Briefly:
> 1. An instance of `Cleaner` (`java.lang.ref`) is created.
> 2. Using the `Cleaner`, an object is registered with a `Runnable` callback that is notified when the object is no longer reachable (GC'ed).
> 3. Write code in the callback to do other cleanings.
>
>
> Cleaner c = new Cleaner();
> Cleanable cleanable = c.register(an_obj, a_runnable);
> ...
> //JVM notifies by calling the
> a_runnable.run() {...}
>
> ### Tests
> local:
> vmTestbase/nsk/monitoring/stress/classload
> vmTestbase/nsk/jvmti/AttachOnDemand
> vmTestbase/nsk/jdi/ObjectReference/referringObjects
> vmTestbase/nsk/sysdict
> mach5: tier 1-5
Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
8301684: Fix test code to not get finalizer deprecation warnings
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/12968/files
- new: https://git.openjdk.org/jdk/pull/12968/files/15c2ef56..58d24335
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=12968&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=12968&range=01-02
Stats: 12 lines in 1 file changed: 0 ins; 0 del; 12 mod
Patch: https://git.openjdk.org/jdk/pull/12968.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12968/head:pull/12968
PR: https://git.openjdk.org/jdk/pull/12968
More information about the hotspot-runtime-dev
mailing list