8264434: Remove ResourceScope-less overload from API #485
This patch does a bunch of API cleanups related to overloaded methods:
The changes are mostly mechanical - e.g. an extra ResourceScope.ofImplicit() is added wherever needed.
The term implicit has been selected to denote the subset of scopes that are not only managed by a Cleaner, but that do not play into explicit deallocation.
So, ResourceScope.ofImplicit() returns a new implicit scope, whereas ResourceScope.globalScope, returns a constant implicit scope which is assumed to be alive for the entire duration of the application.
A new predicate has been added on ResourceScope, namely
PaulSandoz left a comment •
Looking at the changes in the tests it occurred to me that
May be worth reviewing factory methods of other classes too, namely
For common cases i would imagine static imports may be useful, so the method names should stand on their own, at the expense of a few more characters (3 for scope) when the method is qualified.
JornVernee left a comment
LGTM. I agree with Paul that it would be nice to rename
@mcimadamore This change now passes all automated pre-integration checks.
After integration, the commit message for the final commit will be:
At the time when this comment was updated there had been no new commits pushed to the
Ha! I had exactly this conversation earlier (offline).
Same applied to MemoryLayout.ofStruct and others.
I'm happy to rename all this, but (i) I'd like to separate from this change and (ii) I need some guidance from JDK API gurus - e.g. some JDK factories do use
…ResourceScope.java Co-authored-by: Jorn Vernee <JornVernee@users.noreply.github.com>
…ResourceScope.java Co-authored-by: Paul Sandoz <firstname.lastname@example.org>
I think whatever naming we choose, we need to have some visual distinction between factories which are just "accessors" e.g. ResourceScope.globalScope and things which create a new scope e.g. ResourceScope.ofImplicit. But, as discussed offline, I don't want to go down the road of calling the latter