Closed wild8oar closed 1 year ago
I can confirm that
class LambdaTest {
Runnable get() {
return () -> System.out.println("Hello from `LambdaTest.lambda$get$0()`");
}
}
assertThat(new ClassFileImporter().importClass(LambdaTest.class).getCodeUnits())
.extracting(JavaCodeUnit::getFullName)
.hasSize(3); // LambdaTest.<init>, LambdaTest.get(), LambdaTest.lambda$get$0()
changed to hasSize(2)
(without LambdaTest.lambda$get$0()
) with a404fb4b5a948011b7764f5ba0a31426bc98bfe8.
As JavaClass#getCodeUnits()
does not include the lambda body anymore, the corresponding dependencies are missing in JavaClass#getDirectDependenciesFromSelf()
as well.
Thanks for reporting this, this seems to be actually a bug :see_no_evil: AFAIS referenced class objects (and also instanceof checks for that matter) are bypassing the lambda resolution logic. I'll try to fix that ASAP and release a bugfix version!
Thanks for your effort, @codecholeric! I'm looking forward to the bugfix release.
Since version 1.0.0, the method
JavaClass#getDirectDependenciesFromSelf
no longer finds classes referenced in lambdas.Unit-Test to reproduce the problem:
While the Number.class and Optional.class are found, the String.class referenced in a lambda is not found:
This used to work as expected with version 0.23.1. It could be related to #847, but I cannot see an obvious reason.
Thanks for looking into this!