From ab253fd34a891d807bc6254e19103ab2cd1268f9 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 17 Feb 2024 19:04:37 +0100 Subject: [PATCH] Fix class initializer compilation for WASI target --- core/src/main/java/org/teavm/vm/TeaVM.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/teavm/vm/TeaVM.java b/core/src/main/java/org/teavm/vm/TeaVM.java index 1da4fa2d3..4e6d999d3 100644 --- a/core/src/main/java/org/teavm/vm/TeaVM.java +++ b/core/src/main/java/org/teavm/vm/TeaVM.java @@ -548,7 +548,13 @@ public class TeaVM implements TeaVMHost, ServiceRepository { } } - addInitializersToEntryPoint(classes, new MethodReference(entryPoint, CLINIT_DESC)); + var initializers = target.getInitializerMethods(); + if (initializers == null) { + initializers = List.of(new MethodReference(entryPoint, CLINIT_DESC)); + } + for (var initializer : initializers) { + addInitializersToEntryPoint(classes, initializer); + } } private void addInitializersToEntryPoint(ClassHolderSource classes, MethodReference methodRef) {