From 6b7d8432588f0273b22e5b2a050472148d2bb13d Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Thu, 7 Nov 2024 11:24:25 +0100 Subject: [PATCH] Correct handler for `@AllArgsConstructorHandler` The `onConstructor` parameter is specified as `onConstructor_` on Java 1.8+ (as in the case of `J.Modifier` for example). --- .../openrewrite/java/lombok/AllArgsConstructorHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rewrite-java-lombok/src/main/java/org/openrewrite/java/lombok/AllArgsConstructorHandler.java b/rewrite-java-lombok/src/main/java/org/openrewrite/java/lombok/AllArgsConstructorHandler.java index a8071ede4f7..b629bee724a 100644 --- a/rewrite-java-lombok/src/main/java/org/openrewrite/java/lombok/AllArgsConstructorHandler.java +++ b/rewrite-java-lombok/src/main/java/org/openrewrite/java/lombok/AllArgsConstructorHandler.java @@ -38,7 +38,9 @@ public void handle(AnnotationValues annotationValues, JCTree if (originalArg instanceof JCTree.JCAssign && ((JCTree.JCAssign) originalArg).getVariable() instanceof JCTree.JCIdent) { JCTree.JCAssign assign = (JCTree.JCAssign) originalArg; JCTree.JCIdent ident = (JCTree.JCIdent) assign.getVariable(); - if ("onConstructor".equals(ident.getName().toString())) { + String name = ident.getName().toString(); + if (name.equals("onConstructor") || name.equals("onConstructor_")) { + // In Java 1.8+ the parameter is `onConstructor_` continue; } }