Bug 88842 - [docs] Strange errors wheb jdom-b9.jar is in classpath
Summary: [docs] Strange errors wheb jdom-b9.jar is in classpath
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2.1   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-23 08:20 EST by Koen Muilwijk CLA
Modified: 2006-04-04 14:11 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Koen Muilwijk CLA 2005-03-23 08:20:19 EST
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.
Comment 1 Koen Muilwijk CLA 2005-03-24 08:54:36 EST
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.
Comment 2 Adrian Colyer CLA 2005-04-06 09:05:42 EDT
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???)
Comment 3 Koen Muilwijk CLA 2005-04-13 03:39:05 EDT
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.
Comment 4 Adrian Colyer CLA 2005-10-28 06:21:59 EDT
a possible doc enhancement once we've cleared the decks for 1.5.0...