java - 为什么URLClassPath的getResources函数的返回值对象多了两个字段?

标签 java spring-boot

我正在阅读Spring Boot的源代码。我在阅读SpringFactoriesLoader.loadFactoryNames时发现一个问题。 URLClassPath.getResources返回 Enumeration<Resource> 的执行情况,但该值有额外的两个字段 namecheck 。那么,什么时候将这两个字段添加到返回值中呢?

public Enumeration<Resource> getResources(final String var1, final boolean var2) {
        return new Enumeration<Resource>() {
            private int index = 0;
            private int[] cache = URLClassPath.this.getLookupCache(var1);
            private Resource res = null;

            private boolean next() {
                if (this.res != null) {
                    return true;
                } else {
                    do {
                        URLClassPath.Loader var1x;
                        if ((var1x = URLClassPath.this.getNextLoader(this.cache, this.index++)) == null) {
                            return false;
                        }

                        this.res = var1x.getResource(var1, var2);
                    } while(this.res == null);

                    return true;
                }
            }

            public boolean hasMoreElements() {
                return this.next();
            }

            public Resource nextElement() {
                if (!this.next()) {
                    throw new NoSuchElementException();
                } else {
                    Resource var1x = this.res;
                    this.res = null;
                    return var1x;
                }
            }
        };
    }

我使用Intellij调试程序,结果是

Debug Result

最佳答案

在本例中,Result 实例是一个匿名类,它捕获 getResources 参数 (final String var1, Final boolean var2) 的值。

关于java - 为什么URLClassPath的getResources函数的返回值对象多了两个字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55354378/

相关文章:

java - JAVA翻译程序

java - Spring Boot 的 Rest API 和 Web 服务

java - 如何更改Json格式?

java - 为什么 com.netflix.spectator.api.Counter 会产生 "normalized"值?

java - 在多线程环境下使用 HashMap

java - 创建对象[同一实例的多个]

java - OpenGL ES 2 - 顶点的颜色和纹理

java - 控制打印页面上面板的大小

java - 一对多关系支持读取但不支持插入

java - 返回已连接完整实体的选定属性