Community
Participate
Working Groups
For some strange reason mysterious error messages appear when running a woven jar file with jdom-b9.jar in the classpath. When jdom-b9.jar is replaced with jdom.jar the problems disappear. Setup: using the ant iajc task to compile the sources works as expected (without error messages) Running the generated jar (as junit tests) causes errors like: Exception while initializing nl_uu_tracing_AbstractTrace: java.lang.VerifyError: (class: nl/uu/retrieval/XmlInfoDocument, method: StoreNode signature: (Lnl/uu/retrieval/IInfoNode;Lnl/uu/retrieval/ITracingInfoWriter;)V) Incompatible argument to function org.aspectj.lang.NoAspectBoundException: Exception while initializing nl_uu_tracing_AbstractTrace: java.lang.VerifyError: (class: nl/uu/retrieval/XmlInfoDocument, method: StoreNode signature: (Lnl/uu/retrieval/IInfoNode;Lnl/uu/retrieval/ITracingInfoWriter;)V) Incompatible argument to function at nl.uu.tracing.AbstractTrace.aspectOf(AbstractTrace.aj) at com.puppycrawl.tools.checkstyle.UtilsTest.testLengthExpandedTabs(UtilsTest.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) Caused by: java.lang.VerifyError: (class: nl/uu/retrieval/XmlInfoDocument, method: StoreNode signature: (Lnl/uu/retrieval/IInfoNode;Lnl/uu/retrieval/ITracingInfoWriter;)V) Incompatible argument to function at nl.uu.tracing.AbstractTrace.createXmlFile(AbstractTrace.aj:241) at nl.uu.tracing.AbstractTrace.<init>(AbstractTrace.aj:57) at nl.uu.tracing.AbstractTrace.ajc$postClinit(AbstractTrace.aj) at nl.uu.tracing.AbstractTrace.<clinit>(AbstractTrace.aj:51) at com.puppycrawl.tools.checkstyle.UtilsTest.testLengthExpandedTabs(UtilsTest.java) the nl.uu.tracing namespace contains the aspect (AbstractTrace) which is woven through the checkstyle unit test suite. nl.uu.retrieval contains classes for saving the retrieved information. The exact working is not relevant, but the error message is very confusing. Work around: remove jdom-b9.jar from the classpath. This error occurs in 1.5 M1 as well.
The problem seemed to be caused by version problems between the different jdom versions. The nl.uu.retrieval package is compiled with jdom.jar. The actual object passed to StoreNode is an extension of a jdom.Element ant implements nl.uu.retrieval.IInfoNode. It seems that the class veriefier expected a different version (from jdom-b9.jar) then was actually passed (from jdom.jar). But the error message is very confusing. Maybe the aspectj compiler can check for these kind of version problems at compile time? That would make it easier to fix the problem then such cryptic runtime exceptions.
Just to check I've understood the scenario correctly... which version of jdom did you have on the classpath when weaving your application? Sounds like it was jdom.jar? And then at runtime you replaced jdom.jar with jdom-b9.jar (or at least had jdom-b9.jar ahead of jdom.jar in your classpath)? Then the problem arises that there is an incompatible class change between the jdom and jdom-b9 libraries, and this is detected at runtime but with a confusing error message? (I don't see how we could put out a compile-time warning for a library change that will happen at some later point and of which we have no knowledge when compiling???)
Yep, you are completly right. It will be almost impossible to provide a nice solution for this problem since you can only detect it at runtime. A possible solution is to include exception handling code into the woven code that catches this exception and gives a better error description. But this would probably have to much overhead. However, it might be useful to include this problem into the documentation or FAQ. Then will make it easier for others who run into similar problems to solve the problem. It took me quite some time to find this solution as I couldn't find any docs on it.
a possible doc enhancement once we've cleared the decks for 1.5.0...