加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

控制台中的Java消息 – 具有相同方法签名但不提供可分配类的两种

发布时间:2020-12-15 01:30:33 所属栏目:大数据 来源:网络整理
导读:在迁移到Java 1.8时,我在项目中升级了许多依赖项.它是基于4.3版本的应用程序,具有许多外部依赖性,例如:JMS,HTTP客户端,FTP,XML等. 当应用程序启动时,我现在在控制台中收到以下消息: Two methods with same method signature but not providing classes ass

在迁移到Java 1.8时,我在项目中升级了许多依赖项.它是基于4.3版本的应用程序,具有许多外部依赖性,例如:JMS,HTTP客户端,FTP,XML等.

当应用程序启动时,我现在在控制台中收到以下消息:

Two methods with same method signature but not providing classes
assignable?
“public final int
java.util.concurrent.ConcurrentHashMap$CollectionView.size()” and
“public abstract int java.util.Set.size()” please report!

知道这个错误信息是什么以及如何查找导致问题的jar?

另外,我可以在控制台上打印一些关于哪个类/线程/堆栈正在打印此错误的其他数据.

最佳答案
我设法查看github链接提供的代码,并弄清楚为什么你没有得到堆栈跟踪.它没有抛出异常.

资料来源:https://github.com/jkuhnert/ognl/blob/master/src/java/ognl/OgnlRuntime.java

private static MatchingMethod findBestMethod(List methods,Class typeClass,String name,Class[] argClasses) {
    MatchingMethod mm = null;
    IllegalArgumentException failure = null;
    for (int i = 0,icount = methods.size(); i < icount; i++) {
        // ...

        if (mm == null || mm.score > score) {
            mm = new MatchingMethod(m,score,report,mParameterTypes);
            failure = null;
        } else if (mm.score == score) {
            if (Arrays.equals(mm.mMethod.getParameterTypes(),m.getParameterTypes()) && mm.mMethod.getName().equals(m.getName())) {
                if (mm.mMethod.getDeclaringClass().isAssignableFrom(m.getDeclaringClass())) {
                    if (!retsAreEqual && !mm.mMethod.getReturnType().isAssignableFrom(m.getReturnType()))
                        System.err.println("Two methods with same method signature but return types conflict? ""+mm.mMethod+"" and ""+m+"" please report!");

                    mm = new MatchingMethod(m,mParameterTypes);
                    failure = null;
                } else if (!m.getDeclaringClass().isAssignableFrom(mm.mMethod.getDeclaringClass())) {
                    // this should't happen
                    System.err.println("Two methods with same method signature but not providing classes assignable? ""+mm.mMethod+"" and ""+m+"" please report!");
                } else if (!retsAreEqual && !m.getReturnType().isAssignableFrom(mm.mMethod.getReturnType()))
                    System.err.println("Two methods with same method signature but return types conflict? ""+mm.mMethod+"" and ""+m+"" please report!");
            } else {
                // ... cut out
            }
        }
    }
    if (failure != null)
        throw failure;
    return mm;
}

我已经删除了一堆代码.你的代码在字面上有一个注释声明不应该发生的地方失败.

哎呀.

无论如何,它不会导致失败,因为它实际上没有为失败分配任何东西,如果它在其他地方失败,它会抛出一个实际的堆栈跟踪.

我不知道为什么这个陈述会被触发,因为我不是反思专家.

!m.getDeclaringClass().isAssignableFrom(mm.mMethod.getDeclaringClass())

但是,它只是跳过并继续执行for循环,而不添加异常或执行任何其他操作.我认为它保留了第一个参数,并继续评估.

如果您仍然怀疑,请使用Maven将依赖关系树映射到此库,并查看是否存在不会破坏内容的更新版本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读