Skip to content

Commit

Permalink
Merge pull request #3383 from harawata/isaccessible-to-canaccess
Browse files Browse the repository at this point in the history
Replace deprecated `isAccessible()` with `canAccess()`
  • Loading branch information
harawata authored Jan 4, 2025
2 parents 1c21b8d + 82b0f11 commit e8bea65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2024 the original author or authors.
* Copyright 2009-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -235,7 +235,7 @@ private Configuration getConfiguration() {
+ FACTORY_METHOD + "] is not static.");
}

if (!factoryMethod.isAccessible()) {
if (!factoryMethod.canAccess(null)) {
configurationObject = AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
try {
factoryMethod.setAccessible(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2024 the original author or authors.
* Copyright 2009-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,7 +48,7 @@ public Object setup(OgnlContext context, Object target, Member member, String pr
Object result = null;
if (isAccessible(context, target, member, propertyName)) {
AccessibleObject accessible = (AccessibleObject) member;
if (!accessible.isAccessible()) {
if (!accessible.canAccess(target)) {
result = Boolean.FALSE;
accessible.setAccessible(true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2024 the original author or authors.
* Copyright 2009-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,13 +48,13 @@ private <T> T instantiateClass(Class<T> type, List<Class<?>> constructorArgTypes
Constructor<T> constructor;
if (constructorArgTypes == null || constructorArgs == null) {
constructor = type.getDeclaredConstructor();
if (!constructor.isAccessible()) {
if (!constructor.canAccess(null)) {
constructor.setAccessible(true);
}
return constructor.newInstance();
}
constructor = type.getDeclaredConstructor(constructorArgTypes.toArray(new Class[constructorArgTypes.size()]));
if (!constructor.isAccessible()) {
if (!constructor.canAccess(null)) {
constructor.setAccessible(true);
}
return constructor.newInstance(constructorArgs.toArray(new Object[constructorArgs.size()]));
Expand Down

0 comments on commit e8bea65

Please sign in to comment.