Posts Tagged ‘apache’

HttpClient & Java 5

Thursday, October 8th, 2009

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).