Abacn commented on code in PR #39330:
URL: https://github.com/apache/beam/pull/39330#discussion_r3583630825
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/common/ReflectHelpers.java:
##########
@@ -52,11 +52,26 @@ public class ReflectHelpers {
private static final Joiner COMMA_SEPARATOR = Joiner.on(", ");
+ /**
+ * Returns the simple name of the given class, or a fallback simple name
derived from the class
+ * name if {@link Class#getSimpleName()} throws an exception (such as an
{@link
+ * IllegalAccessError} on Java 17+ for non-public inner classes).
+ */
+ public static String getSimpleName(Class<?> clazz) {
+ try {
+ return clazz.getSimpleName();
+ } catch (Throwable t) {
+ String name = clazz.getName();
+ int idx = Math.max(name.lastIndexOf('.'), name.lastIndexOf('$'));
+ return idx != -1 ? name.substring(idx + 1) : name;
+ }
+ }
Review Comment:
Done
--
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]