Files
openidea/java/lombok/tests/verify.py
Ega Saputra ba8d224a46 fix(java): support Lombok builders on compact record constructors (#950)
@Builder on a compact record constructor (record R(...) { @Builder R {} }) failed in the
editor: ECJ has not filled in a compact constructor's implicit parameters when Lombok
runs, so the builder got no fields and builder() was undefined. A patch to Lombok's
Eclipse HandleBuilder takes the parameters from the record components in that case.

The bundled agent is now lombok-1.18.48-openidea.3, built from v1.18.48 with #4059,
#4089 and java/lombok/patches/builder-compact-constructor.patch through the documented
Ant build; only HandleBuilder differs from openidea.2. The new agent path gives JDT LS a
fresh workspace. java/lombok/tests/verify.py compiles and runs the regression cases with
javac and with ECJ plus the agent.

Co-authored-by: egasa21 <44431625+egasa21@users.noreply.github.com>
2026-11-06 11:55:21 +08:00

34 lines
1.3 KiB
Python

"""Compile and run builder regressions with javac and the compiler shipped by JDT LS.
Usage: python3 java/lombok/tests/verify.py /path/to/jdtls /path/to/lombok.jar
Requires a JDK 21+ on PATH. All generated files stay in a temporary directory.
"""
import os
import pathlib
import subprocess
import sys
import tempfile
def main():
home, lombok = (pathlib.Path(p).resolve() for p in sys.argv[1:3])
ecj, = (home / "plugins").glob("org.eclipse.jdt.core.compiler.batch_*.jar")
source = pathlib.Path(__file__).with_name("BuilderCompactConstructor.java")
with tempfile.TemporaryDirectory(prefix="openidea-lombok-builders-") as tmp:
for compiler in ("javac", "ecj"):
output = pathlib.Path(tmp) / compiler
output.mkdir()
if compiler == "javac":
command = ["javac", "--release", "21", "-processorpath", str(lombok)]
else:
command = ["java", f"-javaagent:{lombok}", "-jar", str(ecj), "-21"]
subprocess.run(command + ["-cp", str(lombok), "-d", str(output), str(source)], check=True)
subprocess.run(["java", "-ea", "-cp", os.pathsep.join((str(output), str(lombok))),
"BuilderCompactConstructor"], check=True)
print(f"{compiler}: builder regression assertions passed", flush=True)
if __name__ == "__main__":
main()