wiki:JavaParty/Debugging

Debugging JavaParty Programs

Question: My JavaParty program crashes with the following exception, is this a problem in the JavaParty distribution? What are there cryptic identifiers for? I have no idea how to locate the reason for the exception!

java.lang.NullPointerException
    at mypackagea.MyClassA_instance_impl.myMethodA(/MyClassA_instance_impl.java)
    at mypackagea.MyClassA_instance_impl.myMethodB(/MyClassA_instance_impl.java)
    at mypackagea.MyClassA.myMethodB(/MyClassA.java)
    at mypackagea.MyClassB.myMethodC(/src/mypackagea/MyClassB.java)
    at mypackagea.MyClassB.myMethodD(/src/mypackagea/MyClassB.java)
    at mypackageb.MyClassC.myMethodE(/src/mypackageb/MyClassC.java)
    at mypackageb.MyClassD.myMethodF(/src/mypackageb/MyClassD.java)
    at mypackagec.MyClassE.run(/src/solverPack/MyClassE.java)
    at mypackaged.MyClassF.run(/src/problemMyClassFPack/MyClassF.java)
    at jp.lang.RemoteThread_instance_impl.run(/jp/lang/RemoteThread_instance_impl.java:79)
    at jp.lang.RemoteThread.run(/jp/lang/RemoteThread.java:491)
    at java.lang.Thread.run(Thread.java:484)

Answer: Most likely, this is no JavaParty-problem but an ordinary bug in your application. To track down the problem, you should do the following, to get more information where to start searching:

Use the -g compiler option

This option enables the generation of debugging information into your compiled class files. Rerunning your program, this will result in the additional output of line numbers in your stack trace.

java.lang.NullPointerException
    at mypackagea.MyClassA_instance_impl.myMethodA(/MyClassA_instance_impl.java:1062)
    at mypackagea.MyClassA_instance_impl.myMethodB(/MyClassA_instance_impl.java:276)
    at mypackagea.MyClassA.myMethodB(/MyClassA.java:192)

The JavaParty transformation splits your application classes into several classes for distributed execution. Here the exception occurs in your class mypackagea.MyClassA in your method myMethodA(). This method was moved into the generated class MyClassA_instance_impl by the JavaParty transformation.

Use the -genjpsource <directory> compiler option

This requires the JavaParty compiler to also output the Java source code after the JavaParty transformation to the directory specified by <directory>.

Because the JavaParty transformation alters your application source code for execution in the distributed environment, the line numbers printed in the exception stack trace always reflect line numbers in the generated code after the transformation. To find the line in your original program, where the exception occurred, open the generated file MyClassA_instance_impl.java and look at line 1062.

The generated JavaParty code after the transformation looks very similar to your original program, so you will easily find out the reason why your distributed program crashes. If you are still unsure which access cause the NullPointerException, you should insert some debugging output near the problematic line...

Last modified 11 years ago Last modified on Mar 23, 2006 12:41:12 AM