JnRouvignac commented on a change in pull request #76:
URL: https://github.com/apache/jclouds/pull/76#discussion_r445865014



##########
File path: core/src/main/java/org/jclouds/reflect/Reflection2.java
##########
@@ -153,15 +153,23 @@
          .newBuilder().build(new CacheLoader<TypeToken<?>, Set<Invokable<?, 
?>>>() {
             public Set<Invokable<?, ?>> load(TypeToken<?> key) {
                ImmutableSet.Builder<Invokable<?, ?>> builder = 
ImmutableSet.<Invokable<?, ?>> builder();
-               for (Constructor<?> ctor : 
key.getRawType().getDeclaredConstructors()) {
-                  ctor.setAccessible(true);
+               Class<?> raw = key.getRawType();
+               for (Constructor<?> ctor : raw.getDeclaredConstructors()) {
+                  if (!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()`

Review comment:
       Given the javadoc of  
[`AccessibleObject.isAccessible()`](https://docs.oracle.com/javase/9/docs/api/java/lang/reflect/AccessibleObject.html#isAccessible--),
 it looks almost certain that `ctor.isAccessible()` will return false for that 
package private constructor of String, and so `ctor.setAccessible(true)` will 
be called anyway and we will get the illegal access warning again. Our code is 
not calling  `ctor.setAccessible(true)` at all.
   
   Even when using 
[`AccessibleObject.canAccess()`](https://docs.oracle.com/javase/9/docs/api/java/lang/reflect/AccessibleObject.html#canAccess-java.lang.Object-),
 it will return false in our case and code will end up calling 
`ctor.setAccessible(true)`, thus we will still get the illegal access warning.
   
   Am I missing or misunderstanding something?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to