[JSR308] ClassNotFoundException using BasicChecker

Mahmood Ali mahmood at MIT.EDU
Wed Aug 12 11:16:43 EDT 2009


I am sorry that you are experiencing some difficulties with using the  
BasicChecker.  I would like to move the discussion to jsr308-bugs at lists.csail.mit.edu 
, the mailing list dedicated for tool bugs.

> I am getting a ClassNotFoundException using BasicChecker.
> I first compile the Encrypted class using:
> javac src/myquals/Encrypted.java
> Then I try to compile and check Test.java:
> javac -cp src -processor checkers.basic.BasicChecker
> -Aquals=myquals.Encypted src/myquals/Test.java
> But I receive the following error:
> java.lang.Error: java.lang.ClassNotFoundException: myquals/Encrypted
> Why am I not able to use my own annotation with BasicChecker?

It seems that there are two classpath variables here:
- classpath for the compiler to use for compilation
   '-cp src' sets the lookup path for the javac as it compiles  
- classpath for the JVM (ClassLoader more specifically) to load  
classes while compiling
   The compiler uses the CLASSPATH environment variable to lookup the  
classes to load.  checkers.jar for example live in the path.

While your Encrypted annotation is in the first classpath, ClassLoader  
cannot find it!  Hence you getting the error.

Try (if using *nix - Linux or MacOS):
$ CLASSPATH=src:$CLASSPATH javac -cp src -processor  
checkers.basic.BasicChecker \
   -Aquals=myquals.Encrypted src/myquals/Test.java

I don't know if you can do a one-liner in Windows, but I assume you  
can use set/export.

Thanks for reporting the problem.  We will document it in the manual,  
and hopefully have a better workaround.


More information about the JSR308 mailing list