From 98c3bff8ceaab165e26a1f7b84ddaf1cd2d7d5c0 Mon Sep 17 00:00:00 2001 From: Andreas Stadelmeier Date: Wed, 4 Dec 2024 19:10:28 +0100 Subject: [PATCH] Disable FieldAccess Checks in the reflection library --- .../classes/java/lang/reflect/AccessibleObject.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java index a045f9c196a..0cd63c8b855 100644 --- a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java +++ b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java @@ -287,11 +287,8 @@ public class AccessibleObject implements AnnotatedElement { if (caller == null) { // No caller frame when a native thread attaches to the VM // only allow access to a public accessible member - boolean canAccess = Reflection.verifyPublicMemberAccess(declaringClass, declaringClass.getModifiers()); - if (!canAccess && throwExceptionIfDenied) { - throwInaccessibleObjectException(caller, declaringClass); - } - return canAccess; + + return true; } Module callerModule = caller.getModule(); @@ -325,10 +322,7 @@ public class AccessibleObject implements AnnotatedElement { return true; } - if (throwExceptionIfDenied) { - throwInaccessibleObjectException(caller, declaringClass); - } - return false; + return true; } private void throwInaccessibleObjectException(Class caller, Class declaringClass) {