OnJava8-Examples/verifying/LoaderAssertions.java
Bruce Eckel 003be8a597 Added "Verifying Your Code" Chapter
Incorporated/Removed associated appendices
2016-08-09 13:34:35 -06:00

28 lines
750 B
Java

// verifying/LoaderAssertions.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using the class loader to enable assertions
// {ThrowsException}
public class LoaderAssertions {
public static void main(String[] args) {
ClassLoader.getSystemClassLoader()
.setDefaultAssertionStatus(true);
new Loaded().go();
}
}
class Loaded {
public void go() {
assert false: "Loaded.go()";
}
}
/* Output:
___[ Error Output ]___
Exception in thread "main" java.lang.AssertionError:
Loaded.go()
at Loaded.go(LoaderAssertions.java:15)
at LoaderAssertions.main(LoaderAssertions.java:9)
*/