diff --git a/src/tools/type-generator/main.cpp b/src/tools/type-generator/main.cpp index 32dcf6f7f0..c981d13194 100644 --- a/src/tools/type-generator/main.cpp +++ b/src/tools/type-generator/main.cpp @@ -1408,8 +1408,20 @@ void writeInitializations(Output* out, Module& module) } } -void writeJavaInitialization(Output* out, Class* cl) +void writeJavaInitialization(Output* out, + Class* cl, + std::set& alreadyInited) { + if (alreadyInited.find(cl) != alreadyInited.end()) { + return; + } + + alreadyInited.insert(cl); + + if (cl->super) { + writeJavaInitialization(out, cl->super, alreadyInited); + } + out->write("bootJavaClass(t, Gc::"); out->write(capitalize(cl->name)); out->write("Type, "); @@ -1436,10 +1448,11 @@ void writeJavaInitialization(Output* out, Class* cl) void writeJavaInitializations(Output* out, Module& module) { + std::set alreadyInited; for (const auto p : module.classes) { Class* cl = p.second; if (cl->javaName.size()) { - writeJavaInitialization(out, cl); + writeJavaInitialization(out, cl, alreadyInited); } } } diff --git a/test/NullPointer.java b/test/NullPointer.java index 6c6e5c7b50..8d3abdc6fa 100644 --- a/test/NullPointer.java +++ b/test/NullPointer.java @@ -16,6 +16,12 @@ public class NullPointer { } public static void main(String[] args) { + try { + ((Object) null).getClass(); + } catch (Exception e) { + e.printStackTrace(); + } + try { throw_(null); throw new RuntimeException();