[foreign] RFR: native libraries should have a global scope
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Jul 6 13:15:00 UTC 2018
Hi,
In general, all user-facing pointers have a scope; there is however an
important exceptions: pointer to globals. Since such pointers are
computed inside the binder, they do not have any associate scope. This
leads to issues with code uniformity (where e.g. we have to defensively
check for null when retrieving a pointer's scope), and it is also an
impediment to develop certain features: for instance, we'd like constant
values to be generated in the binder - and not in jextract (as now) -
but doing so might require native memory allocation by the native
library (think about a string constant) - and that requires a scope.
This patch adds a global scope that is shared by all instance of a
certain library. The scope is created when an impl for a library
interface is requested. A reference cleaner is also used to make sure
that the Scope::close method is called when the library class is unloaded.
As part of this change I also added javadoc to the Library interface,
and turned the Library.Symbol class into an interface (allocating a
symbol is a privileged operation and should not be exposed by the public
API).
Webrev:
http://cr.openjdk.java.net/~mcimadamore/panama/global_scope/
Maurizio
More information about the panama-dev
mailing list