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

时间:2017-01-12 19:34:22

标签: java spring

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

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

  

具有相同方法签名但不提供类的两种方法   可分配?“public final int   java.util.concurrent.ConcurrentHashMap $ CollectionView.size()“和   “public abstract int java.util.Set.size()”请报告!

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

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

1 个答案:

答案 0 :(得分:3)

我设法查看了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, score, report, 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;
}

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

糟糕。

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

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

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

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

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