Wrong exception is caught

In running a .NET program using generated proxies to access Java classes, an exception is thrown from the Java-side, but the object that is caught is an instance of some other class. Why isn't the proper exception object being caught?

When an exception is thrown but no proxy has been generated for that exception's class, the JNBridgePro runtime uses the closest class in the superclass chain for which a generated proxy exists. Often this is java.lang.Object. To catch the actually thrown exception object, regenerate your proxy assembly, making sure that a proxy for the exception class is generated. Then, rebuild your program and run it again.

Even if you catch a java.lang.Object, you can obtain information about the underlying exception by accessing the object's properties JavaExceptionClass, JavaExceptionMessage, and JavaStackTrace to obtain strings representing the exception's class, message, and stack trace, respectively.