This is an automated email from the ASF dual-hosted git repository.
nacx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jclouds.git
The following commit(s) were added to refs/heads/master by this push:
new 9e4c7a1 JCLOUDS-1542 follow-up: check whether isAccessible() is
already set (#79)
9e4c7a1 is described below
commit 9e4c7a16daeb97f9b51b9077e40d12ce5343840f
Author: Jean-Noël Rouvignac <[email protected]>
AuthorDate: Sun Jul 5 23:33:07 2020 +0200
JCLOUDS-1542 follow-up: check whether isAccessible() is already set (#79)
AccessibleObject.canAccess() would be much much better,
but this API can only be used from Java 9 onward.
---
core/src/main/java/org/jclouds/reflect/Reflection2.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/core/src/main/java/org/jclouds/reflect/Reflection2.java
b/core/src/main/java/org/jclouds/reflect/Reflection2.java
index 7d1caf1..8787434 100644
--- a/core/src/main/java/org/jclouds/reflect/Reflection2.java
+++ b/core/src/main/java/org/jclouds/reflect/Reflection2.java
@@ -155,7 +155,8 @@ public class Reflection2 {
ImmutableSet.Builder<Invokable<?, ?>> builder =
ImmutableSet.<Invokable<?, ?>> builder();
Class<?> raw = key.getRawType();
for (Constructor<?> ctor : raw.getDeclaredConstructors()) {
- if (!coreJavaClass(raw)) {
+ // TODO replace isAccessible() with canAccess() when using
Java >= 9
+ if (!ctor.isAccessible() && !coreJavaClass(raw)) {
// In JDK 11 up to 14, the only uses for
`java.beans.ConstructorProperties` annotation
// are in the `java.awt`, `java.beans` and `javax.swing`
packages.
// Since these constructors are public, there is no need
to call `setAccessible()`
@@ -167,7 +168,8 @@ public class Reflection2 {
if (Modifier.isAbstract(raw.getModifiers())) {
for (Invokable<?, Object> method : methods(raw)){
if (method.isStatic() &&
method.getReturnType().equals(key)) {
- if (!coreJavaClass(raw)) {
+ // TODO replace isAccessible() with canAccess() when
using Java >= 9
+ if (!method.isAccessible() && !coreJavaClass(raw)) {
method.setAccessible(true);
}
builder.add(method);
@@ -325,7 +327,8 @@ public class Reflection2 {
if (raw == Object.class)
continue;
for (Method method : raw.getDeclaredMethods()) {
- if (!coreJavaClass(raw)) {
+ // TODO replace isAccessible() with canAccess() when
using Java >= 9
+ if (!method.isAccessible() && !coreJavaClass(raw)) {
method.setAccessible(true);
}
builder.add(key.method(method));