Skip to content

Commit 5ed4d0f

Browse files
authored
Merge pull request #3326 from Rawi01/utilityclass-npe
Reset erasure_field of symbol
2 parents 9e6f66c + 5f0582b commit 5ed4d0f

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

src/core/lombok/javac/handlers/HandleUtilityClass.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ private void changeModifiersAndGenerateConstructor(JavacNode typeNode, JavacNode
128128
JCClassDecl innerClassDecl = (JCClassDecl) element.get();
129129
innerClassDecl.mods.flags |= Flags.STATIC;
130130
ClassSymbol innerClassSymbol = innerClassDecl.sym;
131-
if (innerClassSymbol != null && innerClassSymbol.type instanceof ClassType) {
132-
((ClassType) innerClassSymbol.type).setEnclosingType(Type.noType);
131+
if (innerClassSymbol != null) {
132+
if (innerClassSymbol.type instanceof ClassType) {
133+
((ClassType) innerClassSymbol.type).setEnclosingType(Type.noType);
134+
}
135+
innerClassSymbol.erasure_field = null;
133136
}
134137
}
135138
}

src/stubs/com/sun/tools/javac/code/Symbol.java

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public abstract class Symbol implements Element {
2525
public Type type;
2626
public Name name;
2727
public Symbol owner;
28+
public Type erasure_field;
2829

2930
public long flags() { return 0; }
3031
public boolean isStatic() { return false; }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
final class UtilityClassGeneric {
2+
static <T> T convertValue(Class<T> toValueType) {
3+
return null;
4+
}
5+
6+
static DTO convert(Object json) {
7+
return convertValue(DTO.class);
8+
}
9+
10+
static Object convert(DTO dto) {
11+
return null;
12+
}
13+
14+
static class DTO {
15+
}
16+
17+
@java.lang.SuppressWarnings("all")
18+
private UtilityClassGeneric() {
19+
throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated");
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import lombok.experimental.UtilityClass;
2+
final @UtilityClass class UtilityClassGeneric {
3+
static class DTO {
4+
DTO() {
5+
super();
6+
}
7+
}
8+
static <T>T convertValue(Class<T> toValueType) {
9+
return null;
10+
}
11+
static DTO convert(Object json) {
12+
return convertValue(DTO.class);
13+
}
14+
static Object convert(DTO dto) {
15+
return null;
16+
}
17+
private @java.lang.SuppressWarnings("all") UtilityClassGeneric() {
18+
super();
19+
throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated");
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import lombok.experimental.UtilityClass;
2+
@UtilityClass
3+
class UtilityClassGeneric {
4+
<T> T convertValue(Class<T> toValueType) {
5+
return null;
6+
}
7+
8+
DTO convert(Object json) {
9+
return convertValue(DTO.class);
10+
}
11+
12+
Object convert(DTO dto) {
13+
return null;
14+
}
15+
16+
class DTO {
17+
}
18+
}

0 commit comments

Comments
 (0)