Skip to the content.

Contributing to Java Version Manager for Windows

🏠 Overview  •  📦 Installation  •  📖 Usage  •  🏗️ Architecture  •  🏢 Enterprise  •  🔒 Locking  •  🌐 Networking  •  🐚 Shells  •  🎯 Threat Matrix  •  ❓ FAQ  •  ⚖️ SDKMAN! Comparison  •  📜 Changelog  •  🛡️ Security  •  🤝 Contributing  •  💬 Support


First off, thank you for considering contributing! It’s developers like you that keep this tool fast, secure, and rock-solid for the Windows engineering community.


🛠️ Local Development & Sandbox Testing

Because jvm.bat actively modifies system and user environment variables (PATH, JAVA_HOME), testing changes directly in your primary environment can disrupt your local development workflow. Follow these sandbox testing practices:

1. Isolated Execution (Local Checkout vs. Global PATH)

When testing local changes in your cloned repository, invoke the script directly from your working directory rather than relying on the installed command:

# In CMD or PowerShell, run the local working copy directly:
.\jvm.bat list
.\jvm.bat current
.\jvm.bat which
.\jvm.bat 21 --session

[!NOTE] Remember: If you already have JVM installed and present in your system PATH, simply typing jvm will invoke the globally installed executable rather than your local working copy. When developing and testing locally, always prefix the command with .\ (e.g. .\jvm.bat list or .\jvm.bat 21 --session). PowerShell argument tab-completion natively supports all three invocation styles: jvm <Tab>, jvm.bat <Tab>, and .\jvm.bat <Tab>! Once installed into PATH, standard users run jvm without prefixes from any directory.

2. Testing Session Switching (Zero System Impact)

Always use the --session flag during manual CLI testing. This mutates only the memory of the active subshell process and leaves your global Windows Registry and User environment untouched:

# CMD subshell verification:
cmd.exe /c ".\jvm.bat 21 --session && java -version"

[!TIP] In PowerShell, running .\jvm.bat 21 --session spawns a transient child cmd.exe process, so session environment mutations do not persist into the parent PowerShell process. The global jvm command in PowerShell persists session variables because it is wrapped by the PowerShell $PROFILE hook function (function jvm). When developing locally in PowerShell, use the cmd.exe /c pattern above to test session switching.

3. Dedicated Sandbox Testing

To test directory junction creation and candidate downloads in total isolation, redirect the storage root temporarily before launching jvm.bat:

set "LOCALAPPDATA=%TEMP%\JVM_Sandbox"
.\jvm.bat list

🧪 Automated Test Suite Execution

All contributions are subject to two automated test suites before being merged into main:

1. Security, Error Management & Adversarial Test Suite (tests/Test-JvmSecurity.ps1)

The repository includes an exhaustive 327-test automated adversarial security test suite across 16 suites covering 41 MITRE CWE classes (including CWE-798) with a verified 10.0 / 10.0 scorecard. Our automated GitHub Actions CI pipeline continuously validates all 327 tests concurrently across both native Windows PowerShell 5.1 and modern PowerShell 7+ (Core) to guarantee full cross-version compatibility. This suite validates input sanitization, reparse point operations, atomic failure-path rollbacks, handle disposal, and exit code propagation:

# Run using modern PowerShell 7+ (Recommended):
pwsh -NoProfile -ExecutionPolicy Bypass -File .\tests\Test-JvmSecurity.ps1

# Or run using native Windows PowerShell 5.1:
powershell -NoProfile -ExecutionPolicy Bypass -File .\tests\Test-JvmSecurity.ps1

# Run with verbose diagnostic outputs and test millisecond durations:
pwsh -NoProfile -ExecutionPolicy Bypass -File .\tests\Test-JvmSecurity.ps1 -Detailed

# Target a specific test suite or CWE filter:
pwsh -NoProfile -ExecutionPolicy Bypass -File .\tests\Test-JvmSecurity.ps1 -Suite 1
pwsh -NoProfile -ExecutionPolicy Bypass -File .\tests\Test-JvmSecurity.ps1 -Filter "CWE-460"

2. Live OS Integration Test Suite (packages\msi\test-msi.ps1)

DiamTek JVM includes a synthetic 21-point integration test suite (packages\msi\test-msi.ps1) used by our CI/CD pipeline to validate real operating system integration (13 installation & system registration checks + 8 uninstallation & residual hygiene checks).

Running the Integration Test Suite

Open PowerShell (Run as Administrator if testing elevated MSI installation) and execute:

# Run the complete test suite against local build artifacts:
powershell -ExecutionPolicy Bypass -File packages\msi\test-msi.ps1

# Run with interactive Windows Installer UI dialogs visible:
powershell -ExecutionPolicy Bypass -File packages\msi\test-msi.ps1 -ShowUI

# Keep the test installation for manual inspection post-run:
powershell -ExecutionPolicy Bypass -File packages\msi\test-msi.ps1 -KeepInstalled

Building Installer Packages Locally

To verify installer packaging changes:

WiX Toolset v4 Standalone MSI

build-msi.ps1 automatically detects the product version and build number directly from jvm.bat:

# Compiles both x64 and arm64 MSIs into packages\msi\:
powershell -ExecutionPolicy Bypass -File packages\msi\build-msi.ps1 -Arch all

Chocolatey Package

build-choco.ps1 automatically detects the version from jvm.bat, synchronizes jvm.nuspec and fallback URLs, and packages .nupkg:

# Updates nuspec and compiles Chocolatey nupkg into packages\choco\:
powershell -ExecutionPolicy Bypass -File packages\choco\build-choco.ps1

📐 Windows Scripting Rules & Pitfalls

The core jvm.bat engine is over 500 KB of mathematically optimized Windows Batch script. When contributing code, you must adhere to these battle-tested rules:

1. Strict CRLF Line Ending Enforcement

2. Delayed Expansion & Exclamation Mark Safety

3. Quote Encapsulation Across Subshell Boundaries

4. Metacharacter Sanitization for Repository Files

5. The “Zero External Dependencies” Rule

6. Zero Empty Catch Blocks Enforcement (CWE-390)


🔄 Pull Request Workflow

We actively welcome contributions! Follow this workflow for a seamless review:

  1. Fork the repository on GitHub.
  2. Create a topic branch from main:
    git checkout -b feat/add-candidate-scala
    # or
    git checkout -b fix/path-quote-handling
    
  3. Write Conventional Commits:
    • feat: add Scala support to Universal Candidate Engine
    • fix: resolve delayed expansion path collision in BYO-JDK
    • docs: update Intune silent deployment switches
    • test: add synthetic validation case for ARM64 detection
  4. Run the Pre-Flight Checklist:
    • powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\tests\Test-JvmSecurity.ps1 passes 327/327 tests (0 failures across all 16 suites and 41 MITRE CWE classes).
    • Verified zero empty catch blocks across all PowerShell files (CWE-390).
    • cmd.exe /c "jvm.bat --version" executes cleanly with exit code 0.
    • Verified in standard Command Prompt (cmd.exe).
    • Verified in Windows PowerShell (5.1) and PowerShell (7+).
    • Verified in Windows Terminal.
    • UAC-free Symlink Mode switches without prompts.
    • No temporary script files left behind in %TEMP% or %LOCALAPPDATA%\DiamTek\JVM\temp.
  5. Open a Pull Request targeting the main branch with a clear description and testing proof.

🤝 Code of Conduct

This project adheres to the Contributor Covenant. By participating, you agree to uphold a welcoming, respectful, and inclusive environment for everyone.

Questions or architecture discussions? Reach out to Alexéy Shishkin on Discord (@thehawk01) or via email (salexey09@gmail.com).


← Back to Documentation Overview