8264774: Implementation of Foreign Function and Memory API (Incubator)

Co-authored-by: Paul Sandoz <psandoz@openjdk.org>
Co-authored-by: Jorn Vernee <jvernee@openjdk.org>
Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org>
Co-authored-by: Athijegannathan Sundararajan <sundar@openjdk.org>
Co-authored-by: Chris Hegarty <chegar@openjdk.org>
Reviewed-by: psandoz, chegar, mchung, vlivanov
This commit is contained in:
Maurizio Cimadamore 2021-06-02 10:53:06 +00:00
parent 71425ddfb4
commit a223189b06
219 changed files with 10936 additions and 5695 deletions

View file

@ -109,6 +109,8 @@ public final class Module implements AnnotatedElement {
// the module descriptor
private final ModuleDescriptor descriptor;
// true, if this module allows restricted native access
private volatile boolean enableNativeAccess;
/**
* Creates a new named Module. The resulting Module will be defined to the
@ -133,6 +135,10 @@ public final class Module implements AnnotatedElement {
String loc = Objects.toString(uri, null);
Object[] packages = descriptor.packages().toArray();
defineModule0(this, isOpen, vs, loc, packages);
if (loader == null || loader == ClassLoaders.platformClassLoader()) {
// boot/builtin modules are always native
implAddEnableNativeAccess();
}
}
@ -244,6 +250,30 @@ public final class Module implements AnnotatedElement {
return null;
}
/**
* Update this module to allow access to restricted methods.
*/
Module implAddEnableNativeAccess() {
enableNativeAccess = true;
return this;
}
/**
* Update all unnamed modules to allow access to restricted methods.
*/
static void implAddEnableNativeAccessAllUnnamed() {
ALL_UNNAMED_MODULE.enableNativeAccess = true;
}
/**
* Returns true if module m can access restricted methods.
*/
boolean implIsEnableNativeAccess() {
return isNamed() ?
enableNativeAccess :
ALL_UNNAMED_MODULE.enableNativeAccess;
}
// --
// special Module to mean "all unnamed modules"