Java 21 [#96932](https://github.com/elastic/elasticsearch/pull/96932) (`-Druntime.java=21`) breaks `java.util.List` lookups in Painless scripts.

```
invalid foreach loop: method [java.util.List, iterator/0] not found
member method [java.util.List, add/1] not found
member method [java.util.List, asCollection/0] not found
member method [java.util.List, asList/0] not found
member method [java.util.List, isEmpty/0] not found
member method [java.util.List, size/0] not found
member method [java.util.List, stream/0] not found
```

`:modules:lang-painless:test` (57 failures): https://gradle-enterprise.elastic.co/s/dkpi5pcitruwy
`:modules:lang-painless:yamlRestTest` (6 failures) https://gradle-enterprise.elastic.co/s/rsf3522r44ilc

```
java -version
openjdk version "21-ea" 2023-09-19
OpenJDK Runtime Environment (build 21-ea+27-2343)
OpenJDK 64-Bit Server VM (build 21-ea+27-2343, mixed mode, sharing)
```

Refs: https://github.com/elastic/elasticsearch/issues/96997
modules/lang-painless/src/main/java/org/elasticsearch/painless/lookup/PainlessLookup.java
}
    public List<PainlessMethod> lookupPainlessSubClassesMethod(String targetCanonicalClassName, String methodName, int methodArity) {
        Objects.requireNonNull(targetCanonicalClassName);
        Class<?> targetClass = canonicalTypeNameToType(targetCanonicalClassName);
        if (targetClass == null) {
            return null;
        }
        return lookupPainlessSubClassesMethod(targetClass, methodName, methodArity);
    }
    public List<PainlessMethod> lookupPainlessSubClassesMethod(Class<?> targetClass, String methodName, int methodArity) {
        Objects.requireNonNull(targetClass);
        Objects.requireNonNull(methodName);
        if (classesToPainlessClasses.containsKey(targetClass) == false) {
            return null;
        }
        if (targetClass.isPrimitive()) {
            targetClass = typeToBoxedType(targetClass);
            if (classesToPainlessClasses.containsKey(targetClass) == false) {
                return null;
            }
        }
        String painlessMethodKey = buildPainlessMethodKey(methodName, methodArity);
        Deque<Class<?>> subClasses = new ArrayDeque<>(classesToDirectSubClasses.get(targetClass));
        Set<Class<?>> resolvedSubClasses = new HashSet<>();
        List<PainlessMethod> subMethods = null;
        Class<?> subClass;
        while ((subClass = subClasses.pollFirst()) != null) {
            if (resolvedSubClasses.add(subClass)) {
                subClasses.addAll(classesToDirectSubClasses.get(subClass));
                PainlessClass painlessClass = classesToPainlessClasses.get(subClass);