private Permissions compute()

in src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java [287:320]


    private Permissions compute(final Class<?> clazz, final boolean store) {
        // belt and suspender; recursion should not lead here
        if (clazz == null) {
            return BLOCK_ALL;
        }
        final String className = clazz.getName();
        Permissions permissions = sandbox.get(className);
        if (permissions == null) {
            if (inherit) {
                // find first inherited interface that defines permissions
                final Class<?>[] interfaces = clazz.getInterfaces();
                for (int i = 0; permissions == null && i < interfaces.length; ++i) {
                    permissions = inheritable(compute(interfaces[i], false));
                }
                // nothing defined yet, find first superclass that defines permissions
                if (permissions == null) {
                    // let's recurse on super classes
                    final Class<?> superClazz = clazz.getSuperclass();
                    if (Object.class != superClazz) {
                        permissions = inheritable(compute(superClazz, false));
                    }
                }
            }
            // nothing was inheritable
            if (permissions == null) {
                permissions = allow ? ALLOW_ALL : BLOCK_ALL;
            }
            // store the info to avoid doing this costly look-up
            if (store) {
                sandbox.put(className, permissions);
            }
        }
        return permissions;
    }