diff --git a/src/main/java/tools/jackson/databind/MapperFeature.java b/src/main/java/tools/jackson/databind/MapperFeature.java index f15be4c6b9..df12de0d98 100644 --- a/src/main/java/tools/jackson/databind/MapperFeature.java +++ b/src/main/java/tools/jackson/databind/MapperFeature.java @@ -204,7 +204,7 @@ public enum MapperFeature * Feature that determines whether method and field access * modifier settings can be overridden when accessing * properties. If enabled, method - * {@link java.lang.reflect.AccessibleObject#setAccessible} + * {@link java.lang.reflect.AccessibleObject#trySetAccessible} * may be called to enable access to otherwise unaccessible objects. *

* Note that this setting may have significant performance implications, @@ -227,7 +227,7 @@ public enum MapperFeature /** * Feature that determines that forces call to - * {@link java.lang.reflect.AccessibleObject#setAccessible} even for + * {@link java.lang.reflect.AccessibleObject#trySetAccessible} even for * public accessors -- that is, even if no such call is * needed from functionality perspective -- if call is allowed * (that is, {@link #CAN_OVERRIDE_ACCESS_MODIFIERS} is set to true). diff --git a/src/main/java/tools/jackson/databind/introspect/AnnotatedMember.java b/src/main/java/tools/jackson/databind/introspect/AnnotatedMember.java index 56baf13390..1ae9643828 100644 --- a/src/main/java/tools/jackson/databind/introspect/AnnotatedMember.java +++ b/src/main/java/tools/jackson/databind/introspect/AnnotatedMember.java @@ -88,7 +88,7 @@ public Stream annotations() { /** * Method that can be called to modify access rights, by calling - * {@link java.lang.reflect.AccessibleObject#setAccessible} on + * {@link java.lang.reflect.AccessibleObject#trySetAccessible} on * the underlying annotated element. *

* Note that caller should verify that diff --git a/src/main/java/tools/jackson/databind/introspect/AnnotatedMethodCollector.java b/src/main/java/tools/jackson/databind/introspect/AnnotatedMethodCollector.java index a02d8ef8f3..5b40cb487a 100644 --- a/src/main/java/tools/jackson/databind/introspect/AnnotatedMethodCollector.java +++ b/src/main/java/tools/jackson/databind/introspect/AnnotatedMethodCollector.java @@ -141,7 +141,7 @@ private void _addMemberMethods(TypeResolutionContext tc, // may also result in faster method calls (interface calls are slightly // costlier than regular method calls) // 03-Jan-2021, scs: But we should probably prefer more public interface methods - // (and respect class visibility too!) rather than relying on setAccessible + // (and respect class visibility too!) rather than relying on `trySetAccessible` private boolean shouldReplace(Method current, Method replace) { if (accessLevel(replace) > accessLevel(current)) { return true; diff --git a/src/main/java/tools/jackson/databind/util/ClassUtil.java b/src/main/java/tools/jackson/databind/util/ClassUtil.java index 46c24d4461..60cc6babe7 100644 --- a/src/main/java/tools/jackson/databind/util/ClassUtil.java +++ b/src/main/java/tools/jackson/databind/util/ClassUtil.java @@ -844,9 +844,9 @@ public static Class primitiveType(Class type) /** * Method that is called if a {@link Member} may need forced access, * to force a field, method or constructor to be accessible: this - * is done by calling {@link AccessibleObject#setAccessible(boolean)}. + * is done by calling {@link AccessibleObject#trySetAccessible}. * - * @param member Accessor to call setAccessible() on. + * @param member Accessor to call trySetAccessible() on. * @param evenIfAlreadyPublic Whether to always try to make accessor * accessible, even if {@code public} (true), * or only if needed to force by-pass of non-{@code public} access (false) @@ -863,7 +863,7 @@ public static void checkAndFixAccess(Member member, boolean evenIfAlreadyPublic) boolean isPublic = Modifier.isPublic(member.getModifiers()) && Modifier.isPublic(declaringClass.getModifiers()); if (!isJDKClass(declaringClass) && (!isPublic || evenIfAlreadyPublic)) { - ao.setAccessible(true); + ao.trySetAccessible(); } } catch (SecurityException ignore) { } catch (RuntimeException e) { @@ -1238,7 +1238,7 @@ private static Field locateField(Class fromClass, String expectedName, Class< if (!expectedName.equals(f.getName()) || f.getType() != type) { continue; } - f.setAccessible(true); + f.trySetAccessible(); return f; } // If not found, indicate with exception