uschindler commented on code in PR #15864:
URL: https://github.com/apache/lucene/pull/15864#discussion_r2976204309


##########
lucene/core/src/java/org/apache/lucene/internal/tests/TestSecrets.java:
##########
@@ -31,26 +31,20 @@
  * initialized once on startup.
  */
 public final class TestSecrets {
-  static {
-    Consumer<Class<?>> ensureInitialized =
-        clazz -> {
-          try {
-            // A no-op forName here has a side-effect of ensuring the class is 
loaded and
-            // initialized.
-            // This only happens once. We could just leverage the JLS and 
invoke a static
-            // method (or a constructor) on the target class but the method 
below seems simpler.
-            // TODO: In Java 15 there's 
MethodHandles.lookup().ensureInitialized(clazz)
-            Class.forName(clazz.getName());
-          } catch (ClassNotFoundException e) {
-            throw new RuntimeException(e);
-          }
-        };
-
-    ensureInitialized.accept(ConcurrentMergeScheduler.class);
-    ensureInitialized.accept(SegmentReader.class);
-    ensureInitialized.accept(IndexWriter.class);
-    ensureInitialized.accept(FilterIndexInput.class);
-  }
+
+  private static final Consumer<Class<?>> ensureInitialized =

Review Comment:
   As we are on Java 21 (10.x) and Java 25 in main branch, please change the 
forName here to the code in the TODO comment.
   
   This will not avoid the try...catch block, but you can then change it to 
rethrow AssertionFailedError (because the lookup always has correct access).



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