projectlombok/lombok · error

DELOMBOK: Option --module-path requires usage of JDK9 or…

Error message

DELOMBOK: Option --module-path requires usage of JDK9 or higher.

What it means

Delombok's `--module-path` option only exists on JDK 9+, where the module system (JPMS) was introduced. When delombok runs on JDK 8 or lower and a non-empty module path was configured, it throws IllegalStateException because javac 8 has no module-path concept to forward.

Solutions

  1. Run delombok on JDK 9 or higher (update JAVA_HOME / toolchain)
  2. Remove the `--module-path` option or the `setModulepath` call when targeting JDK 8
  3. Only set modulepath conditionally, e.g. when `System.getProperty("java.version")` indicates 9+

Example fix

// before
delombok.setModulepath(modulePath); // fails on JDK 8
// after
if (Runtime.version().feature() >= 9) delombok.setModulepath(modulePath); // or simply drop the line on JDK 8
Defensive patterns

Strategy: validation

Validate before calling

int ver = Integer.parseInt(System.getProperty("java.version").split("\\.")[0]);
if (ver >= 9 && modulePath != null) delombok.setModulepath(modulePath);

Try / catch

try { delombok.delombok(); } catch (IllegalStateException e) { if (e.getMessage().contains("JDK9")) { /* rerun on JDK 9+ or drop modulepath */ } throw e; }

Prevention

When it happens

Trigger: Calling `delombok.setModulepath(...)` (or passing `--module-path` on the CLI) and then running `delombok()` on a runtime JDK whose version is below 9. The check fires in the non-JDK9 branch of the compile setup inside `delombok()`.

Common situations: Builds pinned to JDK 8 (common for legacy projects) whose build script copies module-path settings from a JDK 11+ config; switching CI agents to an older JDK while the Ant/Maven config still sets modulepath.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07). Data as JSON: /api/errors/9b06d3902be2942e. Report an issue: GitHub.

Appendix: source

Thrown at src/delombok/lombok/delombok/Delombok.java:733

				argsList.add((modulepath == null || modulepath.isEmpty()) ? pathToSelfJar : (pathToSelfJar + File.pathSeparator + modulepath));
			} else if (modulepath != null && !modulepath.isEmpty()) {
				argsList.add("--module-path");
				argsList.add(modulepath);
			}
			
			if (!disablePreview && Javac.getJavaCompilerVersion() >= 11) argsList.add("--enable-preview");
			if (Javac.getJavaCompilerVersion() >= 21) argsList.add("-proc:full");
			
			if (Javac.getJavaCompilerVersion() < 15) {
				String[] argv = argsList.toArray(new String[0]);
				args.init("javac", argv);
			} else {
				args.init("javac", argsList);
			}
			options.put("diags.legacy", "TRUE");
			options.put("allowStringFolding", "FALSE");
		} else {
			if (modulepath != null && !modulepath.isEmpty()) throw new IllegalStateException("DELOMBOK: Option --module-path requires usage of JDK9 or higher.");
		}
		
		CommentCatcher catcher = CommentCatcher.create(context, Javac.getJavaCompilerVersion() >= 13);
		JavaCompiler compiler = catcher.getCompiler();
		
		List<JCCompilationUnit> roots = new ArrayList<JCCompilationUnit>();
		Map<JCCompilationUnit, File> baseMap = new IdentityHashMap<JCCompilationUnit, File>();
		
		Set<AbstractProcessor> processors = new LinkedHashSet<AbstractProcessor>();
		processors.addAll(preLombokProcessors);
		processors.add(new lombok.javac.apt.LombokProcessor());
		processors.addAll(additionalAnnotationProcessors);
		
		if (Javac.getJavaCompilerVersion() >= 9) {
			JavaFileManager jfm_ = context.get(JavaFileManager.class);
			if (jfm_ instanceof BaseFileManager) {
				Arguments args = Arguments.instance(context);
				((BaseFileManager) jfm_).setContext(context); // reinit with options

View on GitHub (pinned to 6d6a3e9fec)