Skip to content

Commit 554a6c6

Browse files
Extract complex expression to help JDK 8 make sense of the Java types
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 ```
1 parent c4659f1 commit 554a6c6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

japicmp/src/main/java/japicmp/output/markdown/MarkdownOutputGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ private final String renderCompatibilityChanges(List<? extends JApiCompatibility
384384
}
385385

386386
private String renderAllCompatibilityChanges(JApiClass clazz) {
387-
return renderCompatibilityChanges(Stream.of(
387+
final Stream<List<? extends JApiCompatibility>> allCompatibilityChanges = Stream.of(
388388
singletonList(clazz),
389389
singletonList(clazz.getClassFileFormatVersion()),
390390
singletonList(clazz.getSuperclass()),
@@ -397,7 +397,8 @@ private String renderAllCompatibilityChanges(JApiClass clazz) {
397397
clazz.getMethods(),
398398
clazz.getMethods().stream().map(JApiMethod::getReturnType).collect(toList()),
399399
clazz.getMethods().stream().map(JApiMethod::getParameters).flatMap(List::stream).collect(toList()),
400-
clazz.getFields())
400+
clazz.getFields());
401+
return renderCompatibilityChanges(allCompatibilityChanges
401402
.flatMap(List::stream)
402403
.map(JApiCompatibility::getCompatibilityChanges)
403404
.flatMap(List::stream)

0 commit comments

Comments
 (0)