For some reason, Java 1.5 won’t compile code if it can’t find the associated annotations for an exisiting class file.
Note that I’m not talking about it being unable to find an annotation you’ve attached to the source code you’re compiling. That’s fine. I’m talking about it being unable to find annotations attached to existing classes (like, say, HttpClient) and then refusing to compile the class because of that.
Now, I’m faily sure that they don’t impact anything to do with the runtime-code given that Eclipse ran it all without a problem. And apparently Java 6 will only give a warning. But Java 5 throws an error and tells me to file a bug report with Sun… Which is extremely unhelpful since it’s not actually a Sun problem. I just needed to include the JAR file on my compile path…
Anyway, the exact error I was getting was:
[javac] An exception has occurred in the compiler (1.5.0_19). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
[javac] com.sun.tools.javac.code.Symbol$CompletionFailure: file net/jcip/annotations/GuardedBy.class not found
I saw a bug report in the Java Bug Repo that mentioned Java pointing out the incorrect class when this happened, so I’m glad that’s fixed. Anyway, this is a known issue with HttpClient, as can be seen here. To download the JCIP Jar, wich has the annotation net.jcip.annotations.GuardedBy, go here.
Hopefully this will help someone (or me, if I ever forget what the hell I was thinking).
Tags: annotations, apache, bugs, httpclient, java, jcip
This bit you too, huh? The HttpClient developers were very responsive and have addressed the issue in svn. Still waiting for an official release though.
Oh yeah, they seemed to respond pretty quickly. But it was a little frustrating to find that it all worked fine in Eclipse but didn’t compile with Ant. Especially with the error message it produced, there were a few panicked minutes of ‘Oh crap, is my work machines Java install completely broken?!’
Thank you so much for this help… Your blog was one of the first that popped up in Google, and I was able to resolve this issue within 2 minutes. I reckon it probably would have take me quite a while not longer had you not made this post…
Matt
Thank you. It help me.
Thanks! This helped me!
Thanks, this helped a lot!
PS: Your link to the JCIP-Jar seems to be out-of-date, here is a current one: http://findjar.com/jar/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar.html