From ce1d3ddb38e0933e052efb03dedfd6ef4dfcf574 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sun, 17 Nov 2019 17:04:35 +0100 Subject: [PATCH] improve the "ignore redefinition" in ClassPath. The first should win. --- .../jwebassembly/module/FunctionManager.java | 11 +++++++++++ .../jwebassembly/module/ModuleGenerator.java | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/de/inetsoftware/jwebassembly/module/FunctionManager.java b/src/de/inetsoftware/jwebassembly/module/FunctionManager.java index fb8fabe..1f500c6 100644 --- a/src/de/inetsoftware/jwebassembly/module/FunctionManager.java +++ b/src/de/inetsoftware/jwebassembly/module/FunctionManager.java @@ -61,6 +61,17 @@ public class FunctionManager { return state; } + /** + * Check if this function is already known/registered. + * + * @param name + * the function name + * @return true, if known + */ + boolean isKnown( FunctionName name ) { + return states.get( name ) != null; + } + /** * Mark the a function as a import function. Only if the function is also needed then it will imported from * compiler. diff --git a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java index 2dcd532..eca96b6 100644 --- a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java +++ b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java @@ -367,8 +367,12 @@ public class ModuleGenerator { private void prepareMethod( MethodInfo method ) throws WasmException { try { FunctionName name = new FunctionName( method ); + if( functions.isKnown( name ) ) { + return; + } Map annotationValues; if( (annotationValues = method.getAnnotation( JWebAssembly.REPLACE_ANNOTATION )) != null ) { + functions.isStatic( name ); // register this class that process the annotation of this replacement function not a second time. iSKnown() returns true now. String signatureName = (String)annotationValues.get( "value" ); name = new FunctionName( signatureName ); functions.addReplacement( name, method );