Java 14 support
Decat-SimonA opened this issue ยท 10 comments
Hello,
running junit-quickcheck on JDK 14 throws this error:
java.lang.ExceptionInInitializerError
at com.pholser.junit.quickcheck.generator.java.util.function.SupplierGenerator.generate(SupplierGenerator.java:48)
at com.pholser.junit.quickcheck.generator.java.util.function.SupplierGenerator.generate(SupplierGenerator.java:41)
at com.pholser.junit.quickcheck.internal.generator.PropertyParameterGenerationContext.generate(PropertyParameterGenerationContext.java:82)
at com.pholser.junit.quickcheck.internal.SeededValue.<init>(SeededValue.java:37)
...
Caused by:
com.pholser.junit.quickcheck.internal.ReflectionException: java.lang.NoSuchMethodException: java.lang.invoke.MethodHandles$Lookup.<init>(java.lang.Class,int)
at com.pholser.junit.quickcheck.internal.Reflection.reflectionException(Reflection.java:288)
at com.pholser.junit.quickcheck.internal.Reflection.findDeclaredConstructor(Reflection.java:101)
at com.pholser.junit.quickcheck.generator.Lambdas.<clinit>(Lambdas.java:49)
@Decat-SimonA Thanks for reporting this. I'll see if I can reproduce this. Would you be able to share a minimal example?
Never mind, it's occurring in a clinit. Have to see whether we can accomplish what we want another way in JDK >= 14.
This is a bit tricky. The issue centers around trying to be able to invoke an interface method marked default
, whose receiving object is a dynamic proxy for that interface. For example, this test using Predicate.or.
When I developed this ability for JDK 8, I leaned on a solution from here...but never looked into whether this worked on newer JDK (it doesn't).
An intermediate step in the right direction might be to do the reflection only if needed. Right now it's invoked whenever class Lambdas
is loaded, in static initialization. After that, I will probably need to sniff the JDK and figure out version-specific solutions.
@Decat-SimonA If you would, have a look at this PR: #265 -- I believe it'll solve the issue you encountered. Thanks!
@pholser
Maybe you want to automatically build on Java > 8 as well.
see https://github.com/jlink/jqwik/blob/master/.travis.yml
@jlink Good point, thanks. Only thing I'll have to reconcile is an implementation of AnnotatedArrayType
that's missing a method added in JDK 9. Perhaps I'll add is implementation but won't mark it as @Override
.
Was there a new release containing this fix? I just bumped to 0.9.2 (latest I can find on Maven Central/JCenter) but I still get similar exceptions ๐
If not, would you mind publishing it, please? ๐
Hi @sir4ur0n -- 0.9.3 should be available shortly; once it is, can you see whether it resolves the issue for you? Thanks much
Sorry @pholser I didn't received the github notification ๐
0.9.3 works fine in JDK 14, thanks a lot !
@Decat-SimonA @sir4ur0n Thanks for verifying, and for your patience.