Exercises with JML and ESC/Java2<TITLE> </HEAD> <p> <body> <h2>Bag and Amount exercises</h2> For these exercises, you should specify the two classes <ol> <li> <a href="Bag.java">Bag.java</a> <li> <a href="Amount.java">Amount.java</a> </ol> with JML and run ESC/Java2 to verify these specifications. Simply put, you run ESC/Java2 on these files and if the tool produces some warning, you <ul> <li> <em>either</em> add annotation to the code (eg to document invariants, preconditions, or postconditions) <li> <em>or</em> fix bugs in the code </ul> to make the warning go away. You have to use your own best judgement to choose between these two options, but there are some deliberate bugs in the code for you to detect, with the help of the tool. Note that there are some deliberate errors in the code for you to find. <p> For Amount.java you must also try to formalise the informal invariant that is discussed in the file as a JML invariant, which should reveal some more problems in the code. <p> In the end, ESC/Java2 should run without any complaints on the annotated code. ESC/Java2 complains (among other things) if it thinks a runtime exception may occur, say a NullPointerException, so if ESC/Java2 runs without complaints this means it has verified that no runtime exceptions can occur. <p> <b>More detailed instructions are given <u><em>in</em></u> the Java files. Read these!</b> <p> </body> </html>