diff --git a/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java b/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java index e1998e1..853d1a6 100644 --- a/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java +++ b/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java @@ -874,7 +874,6 @@ public abstract class WasmCodeBuilder { StructType interfaceType = (StructType)parser.next(); StructType type = types.lambdaType( typeName, interfaceType, name, interfaceMethodName ); addStructInstruction( StructOperator.NEW_DEFAULT, typeName, null, javaCodePos, lineNumber ); - throw new WasmException( "InvokeDynamic/Lambda is not supported.", lineNumber ); } /** diff --git a/test/de/inetsoftware/jwebassembly/runtime/RuntimeErrors.java b/test/de/inetsoftware/jwebassembly/runtime/RuntimeErrors.java index 4274f9b..e341e77 100644 --- a/test/de/inetsoftware/jwebassembly/runtime/RuntimeErrors.java +++ b/test/de/inetsoftware/jwebassembly/runtime/RuntimeErrors.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2020 Volker Berlin (i-net software) + * Copyright 2017 - 2021 Volker Berlin (i-net software) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; @@ -97,19 +95,4 @@ public class RuntimeErrors { @Export native static float function(); } - - @Test - public void lambdas() throws IOException { - compileErrorTest( "InvokeDynamic/Lambda is not supported.", LambdaMethod.class ); - } - - static class LambdaMethod { - private static int counter; - - @Export - static void runnable() { - Runnable run = () -> counter++; - run.run(); - } - } } diff --git a/test/de/inetsoftware/jwebassembly/runtime/StructsNonGC.java b/test/de/inetsoftware/jwebassembly/runtime/StructsNonGC.java index 6b2b261..893f6d0 100644 --- a/test/de/inetsoftware/jwebassembly/runtime/StructsNonGC.java +++ b/test/de/inetsoftware/jwebassembly/runtime/StructsNonGC.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 - 2020 Volker Berlin (i-net software) + * Copyright 2018 - 2021 Volker Berlin (i-net software) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; +import java.util.function.IntSupplier; +import java.util.function.IntUnaryOperator; import org.junit.ClassRule; import org.junit.runners.Parameterized.Parameters; @@ -66,6 +68,9 @@ public class StructsNonGC extends AbstractBaseTest { addParam( list, script, "intClassName" ); addParam( list, script, "getComponentType" ); addParam( list, script, "branchWithObjectResult" ); + addParam( list, script, "callParameterFromCondition" ); + addParam( list, script, "lambda0" ); + addParam( list, script, "lambda1" ); } rule.setTestParameters( list ); return list; @@ -243,6 +248,18 @@ public class StructsNonGC extends AbstractBaseTest { Abc abc = new Abc(); return abc.add( 42, abc == null ? 7 : 13 ); } + + @Export + static int lambda0() { + IntSupplier val = () -> 42; + return val.getAsInt(); + } + + @Export + static int lambda1() { + IntUnaryOperator val = (x) -> x; + return val.applyAsInt( 13 ); + } } interface TestDefault {