From f04369fac5aaa5a1bb07f9546e13b5969067837d Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sun, 26 Apr 2020 17:59:05 +0200 Subject: [PATCH] Also replace static constructor methods --- .../jwebassembly/module/StaticCodeBuilder.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/StaticCodeBuilder.java b/src/de/inetsoftware/jwebassembly/module/StaticCodeBuilder.java index 45751fe..d3c049e 100644 --- a/src/de/inetsoftware/jwebassembly/module/StaticCodeBuilder.java +++ b/src/de/inetsoftware/jwebassembly/module/StaticCodeBuilder.java @@ -93,6 +93,13 @@ class StaticCodeBuilder { }; } + /** + * Scan a class initializer (static constructor). If it reference to another class with has class initializer which + * was not call then it patch the code and call it before the other class is access. + * + * @param name + * name of the static constuctor + */ private void scanAndPatchIfNeeded( FunctionName name ) { String className = name.className; String sourceFile = null; @@ -101,6 +108,7 @@ class StaticCodeBuilder { ClassFile classFile = classFileLoader.get( className ); sourceFile = classFile.getSourceFile(); MethodInfo method = classFile.getMethod( name.methodName, name.signature ); + method = options.functions.replace( name, method ); Code code = method.getCode(); javaCodeBuilder.buildCode( code, method ); @@ -134,10 +142,8 @@ class StaticCodeBuilder { if( patched ) { options.functions.markAsNeededAndReplaceIfExists( new SyntheticFunctionName( className, name.methodName, name.signature ) { - @Override protected boolean hasWasmCode() { - // TODO Auto-generated method stub return true; }