LuciferYang opened a new issue, #7686:
URL: https://github.com/apache/kyuubi/issues/7686

   ### Description
   
   The three `hiddenImpl` builders in `kyuubi-util`'s vendored `reflect` 
package call `setAccessible` on the member they just looked up:
   
   ```java
   try {
     Method hidden = targetClass.getDeclaredMethod(methodName, argClasses);
     AccessController.doPrivileged(new MakeAccessible(hidden));
     this.method = new UnboundMethod(hidden, name);
   } catch (SecurityException | NoSuchMethodException e) {
     // unusable or not the right implementation
   }
   ```
   
   `setAccessible` on a member of a package that is not open throws 
`java.lang.reflect.InaccessibleObjectException` — since JDK 9 for named 
modules, and by default from the unnamed module since JDK 16. It is a 
`RuntimeException`, and none of the three catch clauses match it, so it escapes 
the builder. Every candidate registered after the inaccessible one is never 
tried, and the public-lookup `.impl(...)` fallback that usually follows never 
runs.
   
   The shape that breaks is the one `ReflectUtils` uses throughout the engines:
   
   ```scala
   // 
kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/reflect/ReflectUtils.scala
   val field = DynFields.builder
     .hiddenImpl(clz, fieldName)
     .impl(clz, fieldName)      // never reached when hiddenImpl throws
   ```
   
   Reproducer on JDK 16+ without `--add-opens`:
   
   ```java
   DynFields.builder()
       .hiddenImpl("java.math.BigInteger", "signum")
       .impl(String.class, "value")
       .build();
   
   // java.lang.reflect.InaccessibleObjectException: Unable to make field final 
int
   //   java.math.BigInteger.signum accessible: module java.base does not 
"opens java.math"
   //   to unnamed module @1b069fdf
   ```
   
   Expected: the inaccessible candidate counts as a miss and the chain 
continues to the next implementation.
   
   ### Affected code
   
   - `DynMethods.Builder.hiddenImpl(Class, String, Class...)`
   - `DynFields.Builder.hiddenImpl(Class, String)`
   - `DynConstructors.Builder.hiddenImpl(Class, Class...)`
   
   ### Upstream
   
   Neither upstream copy catches it either: parquet-common's 
`DynMethods`/`DynConstructors` and iceberg-common's 
`DynMethods`/`DynFields`/`DynConstructors` all catch only `SecurityException` 
plus the `NoSuchMethod`/`NoSuchField` variant, on current master as well as on 
the releases these files were copied from. So this is a divergence Kyuubi has 
to carry rather than something a newer upstream release would bring in.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to