From 554a6c6c046ccf35c60daec92ca16bcca8ff48ba Mon Sep 17 00:00:00 2001 From: Guillermo Calvo Date: Tue, 20 Aug 2024 20:56:10 +0200 Subject: [PATCH] Extract complex expression to help JDK 8 make sense of the Java types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Full explanation: JDK 8 doesn't realize we want to handle a stream of `JApiCompatibility` elements. Instead, the compiler thinks we want to create a stream of `JApiHasChangeStatus` elements. So I just extracted the complex expression to a constant with the appropriate type and it works fine. Other JDK versions get it right without the type hint. ¯\_(ツ)_/¯ Root cause of the problem: ``` Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type interface japicmp.model.JApiHasChangeStatus; not a subtype of implementation type interface japicmp.model.JApiCompatibility at java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:233) at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:303) at java.lang.invoke.CallSite.makeSite(CallSite.java:302) ... 54 more ``` --- .../japicmp/output/markdown/MarkdownOutputGenerator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/japicmp/src/main/java/japicmp/output/markdown/MarkdownOutputGenerator.java b/japicmp/src/main/java/japicmp/output/markdown/MarkdownOutputGenerator.java index c6fa2967..0666647e 100644 --- a/japicmp/src/main/java/japicmp/output/markdown/MarkdownOutputGenerator.java +++ b/japicmp/src/main/java/japicmp/output/markdown/MarkdownOutputGenerator.java @@ -384,7 +384,7 @@ private final String renderCompatibilityChanges(List> allCompatibilityChanges = Stream.of( singletonList(clazz), singletonList(clazz.getClassFileFormatVersion()), singletonList(clazz.getSuperclass()), @@ -397,7 +397,8 @@ private String renderAllCompatibilityChanges(JApiClass clazz) { clazz.getMethods(), clazz.getMethods().stream().map(JApiMethod::getReturnType).collect(toList()), clazz.getMethods().stream().map(JApiMethod::getParameters).flatMap(List::stream).collect(toList()), - clazz.getFields()) + clazz.getFields()); + return renderCompatibilityChanges(allCompatibilityChanges .flatMap(List::stream) .map(JApiCompatibility::getCompatibilityChanges) .flatMap(List::stream)