aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/javac/handlers/HandleUtilityClass.java7
-rw-r--r--test/transform/resource/after-delombok/UtilityClass.java5
-rw-r--r--test/transform/resource/after-ecj/UtilityClass.java8
-rw-r--r--test/transform/resource/before/UtilityClass.java6
4 files changed, 26 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleUtilityClass.java b/src/core/lombok/javac/handlers/HandleUtilityClass.java
index 6fa630e2..716d6d63 100644
--- a/src/core/lombok/javac/handlers/HandleUtilityClass.java
+++ b/src/core/lombok/javac/handlers/HandleUtilityClass.java
@@ -25,6 +25,9 @@ import static lombok.core.handlers.HandlerUtil.handleExperimentalFlagUsage;
import static lombok.javac.handlers.JavacHandlerUtil.*;
import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
@@ -124,6 +127,10 @@ public class HandleUtilityClass extends JavacAnnotationHandler<UtilityClass> {
} else if (element.getKind() == Kind.TYPE) {
JCClassDecl innerClassDecl = (JCClassDecl) element.get();
innerClassDecl.mods.flags |= Flags.STATIC;
+ ClassSymbol innerClassSymbol = innerClassDecl.sym;
+ if (innerClassSymbol != null && innerClassSymbol.type instanceof ClassType) {
+ ((ClassType) innerClassSymbol.type).setEnclosingType(Type.noType);
+ }
}
}
diff --git a/test/transform/resource/after-delombok/UtilityClass.java b/test/transform/resource/after-delombok/UtilityClass.java
index 8d3f4c08..1d541b6e 100644
--- a/test/transform/resource/after-delombok/UtilityClass.java
+++ b/test/transform/resource/after-delombok/UtilityClass.java
@@ -2,10 +2,15 @@ final class UtilityClass {
private static long someField = System.currentTimeMillis();
static void someMethod() {
System.out.println();
+ new InnerClass();
+ new InnerStaticClass();
}
protected static class InnerClass {
private String innerInnerMember;
}
+ protected static class InnerStaticClass {
+ private String innerInnerMember;
+ }
@java.lang.SuppressWarnings("all")
private UtilityClass() {
throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated");
diff --git a/test/transform/resource/after-ecj/UtilityClass.java b/test/transform/resource/after-ecj/UtilityClass.java
index 656c0184..1db3d540 100644
--- a/test/transform/resource/after-ecj/UtilityClass.java
+++ b/test/transform/resource/after-ecj/UtilityClass.java
@@ -5,11 +5,19 @@ final @lombok.experimental.UtilityClass class UtilityClass {
super();
}
}
+ protected static class InnerStaticClass {
+ private String innerInnerMember;
+ protected InnerStaticClass() {
+ super();
+ }
+ }
private static long someField = System.currentTimeMillis();
<clinit>() {
}
static void someMethod() {
System.out.println();
+ new InnerClass();
+ new InnerStaticClass();
}
private @java.lang.SuppressWarnings("all") UtilityClass() {
super();
diff --git a/test/transform/resource/before/UtilityClass.java b/test/transform/resource/before/UtilityClass.java
index 016a166e..b817b5c1 100644
--- a/test/transform/resource/before/UtilityClass.java
+++ b/test/transform/resource/before/UtilityClass.java
@@ -4,11 +4,17 @@ class UtilityClass {
void someMethod() {
System.out.println();
+ new InnerClass();
+ new InnerStaticClass();
}
protected class InnerClass {
private String innerInnerMember;
}
+
+ protected static class InnerStaticClass {
+ private String innerInnerMember;
+ }
}
class UtilityInner {