Java
An object-oriented language running on the JVM, widely used for enterprise services and Android.
What do you want to prove about your Java code?
Where proofs can attach
Toolchains that verify Java directly, and those that verify what it compiles to. A proof about compiled code also relies on the compiler that produced it.
- Compiled from Languages that compile to Java
- Your codeJava
Verify Java directly
Ranked by stage, feature coverage and trust.
| Toolchain | Stage | Trust | Effort | Feature coverage |
|---|---|---|---|---|
| KeY Write JML specifications for sequential Java code; KeY's prover, mostly automatic with interactive steps when needed, proves the code meets them. | Stage 1 · Usable | 0/5 | Interactive | 7/14full, 3 partial |
Write new verified code that becomes Java
You write in a verification language; its compiler emits the code.
| Toolchain | Stage | Trust | Effort | Path |
|---|---|---|---|---|
| Dafny Write programs in Dafny with specifications; the verifier proves them through Boogie and Z3, then Dafny compiles the code to C#, Java, Go, JavaScript or Python. | Stage 1 · Usable | 1/5 | Auto-active | from Dafny: Java (Dafny compiler (Java backend), trusted) |
Feature coverage
Which language features each toolchain handles. Hover or focus a mark for the note and source. Toolchains on compiled code are shown for common features only.
| Feature | KeY |
|---|---|
| Common features | |
| Machine integersFixed-width integer arithmetic, overflow and bit operations. | KeY, Machine integers: Partial.Three settings exist. The default treats Java integers as unbounded mathematical integers, which KeY marks as unsound. "Java semantics" models overflow exactly, and "checking overflow" proves that no overflow happens. Source |
| Floating pointIEEE 754 floating-point arithmetic, including rounding and NaNs. | KeY, Floating point: Supported.Supported; needs an installed SMT solver with floating-point support. Source |
| Heap and pointersDynamically allocated memory, pointers or references, and aliasing. | KeY, Heap and pointers: Supported.Objects and references with an explicit heap model. Source |
| Arrays and buffersIndexed memory such as arrays, slices, vectors and byte buffers. | KeY, Arrays and buffers: Supported.Including multi-dimensional arrays, ArrayStoreException and out-of-bounds behavior. Source |
| LoopsUnbounded loops, which need invariants or bounds to verify. | KeY, Loops: Supported.Loop invariants; for-each loops are rewritten to indexed or iterator loops. Source |
| RecursionFunctions that call themselves, directly or through others. | KeY, Recursion: Supported.Recursive methods with measured_by clauses for termination. Source |
| Higher-order codeFunction pointers, closures and callbacks. | KeY, Higher-order code: Partial.Lambdas and method references are partly supported (turned into classes); lambdas in field initializers and anonymous classes are not. Source |
| Threads and shared memoryConcurrent threads with locks, atomics or message passing. | KeY, Threads and shared memory: Not supported.Multithreading is not supported. Source |
| I/O and system callsFiles, network, system calls and foreign-function calls. | KeY, I/O and system calls: Not supported.KeY has no model of the JVM runtime or I/O; library methods, including I/O, need stub classes with hand-written contracts. Source |
| Standard librarySpecifications or models for the language's standard library. | KeY, Standard library: Partial.Library classes must be on KeY's classpath, usually as stubs with contracts; KeY reports an error otherwise. Source |
| Java-specific features | |
| Objects and inheritanceClasses, interfaces, inheritance and dynamic dispatch. | KeY, Objects and inheritance: Supported.Classes, interfaces, inheritance and dynamic dispatch. Private and default interface methods load but cannot yet be proved about. Source |
| ExceptionsChecked and unchecked exceptions. | KeY, Exceptions: Supported.try/catch/finally, throw, multi-catch and try-with-resources. Source |
| GenericsGeneric classes and methods. | KeY, Generics: Not supported.Generics are not supported in any form; a separate tool can remove them before loading. Source |
| Threads and synchronizedJava threads, locks and the Java memory model. | KeY, Threads and synchronized: Not supported.Multithreading is not supported. Source |
Supported Partial Not supported Unknown
Formal semantics of Java
Models that proofs about Java can be stated against. See formal semanticsFormal semantics. A precise, mathematical definition of what programs in a language do..
None in the index yet.