Skip to content

Commit

Permalink
Refine module openness check
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Aug 24, 2020
1 parent eaa12bf commit 57f7db8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -95,6 +95,7 @@ class InstrumentationMemberAccessor implements MemberAccessor {
INITIALIZATION_ERROR = throwable;
}

@SuppressWarnings("unused")
private final MethodHandle getModule, isOpen, redefineModule, privateLookupIn;

InstrumentationMemberAccessor() {
Expand All @@ -116,7 +117,7 @@ class InstrumentationMemberAccessor implements MemberAccessor {
.findVirtual(
module,
"isOpen",
MethodType.methodType(boolean.class, String.class, module));
MethodType.methodType(boolean.class, String.class));
redefineModule =
MethodHandles.publicLookup()
.findVirtual(
Expand Down Expand Up @@ -330,9 +331,12 @@ public void set(Field field, Object target, Object value) throws IllegalAccessEx
}

private void assureOpen(Object module, String packageName) throws Throwable {
if (!(Boolean)
DISPATCHER.invokeWithArguments(
isOpen, module, packageName, DISPATCHER.getModule())) {
// It would be more reliable to check if a module's package already is opened to
// the dispatcher module from before. Unfortunately, there is no reliable check
// for doing so since the isOpen(String, Module) method always returns true
// if the second argument is an unnamed module. Therefore, for now, we need
// to reopen packages even if they are already opened to the dispatcher module.
if (!(Boolean) DISPATCHER.invokeWithArguments(isOpen, module, packageName)) {
DISPATCHER.invokeWithArguments(
redefineModule.bindTo(INSTRUMENTATION),
module,
Expand Down
4 changes: 4 additions & 0 deletions subprojects/inline/inline.gradle
Expand Up @@ -12,3 +12,7 @@ tasks.javadoc.enabled = false
//required by the "StressTest.java" and "OneLinerStubStressTest.java"
test.maxHeapSize = "256m"
retryTest.maxHeapSize = "256m"

test {
jvmArgs '--illegal-access=debug'
}

0 comments on commit 57f7db8

Please sign in to comment.