8386972: [lworld] Finalizer should not be registered for value objects#2589
8386972: [lworld] Finalizer should not be registered for value objects#2589fparain wants to merge 5 commits into
Conversation
|
👋 Welcome back fparain! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
| if (InstanceKlass::is_finalization_enabled() && | ||
| (m != nullptr) && !m->is_empty_method()) { | ||
| (m != nullptr) && !m->is_empty_method() && | ||
| m->method_holder()->access_flags().is_identity_class()) { |
There was a problem hiding this comment.
Could we call ClassFileParser's is_identity_class() here instead of going through the method_holder?
There was a problem hiding this comment.
Fred pointed out my proposed change actually changes the meaning as my proposal checks the current class, not the class that defines the finalize method. This is different for a finalize method from an abstract value class
There was a problem hiding this comment.
A finalizer in an abstract value class should probably still be registered for identity subclasses; as otherwise, changing an abstract identity class with a finalizer to an abstract value class with a finalizer would be a breaking change as long as finalizers continue to exist.
There was a problem hiding this comment.
An abstract class with final fields may be good candidate to migrate to an abstract value class. If the abstract class relies on finalization then it is probably not a good candidate. If someone were to migrate without removing the dependency on finalization then it's not going to work as they might think as presumably the motivation for migrating the abstract class is to allow for subclasses to be value classes.
Right now, compiling an abstract value class with a finalize method emits a warning at compile-time to say that class should not have a finalize method as it will not be invoked (this is in addition to the removal warning that finalization is deprecated for removal). This will hopefully make developers aware that it doesn't work as they might think.
|
@fparain this pull request can not be integrated into git checkout finalizer_registration
git fetch https://git.openjdk.org/valhalla.git lworld
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge lworld"
git push |
|
There are two tests in test/jdk/java/lang/Object/ValueObjects.java that are |
Change in finalizers registration to prevent it for value classes.
Tested tier1-4.
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2589/head:pull/2589$ git checkout pull/2589Update a local copy of the PR:
$ git checkout pull/2589$ git pull https://git.openjdk.org/valhalla.git pull/2589/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2589View PR using the GUI difftool:
$ git pr show -t 2589Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2589.diff