From 82b0f118d343c27a5a8d57ef6a098e7e7b0b14fd Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 5 Jan 2025 01:12:11 +0900 Subject: [PATCH] Replace deprecated `isAccessible()` with `canAccess()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We no longer support Java 8 👋 --- .../org/apache/ibatis/executor/loader/ResultLoaderMap.java | 4 ++-- .../apache/ibatis/scripting/xmltags/OgnlMemberAccess.java | 4 ++-- .../custom_collection_handling/CustomObjectFactory.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java b/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java index 29f1875e3da..1d4a1314b4c 100644 --- a/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java +++ b/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java @@ -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. @@ -235,7 +235,7 @@ private Configuration getConfiguration() { + FACTORY_METHOD + "] is not static."); } - if (!factoryMethod.isAccessible()) { + if (!factoryMethod.canAccess(null)) { configurationObject = AccessController.doPrivileged((PrivilegedExceptionAction) () -> { try { factoryMethod.setAccessible(true); diff --git a/src/main/java/org/apache/ibatis/scripting/xmltags/OgnlMemberAccess.java b/src/main/java/org/apache/ibatis/scripting/xmltags/OgnlMemberAccess.java index 33544b7ac24..d3b37cc5fae 100644 --- a/src/main/java/org/apache/ibatis/scripting/xmltags/OgnlMemberAccess.java +++ b/src/main/java/org/apache/ibatis/scripting/xmltags/OgnlMemberAccess.java @@ -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. @@ -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); } diff --git a/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomObjectFactory.java b/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomObjectFactory.java index 528b99bb975..b57225bb438 100644 --- a/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomObjectFactory.java +++ b/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomObjectFactory.java @@ -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. @@ -48,13 +48,13 @@ private T instantiateClass(Class type, List> constructorArgTypes Constructor 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()]));