Barista
Barista copied to clipboard
Java version of assertAny
Library Version:
4.3.0
Describe the Bug:
I am not sure if this is a bug, but I could not find any way to invoke the convenience method assertAny
from Java code.
The Kotlin function(s) are annotated with @JvmStatic
(in BaristaAssertions.kt
) which makes me think that there's meant to be a static version of this method which can be called from Java code, but there is no such method in the final bytecode. There IS a method com.adevinta.android.barista.internal.AssertAnyKt.assertAny
in Java, but that method has a different signature assertAny(Matcher, Matcher)
and also it's clearly an internal method from the package name.
I believe that reified functions cannot be called from Java code, which is why this issue appears.
If this was never meant to be possible, then I apologise and this should not be considered a bug - but in that case I'm not sure why the function is annotated as @JvmStatic
.
Steps to reproduce the bug:
- Write a Java file with
import static com.adevinta.android.barista.assertion.BaristaAssertions.assertAny;
in the imports - Compile and note that the compiler gives an error that the method was not found
Or:
- Extract the
classes.jar
from the finalaar
release of barista - Decompile
classes.jar
using any Java decompiler (I used JD-GUI) - Observe that there is no
assertAny
static method in the final bytecode (apart from the internal version mentioned above)
Expected Behavior:
I expected to be able to import this method and call it from Java code. I am aware that the syntax would not be quite as simple as in Kotlin code, but still better than creating custom matchers. Is it possible to create a non-reified version of this function so it can be called from Java code?