Java21 introduced List.getFirst() and getLast(). So now this happens only in Java21 (jruby-9.4.9.0) because JRuby is calling the Java method. The same code runs fine ...
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.IllegalAccessException: class RJavaTools cannot access a member of class java.util ...