From 7c3674969f55174e3682136ff6eb1404d7e7e318 Mon Sep 17 00:00:00 2001 From: Mirko Sertic Date: Thu, 10 Jun 2021 08:40:21 +0200 Subject: [PATCH] Bug fix for Java 16 Lambdas (#571) --- .github/workflows/pullrequest.yml | 10 ++-- .../backend/js/JSSSACompilerBackend.java | 52 ++----------------- 2 files changed, 10 insertions(+), 52 deletions(-) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index a6f3495465..3a8c3404ed 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -7,7 +7,7 @@ jobs: runs-on: 'ubuntu-latest' strategy: matrix: - java: [8,11,15] + java: [8,11,15,16] steps: - uses: actions/checkout@v1 - uses: joschi/setup-jdk@v1 @@ -31,7 +31,7 @@ jobs: runs-on: 'ubuntu-latest' strategy: matrix: - java: [8,11,15] + java: [8,11,15,16] steps: - uses: actions/checkout@v1 - uses: joschi/setup-jdk@v1 @@ -55,7 +55,7 @@ jobs: runs-on: 'ubuntu-latest' strategy: matrix: - java: [8,11,15] + java: [8,11,15,16] steps: - uses: actions/checkout@v1 - uses: joschi/setup-jdk@v1 @@ -79,7 +79,7 @@ jobs: runs-on: 'ubuntu-latest' strategy: matrix: - java: [8,11,15] + java: [8,11,15,16] steps: - uses: actions/checkout@v1 - uses: joschi/setup-jdk@v1 @@ -103,7 +103,7 @@ jobs: runs-on: 'ubuntu-latest' strategy: matrix: - java: [8,11,15] + java: [8,11,15,16] steps: - uses: actions/checkout@v1 - uses: joschi/setup-jdk@v1 diff --git a/core/src/main/java/de/mirkosertic/bytecoder/backend/js/JSSSACompilerBackend.java b/core/src/main/java/de/mirkosertic/bytecoder/backend/js/JSSSACompilerBackend.java index 8bf8d824f7..1e60f907c1 100644 --- a/core/src/main/java/de/mirkosertic/bytecoder/backend/js/JSSSACompilerBackend.java +++ b/core/src/main/java/de/mirkosertic/bytecoder/backend/js/JSSSACompilerBackend.java @@ -1690,26 +1690,17 @@ private void writeMethodHandleDelegateInvokeStatic(final MethodHandleExpression // We build the dynamic signature here final List theDelegateArgs = new ArrayList<>(); final List theCallingArgs = new ArrayList<>(); - final List theEffectiveArguments = new ArrayList<>(); for (int k=0;k0) { aWriter.text(","); @@ -1721,7 +1712,7 @@ private void writeMethodHandleDelegateInvokeStatic(final MethodHandleExpression aWriter.tab(1).text("return "); aWriter.text(aMinifier.toClassName(aMethodHandle.getClassName())); aWriter.text(".").text(aMinifier.toSymbol("init")).text("()."); - aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), theEffectiveSignature)); + aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), aMethodHandle.getImplementationSignature())); aWriter.text("("); for (int j=0;j theDelegateArgs = new ArrayList<>(); final List theCallingArgs = new ArrayList<>(); - final List theEffectiveArguments = new ArrayList<>(); for (int k=0;k0) { theDelegateArgs.add(theArgName); theCallingArgs.add(theArgName); - theEffectiveArguments.add(theAdapterAnnotation.getCaptureSignature().getArguments()[k]); } else { theCallingArgs.add("this"); } } - final BytecodeMethodSignature theEffectiveSignature = new BytecodeMethodSignature( - aMethodHandle.getImplementationSignature().getReturnType(), - theEffectiveArguments.toArray(new BytecodeTypeRef[0]) - ); - for (int j=0;j0) { aWriter.text(","); @@ -1777,7 +1760,7 @@ private void writeMethodHandleDelegateInvokeInterface(final MethodHandleExpressi aWriter.text(") {").newLine(); aWriter.tab(1).text("return this."); - aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), theEffectiveSignature)); + aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), aMethodHandle.getImplementationSignature())); aWriter.text("("); for (int j=0;j theDelegateArgs = new ArrayList<>(); final List theCallingArgs = new ArrayList<>(); - final List theEffectiveArguments = new ArrayList<>(); for (int k=0;k0) { aWriter.text(","); @@ -1837,7 +1811,7 @@ private void writeMethodHandleDelegateNewInvokeSpecial(final MethodHandleExpress aWriter.text(aMinifier.toClassName(aMethodHandle.getClassName())); aWriter.text(".").text(aMinifier.toSymbol("init")).text("()"); aWriter.text(".").text(aMinifier.toSymbol("__runtimeclass")); - aWriter.text(".").text(aMinifier.toMethodName("$newInstance", theEffectiveSignature)); + aWriter.text(".").text(aMinifier.toMethodName("$newInstance", aMethodHandle.getImplementationSignature())); aWriter.text("("); for (int j=0;j theDelegateArgs = new ArrayList<>(); final List theCallingArgs = new ArrayList<>(); - final List theEffectiveArguments = new ArrayList<>(); for (int k=0;k0) { theDelegateArgs.add(theArgName); theCallingArgs.add(theArgName); - theEffectiveArguments.add(theAdapterAnnotation.getLinkageSignature().getArguments()[k]); } } for (int k=0;k0) { aWriter.text(","); @@ -1891,7 +1857,7 @@ private void writeMethodHandleDelegateInvokeVirtual(final MethodHandleExpression aWriter.text(") {").newLine(); aWriter.tab(1).text("return this."); - aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), theEffectiveSignature)); + aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), aMethodHandle.getImplementationSignature())); aWriter.text("("); for (int j=0;j theDelegateArgs = new ArrayList<>(); final List theCallingArgs = new ArrayList<>(); - final List theEffectiveArguments = new ArrayList<>(); for (int k=0;k0) { theDelegateArgs.add(theArgName); theCallingArgs.add(theArgName); - theEffectiveArguments.add(theAdapterAnnotation.getLinkageSignature().getArguments()[k]); } } for (int k=0;k0) { aWriter.text(","); @@ -1947,7 +1905,7 @@ private void writeMethodHandleDelegateInvokeSpecial(final MethodHandleExpression aWriter.tab(1).text("return "); aWriter.text(aMinifier.toClassName(aMethodHandle.getClassName())); aWriter.text("."); - aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), theEffectiveSignature)); + aWriter.text(aMinifier.toMethodName(aMethodHandle.getMethodName(), aMethodHandle.getImplementationSignature())); aWriter.text(".call(this"); for (final String theCallingArg : theCallingArgs) { aWriter.text(",");