Interpreting the "Incompatible argument to function" exception message
Asked Answered
P

3

9

A quick question regarding the java.lang.VerifyError exception. Suppose I get an error that looks like this:

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!

Pilsudski answered 14/6, 2012 at 19:40 Comment(0)
B
7

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.

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!

Borrowing answered 14/6, 2012 at 19:43 Comment(2)
Thanks! The problem is, the type of the object being initialized does have two constructors, one taking a string and one taking a StreamReader as a parameter. There is no other version of the type that is missing the constructor that takes a string. This is bizarre. I have to find a way to step through this code.Pilsudski
We finally figured out that the loaded java classes were corrupt and had to force a reload of all the classes.Pilsudski
U
4

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.

Unscrupulous answered 14/6, 2012 at 19:55 Comment(1)
Thanks. I do agree it is likely related to a version mismatch.Pilsudski
T
0

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.

Tigrinya answered 29/2, 2016 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.