< prev index next >
src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -668,10 +668,18 @@
// Keep all this slow stuff out of line:
private boolean slowVerifyAccess(Class<?> caller, Class<?> memberClass,
Class<?> targetClass, int modifiers)
{
+
+ if (caller == null) {
+ // No caller frame when a native thread attaches to the VM
+ // can access public member of a type in unconditional exported API packages
+ Module module = memberClass.getModule();
+ return Modifier.isPublic(modifiers) && module.isExported(memberClass.getPackageName());
+ }
+
if (!Reflection.verifyMemberAccess(caller, memberClass, targetClass, modifiers)) {
// access denied
return false;
}
< prev index next >