Copilot commented on code in PR #12015:
URL: https://github.com/apache/gravitino/pull/12015#discussion_r3578804778
##########
core/src/main/java/org/apache/gravitino/utils/IsolatedClassLoader.java:
##########
@@ -178,6 +178,14 @@ protected Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundE
}
private Class<?> doLoadClass(String name, boolean resolve) throws
Exception {
+ if (!name.contains(".")) {
+ try {
+ return getRootClassLoader().loadClass("java.lang." + name);
+ } catch (ClassNotFoundException e) {
+ // Fall through to normal loading for generated classes or non-JDK
simple names.
+ }
+ }
Review Comment:
The new java.lang simple-name resolution uses
getRootClassLoader().loadClass(...), which adds reflective lookup overhead and
can NPE if getRootClassLoader() returns null (e.g., pre-Java 9). You can
delegate to URLClassLoader’s normal parent-first loading for the fully
qualified java.lang name, which also respects the resolve flag.
--
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]