LiquidJava is an additional typechecker for Java that supports refinement types.
Simple example
@Refined("a > 0")
int a = 3; // okay
a = -8; // type error!- VSCode plugin for LiquidJava
- Examples of LiquidJava
- LiquidJava Specification of Java StdLib
- Formalization of LiquidJava
- Clone the repository;
- Open Eclipse and do
Ìmport...\ Existing Maven Projectselecting the folderliquidjava-umbrellaand waiting for the build process to finish (bottom right update bar) - Select the
liquidjava-umbrellafolder, right click it and selectRun as...\Maven install... - Select
liquidjava-verifier, on right-click, go toBuild Path\Link Source...and browse forliquidjava-verifier\target\generated-sources\antlr4and selectFinish
Run the file liquidjava-verifier\api\CommandLineLaucher with the path to the target project for verification.
If there are no arguments given, the application verifies the project on the path liquidjava-example\src\main\java.
Inside the folder liquidjava-verifier\api\tests are three classes that test several examples available at liquidjava-example\src\test\java.
To run the JUnit tests in one of the files, select it, right-click it and Run as...\JUnit tests.
To run the all test suit, select the package tests (liquidjava-verifier\api\tests), right-click it, and do Run as...\JUnit tests.
Make sure to run these tests after making changes in the verification code.
- liquidjava-api: inlcudes the annotations that can be introduced in the Java programs to add the refinements
- liquidjava-examples: includes a main folder with the current example that the verifier is testing; and inlcudes the classes for the tests
- liquidjava-verifier: has the project for verification of the classes
- api: classes that test the verifier. Includes the
CommandLineLauncherthat runs the verification on a given class or on the main folder ofliquidjava-examplesif no argument is given. This package includes the JUnit tests to verify if the examples inliquidjava-example/testsare correctly verified. - ast: represents the abstract syntax tree of the refinement's language.
- errors: package for reporting the errors.
- processor: package that handles the type checking.
- rj_language: handles the processing of the strings with refinements.
- smt: package that handles the translation to the smt solver and the processing of the results the smt solver produces.
- utils: includes useful methods for all the previous packages.
- api: classes that test the verifier. Includes the