Hello!
I've been playing with it. I wrote only one source file, Main.java,
which contains the interface Time and the class Main. Using NetBeans,
I added the @Contracted annotation to the Main class and the compiler
produced the contract files (Time.contracts, Main.contracts and Time
$com$google$java$contract$H.class). Then, I tried to run the project
with -javaagent:../ccofoja-1.0-20110213.jar and I got the following
error:
Exception in thread "main" java.lang.NoClassDefFoundError: cofoja/Time
$com$google$java$contract$H
at
cofoja.Main.com$google$java$contract$P$setHour(Main.java)
at cofoja.Main.setHour(Main.java)
at cofoja.Main.main(Main.java:15)
Caused by: java.lang.ClassNotFoundException: cofoja.Time$com$google
$java$contract$H
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 3 more
Java Result: 1
However, I tried the command line and it worked!
prompt>java -javaagent:../../ccofoja-1.0-20110213.jar -jar cofoja.jar
Exception in thread "main" com.google.java.contract.PreconditionError:
h <= 23
at cofoja.Time$com$google$java$contract$H.com$google$java
$contract$PH$co
foja$Time$setHour(Time.java:40)
at cofoja.Main.setHour(Main.java)
at cofoja.Main.main(Main.java:15)
On 6 mar, 21:20, David Smith <
packetsp...@gmail.com> wrote:
> Never mind - Good groups email, ops.
>
>
>
>
>
>
>
> On Sun, Mar 6, 2011 at 3:20 PM, David Smith <
packetsp...@gmail.com> wrote:
> > Did you check to see if the @Con~ was annotated correctly?
>
> > BTW how did i get on this trail?
>
> > On Fri, Mar 4, 2011 at 9:50 AM, David Morgan ☯ <
davidmor...@google.com>wrote:
>
> >> Leonardo just checked locally and it looks like the @Contracted check
> >> may not be working -- in which case adding @Contracted should fix your
> >> problem.
>
> >> Please try it and let us know :)
>
> >> Cheers
>
> >> David
>
> >> On Fri, Mar 4, 2011 at 15:19, David Morgan ☯ <
davidmor...@google.com>
> >> wrote:
> >> > Hi Jose,
>
> >> > Glad that you like it!
>
> >> > The annotation processor only sees classes that have one of our
> >> > annotations on them. So, since your Main class has no contract
> >> > annotations, it will need the special @Contracted annotation at the
> >> > class level.
>
> >> > To make this less of a worry there is a check at runtime for the
> >> > @Contracted annotation; the fact that it didn't fire suggests that the
> >> > javaagent flag is not being passed.
>
> >> > So, some concrete suggestions:
> >> > - Check that the contracts are compiled; alongside the output .class
> >> > files you should have contract files
> >> > - Add the @Contracted annotation and see if that makes a difference
> >> > - Try running the output directly using "java -javaagent:<cofoja jar>
> >> > Main" on the command line
>
> >> > Hope that helps,
>
> >> > David
>
> >> > On Fri, Mar 4, 2011 at 14:54, josemari <
wyatt.earp.1848.1...@gmail.com>