Java“NoSuchMethodError” [英] Java "NoSuchMethodError"

查看:123
本文介绍了Java“NoSuchMethodError”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到:

NoSuchMethodError: com.foo.SomeService.doSmth()Z

我是否正确理解这个'Z'表示返回类型doSmth()方法是boolean?如果为true,那么这种方法确实不存在,因为此方法返回一些Collection。但另一方面,如果我调用此方法,我不会将其返回值赋给任何变量。我只是这样调用这个方法:

Am I understanding correctly that this 'Z' means that return type of doSmth() method is boolean? If true, then that kind of method really does not exist because this method returns some Collection. But on the other hand if I call this method, I'm not assigning its return value to any variable. I just call this method like this:

service.doSmth();

出现此错误的任何想法?存在所有必需的JAR文件,并且此类中的所有其他方法似乎都存在。

Any ideas why this error occurs? All necessary JAR files exist and all other methods from this class seems to exist.

推荐答案

在编译期间看起来类似方法存在于类路径中,但在应用程序运行期间不存在。

Looks like method exists in classpath during compilation, but not during running of your application.

我不认为返回类型是个问题。如果是的话,就不会编译。当方法调用不明确时编译器抛出错误,并且当两个方法仅因返回类型而不同时。

I don't think return type is a problem. If it was, it wouldn't compile. Compiler throws error when method call is ambiguous, and it is when two methods differ only by return type.

这篇关于Java“NoSuchMethodError”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆