Welcome to the LiquidJava examples repository!
This collection demonstrates how to use LiquidJava, a powerful extension for Java that enables expressive type refinements through annotations. Whether you're new to LiquidJava or looking to deepen your understanding, these examples will help you explore its capabilities and learn how to enhance your Java code with sophisticated type checking.
For more information about LiquidJava, visit our website!
🚀 Check the following video on the setup:

- Open the repository in GitHub Codespaces or use VS Code's "Remote-Containers: Open Folder in Container" command.
- Install the extension: View → Extensions → Click on the "..." (More Actions) button → Install from VSIX →
/workspaces/liquidjava-examples/extension/liquid-java-0.0.15.vsix. - After the information that the extension is activated, do
Ctrl + Shift + Pand writeDeveloper: Reload Window - Open examples: File → Open Folder →
examples/demo/src/. - You can try changing the example to see an error appear.
- If needed, reload window again using
Developer: Reload Window.
- The extension may take some time to be activated. While a small wheel in the bottom right of VS Code window is spinning, the extension is being loaded.
- The extension will only activate when opening a Java project with the liquidjava-api.jar present.
If the automatic setup didn't work correctly, follow these manual steps:
-
Install Git LFS if not already installed:
sudo apt-get update && sudo apt-get install -y git-lfs git lfs install -
Pull LFS files:
git lfs pull
-
Install the extension:
- In VS Code, go to the Extensions view (View → Extensions)
- Click on the "..." (More Actions) button
- Select "Install from VSIX..."
- Navigate to
extension/liquid-java-0.0.15.vsixin the repository - Click "Install"
Alternatively, use the terminal:
code --install-extension extension/liquid-java-0.0.15.vsix
-
Ensure the redhat extension for Language Support for Java™ is installed and enabled.
-
Open examples:
- Go to File → Open Folder → examples/demo/src/
- Or use the terminal:
code examples/demo/src/
If you see "End of central directory record signature not found" or similar errors:
-
This is likely a Git LFS issue. Make sure Git LFS is installed and run:
git lfs pull
-
Verify the VSIX file isn't just a pointer:
cat ./extension/liquid-java-0.0.15.vsix | head
- Ensure your project is correctly set up with the
liquidjava-api.jar. - When opening a Java file, the extension will automatically verify your LiquidJava annotations.
- Errors will be highlighted directly in your code editor.
examples/demo/lib folder contains the api jar that you can use in your projects.
liquidjava-examples/
├── examples/
│ ├── demo/ # Simple demo examples
│ │ ├── src/main/java/com/example # Examples start with "Test*.java"
├── user_study_23/ # Example projects used for user study of 2023
│ ├── part1-plainJava/ # Java projects without LiquidJava
│ ├── part3-liquidJava/ # Projects with LiquidJava annotations
│ └── part4/ # Files to be annotated with LiquidJava
├── extension/ # Contains the VSIX extension file
...
Contains Java projects without LiquidJava. Open one of the folders on VS Code and find the error.
Contains LiquidJava projects.
Open one of the folders on VS Code with the extension running. Uncomment the code in the Test file and find the error. You can open the folder through the terminal by going to the correct path and typing code or open through the VS Code GUI.
Contains Java files to be annotated with LiquidJava.
- Variable.java - Add the annotation and check the correct and wrong assignment
- TrafficLight.java - Add the annotations on the fields and model the state using
@StateSetand@StateRefinement. To check if the modelling is correct, uncomment the fileTestTLCorrect.java(that should be correct) and then uncomment the fileTestTLWrong.javathat should present an error.
For extension development:
- Refer to the VS Code Extension API documentation
- Make changes to your code and test using the provided examples
- Use the debug console to troubleshoot any issues