RFR: 8235772: Remove use of deprecated finalize method from PiscesRenderer and AbstractSurface
Ambarish Rapte
arapte at openjdk.java.net
Wed Dec 18 16:55:44 UTC 2019
On Tue, 17 Dec 2019 14:29:22 GMT, Johan Vos <jvos at openjdk.org> wrote:
>> The finalize() method is deprecated in JDK9. See [Java 9 deprecated features](https://www.oracle.com/technetwork/java/javase/9-deprecated-features-3745636.html).
>> And so the [PiscesRenderer.finalize()](https://github.com/openjdk/jfx/blob/71ca899fbfc74d825c29b20a778d6d9eb243f90f/modules/javafx.graphics/src/main/java/com/sun/pisces/PiscesRenderer.java#L439) and [AbstractSurface.finalize()](https://github.com/openjdk/jfx/blob/71ca899fbfc74d825c29b20a778d6d9eb243f90f/modules/javafx.graphics/src/main/java/com/sun/pisces/AbstractSurface.java#L100) method should be removed.
>>
>> The change is,
>> 1. Remove finalize method from PiscesRenderer and AbstractSurface classes.
>> 2. Use [Disposer](https://github.com/openjdk/jfx/blob/71ca899fbfc74d825c29b20a778d6d9eb243f90f/modules/javafx.graphics/src/main/java/com/sun/prism/impl/Disposer.java#L48) class for cleanup instead of finalize(). For SW pipeline the cleanup is initiated in [here](https://github.com/openjdk/jfx/blob/71ca899fbfc74d825c29b20a778d6d9eb243f90f/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/UploadingPainter.java#L195) in UploadingPainer.java.
>> 3. Added new JNI methods to JPiscesRenderer.c and JAbstractSurface.c and removed the ones which were used previously with finalize() method.
>>
>> Verification:
>> Verified that the newly added dispose() methods get invoked as required and no OOM occurs.
>> 1. Create a sample program which adds and removes non 3D shapes and/or controls to stage in a loop.
>> 2. Run the program using -Dprism.order=sw, -Dprism.verbose=true. (optional -Xmx50m)
>> Expected Behavior:
>> a. Maximum memory consumption after this change should reduce or remain same as that of before this change.
>> b. No OOM should occur with this change or without this change.
>
> modules/javafx.graphics/src/main/native-prism-sw/JAbstractSurface.c line 63:
>
>> 62: }
>> 63: }
>> 64:
>
> there are no checks on memory errors as used to be in the finalize implementation. Are those not needed anymore?
Hi Johan,
The `readAndClearMemErrorFlag()` method checks if the variable `mem_Error_Flag` is `JNI_TRUE`.
A call should be made to `setMemErrorFlag()` to set `mem_Error_Flag` to `JNI_TRUE`.
The methods used to dispose Surface and renderer only `free()` the allocated memory and
do not result in making a call to `setMemErrorFlag().`
So we do not need to check for `readAndClearMemErrorFlag()`
And I think it was not required before this change too.
-------------
PR: https://git.openjdk.java.net/jfx/pull/66
More information about the openjfx-dev
mailing list