java 解释“与函数不兼容的参数”异常消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11040206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Interpreting the "Incompatible argument to function" exception message
提问by Zoomzoom
A quick question regarding the java.lang.VerifyError exception. Suppose I get an error that looks like this:
关于 java.lang.VerifyError 异常的一个快速问题。假设我收到一个如下所示的错误:
Java call terminated by uncaught Java exception: java.lang.VerifyError:(class: com/.../MyClassName, method: <init> signature: (Ljava/io/Reader;)V) Incompatible argument to function
Could you help me with understanding what the "init" and what the "(Ljava/io/Reader;)V)" parts pertain to? They don't look like method names or signatures to me, but I'm not too familiar with java. Thanks!
你能帮我理解“init”和“(Ljava/io/Reader;)V)”部分的含义吗?对我来说,它们看起来不像方法名称或签名,但我对 java 不太熟悉。谢谢!
采纳答案by templatetypedef
This error means that somewhere in your code, you tried to call a constructor (the <init>
method) passing in the wrong set of arguments. The expected argument was a Reader
object.
此错误意味着在您的代码中的某处,您试图调用<init>
传入错误参数集的构造函数(方法)。预期的参数是一个Reader
对象。
This probably meant that you previously compiled a class file, then changed the class definition in some way without recompiling the class file. Consequently, your code tries to call a function that no longer exists. Try recompiling the code and see if that fixes it.
这可能意味着您之前编译了一个类文件,然后在没有重新编译类文件的情况下以某种方式更改了类定义。因此,您的代码会尝试调用不再存在的函数。尝试重新编译代码,看看是否可以修复它。
Hope this helps!
希望这可以帮助!
回答by Udo Held
If you are running your application on an application server, it could be a class loading problem.
如果您在应用程序服务器上运行应用程序,则可能是类加载问题。
You compiled your code against a library and when you try to run your code it is running against a different (older?) version of the library.
您针对库编译了代码,当您尝试运行代码时,它正在针对库的不同(较旧?)版本运行。
The older library probably doesn't have that method or constructor.
较旧的库可能没有该方法或构造函数。
回答by Stefano Cazzola
Just to leave track of a different cause.
只是为了留下不同的原因。
Always on an application server (in my case WildFly 10), you might be loading the same library on a modules and on the EAR lib. If this library contains an interface that needs to be implemented by the module, this might cause a conflict since the same class / interface loaded by two different class loaders are considered to be two different types.
总是在应用程序服务器上(在我的例子中是 WildFly 10),您可能会在模块和 EAR 库上加载相同的库。如果这个库包含需要由模块实现的接口,这可能会导致冲突,因为两个不同的类加载器加载的同一个类/接口被认为是两种不同的类型。