From 615efbd11fc5487d3ded41d7fe816ff2c596b883 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Fri, 9 Aug 2019 21:58:42 +0200 Subject: [PATCH] use class and method name as default import setting if not set --- .../inetsoftware/jwebassembly/module/ModuleGenerator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java index 03721b4..4baa25a 100644 --- a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java +++ b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java @@ -223,11 +223,13 @@ public class ModuleGenerator { Map importAnannotation = functions.getImportAnannotation( name ); String importModule = (String)importAnannotation.get( "module" ); if( importModule == null || importModule.isEmpty() ) { - throw new WasmException( "Module not set for import function: " + name.signatureName, -1 ); + // use className if module is not set + importModule = name.className.substring( name.className.lastIndexOf( '/' ) + 1 ); } String importName = (String)importAnannotation.get( "name" ); if( importName == null || importName.isEmpty() ) { - throw new WasmException( "Name not set for import function: " + name.signatureName, -1 ); + // use method name as function if not set + importName = name.methodName; } writer.prepareImport( name, importModule, importName ); writeMethodSignature( name, true, null );