|
2 | 2 |
|
3 | 3 |  |
4 | 4 |
|
5 | | -## Welcome to LiquidJava |
| 5 | +## Welcome to LiquidJava! |
6 | 6 |
|
7 | | -LiquidJava is an additional type checker for Java that based on liquid types and typestates. |
| 7 | +LiquidJava is an additional type checker for Java, based on **liquid types** and **typestates**, which provides additional safety guarantees to Java programs through **refinements** at compile time. |
8 | 8 |
|
9 | | -Simple example: |
| 9 | +**Example:** |
10 | 10 |
|
11 | 11 | ```java |
12 | 12 | @Refinement("a > 0") |
13 | 13 | int a = 3; // okay |
14 | 14 | a = -8; // type error! |
15 | 15 | ``` |
16 | 16 |
|
17 | | -This project has the LiquidJava verifier, the API and some examples for testing. |
| 17 | +This project contains the LiquidJava verifier and its API, as well as some examples for testing. |
| 18 | + |
18 | 19 | You can find out more about LiquidJava in the following resources: |
19 | 20 |
|
20 | | -* [Try it](https://github.com/CatarinaGamboa/liquidjava-examples) with Codespaces or locally following these steps |
21 | | -* [Website](https://catarinagamboa.github.io/liquidjava.html) |
22 | | -* [Examples of LiquidJava](https://github.com/CatarinaGamboa/liquidjava-examples) |
23 | | -* [LiquidJava Specification of the Java Standard Library](https://github.com/CatarinaGamboa/liquid-java-external-libs) |
24 | | -* [VSCode plugin for LiquidJava](https://github.com/CatarinaGamboa/vscode-liquidjava) |
| 21 | +* [Try it](https://github.com/CatarinaGamboa/liquidjava-examples) with GitHub Codespaces or locally |
| 22 | +* [VS Code extension for LiquidJava](https://github.com/CatarinaGamboa/vscode-liquidjava) |
| 23 | +* [LiquidJava website](https://catarinagamboa.github.io/liquidjava.html) |
| 24 | +* [LiquidJava specification examples for the Java standard library](https://github.com/CatarinaGamboa/liquid-java-external-libs) |
25 | 25 | <!-- * [Formalization of LiquidJava](https://github.com/CatarinaGamboa/liquidjava-formalization) - not opensource yet --> |
26 | 26 |
|
27 | | -# Setup the project |
| 27 | +## Getting Started |
| 28 | + |
| 29 | +### VS Code Extension |
| 30 | + |
| 31 | +The easiest way to use LiquidJava is through its [VS Code extension](https://github.com/CatarinaGamboa/vscode-liquidjava), which uses the LiquidJava verifier directly inside VS Code, with error diagnostics and syntax highlighting for refinements. |
| 32 | + |
| 33 | +### Command Line |
| 34 | + |
| 35 | +For development, you may use the LiquidJava verifier from the command line. |
| 36 | + |
| 37 | +#### Prerequisites |
28 | 38 |
|
29 | | -## Prerequisites |
30 | 39 | Before setting up LiquidJava, ensure you have the following installed: |
31 | 40 |
|
32 | | -- Java 20 or newer - The project is configured to use Java 20; |
33 | | -- Maven 3.6+ - For building and dependency management. |
| 41 | +- Java 20+ - JDK for compiling and running Java programs |
| 42 | +- Maven 3.6+ - For building and dependency management |
34 | 43 |
|
35 | | -## Installation Steps |
| 44 | +#### Setup |
36 | 45 |
|
37 | | -1. Clone the repository: `git clone https://github.com/CatarinaGamboa/liquidjava.git`; |
38 | | -2. Build the project `mvn clean install`; |
39 | | -3. Run tests to verify installation: `mvn test`; |
40 | | -4. If importing into an IDE, import the project as a Maven project using the root `pom.xml`. |
| 46 | +1. Clone the repository: `git clone https://github.com/CatarinaGamboa/liquidjava.git` |
| 47 | +2. Build the project `mvn clean install` |
| 48 | +3. Run tests to verify installation: `mvn test` |
| 49 | +4. If importing into an IDE, import the project as a Maven project using the root `pom.xml` |
41 | 50 |
|
42 | | -## Verify Installation |
| 51 | +#### Run Verification |
43 | 52 |
|
44 | | -To check your refinements using LiquidJava: |
| 53 | +To run LiquidJava, use the Maven command below, replacing `/path/to/your/project` with the path to the Java file or directory you want to verify. |
45 | 54 |
|
46 | | -**Run verification on examples**: |
47 | 55 | ```bash |
48 | | -mvn exec:java -pl liquidjava-verifier -Dexec.mainClass="liquidjava.api.CommandLineLauncher" -Dexec.args="liquidjava-example/src/main/java/testSuite/CorrectSimpleAssignment.java" |
| 56 | +mvn exec:java -pl liquidjava-verifier -Dexec.mainClass="liquidjava.api.CommandLineLauncher" -Dexec.args="/path/to/your/project" |
49 | 57 | ``` |
50 | | - This should output: `Correct! Passed Verification`. |
51 | 58 |
|
52 | | -**Test an error case**: |
| 59 | +If you're on Linux/macOS, you can use the `liquidjava` script (from the repository root) to simplify the process. |
| 60 | + |
| 61 | +**Test a correct case**: |
53 | 62 | ```bash |
54 | | -mvn exec:java -pl liquidjava-verifier -Dexec.mainClass="liquidjava.api.CommandLineLauncher" -Dexec.args="liquidjava-example/src/main/java/testSuite/ErrorSimpleAssignment.java" |
| 63 | +./liquidjava liquidjava-example/src/main/java/testSuite/CorrectSimpleAssignment.java |
55 | 64 | ``` |
56 | | - This should output an error message describing the refinement violation. |
57 | 65 |
|
58 | | -## Run verification |
| 66 | +This should output: `Correct! Passed Verification`. |
59 | 67 |
|
60 | | -### In a specific project |
| 68 | +**Test an error case**: |
| 69 | +```bash |
| 70 | +./liquidjava liquidjava-example/src/main/java/testSuite/ErrorSimpleAssignment.java |
| 71 | +``` |
61 | 72 |
|
62 | | -Run the file `liquidjava-verifier\api\CommandLineLaucher` with the path to the target project for verification. |
63 | | -If there are no arguments given, the application verifies the project on the path `liquidjava-example\src\main\java`. |
| 73 | +This should output an error message describing the refinement violation. |
64 | 74 |
|
65 | | -## Testing |
| 75 | +#### Testing |
66 | 76 |
|
67 | 77 | Run `mvn test` to run all the tests in LiquidJava. |
68 | 78 |
|
69 | | -The starter test file is `TestExamples.java` which uses the test suite under the `liquidjava-examples/testSuite`. |
70 | | - |
71 | | -Paths in the test suite are considered test cases if: |
| 79 | +The starter test file is `TestExamples.java`, which runs the test suite under the `testSuite` directory in `liquidjava-example`. |
72 | 80 |
|
73 | | -1. File that start with `Correct` or `Error` (e.g, "CorrectRecursion.java") |
74 | | -2. Package/Folder that contains the word `correct` or `error`. |
| 81 | +The test suite considers test cases: |
| 82 | +1. Files that start with `Correct` or `Error` (e.g., `CorrectRecursion.java`) |
| 83 | +2. Packages or folders that contain the word `correct` or `error` (e.g., `arraylist_correct`) |
75 | 84 |
|
76 | | -Therefore, files/folders that do not pass this description are not verified. |
| 85 | +Therefore, the files and folders that do not follow this pattern are ignored. |
77 | 86 |
|
78 | | -## Project structure |
| 87 | +## Project Structure |
79 | 88 |
|
80 | | -* **docs**: documents used for the design of the language. The folder includes a readme to a full artifact used in the design process, here are some initial documents used to prepare the design of the refinements language at its evaluation |
81 | | -* **liquidjava-api**: inlcudes the annotations that can be introduced in the Java programs to add the refinements |
82 | | -* **liquidjava-examples**: includes a main folder with the current example that the verifier is testing; the test suite that is used in maven test is under the `testSuite` folder |
83 | | -* **liquidjava-verifier**: has the project for verification of the classes |
84 | | - * *api*: classes that test the verifier. Includes the `CommandLineLauncher` that runs the verification on a given class or on the main folder of `liquidjava-examples` if no argument is given. This package includes the JUnit tests to verify if the examples in `liquidjava-example/tests` are correctly verified. |
85 | | - * *ast*: represents the abstract syntax tree of the refinement's language. |
86 | | - * *errors*: package for reporting the errors. |
87 | | - * *processor*: package that handles the type checking. |
88 | | - * *rj_language*: handles the processing of the strings with refinements. |
89 | | - * *smt*: package that handles the translation to the SMT solver and the processing of the results the SMT solver produces. |
90 | | - * *utils*: includes useful methods for all the previous packages. |
91 | | - * *test/java/liquidjava/api/tests* contains the `TestExamples` class used for running the test suite. |
| 89 | +* **docs**: Contains documents used for the design of the language. This folder includes a [README](./docs/design/README.md) with the link to the full artifact used in the design process. It also contains initial documents used to prepare the design of the refinements language during its evaluation |
| 90 | +* **liquidjava-api**: Includes the annotations that can be introduced in the Java programs to add the refinements |
| 91 | +* **liquidjava-example**: Includes some examples and the test suite used for testing the verifier |
| 92 | +* **liquidjava-verifier**: Includes the implementation of the verifier. Its main packages are: |
| 93 | + * `api`: Includes the `CommandLineLauncher` that runs the verification on a given class or in the `currentlyTesting` directory if no argument is given |
| 94 | + * `ast`: Represents the Abstract Syntax Tree (AST) of the Refinements Language (RJ) |
| 95 | + * `errors`: Package for reporting the errors |
| 96 | + * `processor`: Package that handles the type checking |
| 97 | + * `rj_language`: Handles the parsing of the refinement strings to an AST |
| 98 | + * `smt`: Package that handles the translation to the SMT solver and the processing of the results the SMT solver produces |
| 99 | + * `utils`: Includes useful methods for all the previous packages |
| 100 | + * `test/java/liquidjava/api/tests`: Contains the `TestExamples` class used for running the test suite |
0 commit comments