Fix #343 (le null check)

This commit is contained in:
Daniel Holle 2024-08-07 13:33:40 +02:00
parent a654f55deb
commit f0b9bea23e
3 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,2 @@
public record Bug343() {
}

View File

@ -254,7 +254,10 @@ public class SyntaxTreeGenerator {
List<RefType> implementedInterfaces = new ArrayList<>(); List<RefType> implementedInterfaces = new ArrayList<>();
List<Pattern> constructorParameters = new ArrayList<>(); List<Pattern> constructorParameters = new ArrayList<>();
List<Statement> constructorStatements = new ArrayList<>(); List<Statement> constructorStatements = new ArrayList<>();
for (RecordComponentContext component : recordDeclaration.recordHeader().recordComponentList().recordComponent()) {
List<Java17Parser.RecordComponentContext> components = recordDeclaration.recordHeader().recordComponentList() != null ?
recordDeclaration.recordHeader().recordComponentList().recordComponent(): List.of();
for (RecordComponentContext component : components) {
int fieldmodifiers = allmodifiers.get("private") + allmodifiers.get("final"); int fieldmodifiers = allmodifiers.get("private") + allmodifiers.get("final");
String fieldname = component.identifier().getText(); String fieldname = component.identifier().getText();
Token fieldoffset = component.getStart(); Token fieldoffset = component.getStart();

View File

@ -1147,4 +1147,11 @@ public class TestComplete {
var clazz = classFiles.get("Bug338"); var clazz = classFiles.get("Bug338");
var instance = clazz.getDeclaredConstructor().newInstance(); var instance = clazz.getDeclaredConstructor().newInstance();
} }
@Test
public void testBug343() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug343.jav");
var clazz = classFiles.get("Bug343");
var instance = clazz.getDeclaredConstructor().newInstance();
}
} }