You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OK, bit of an edge case I admit, but I notice that @inrange doesn't work in Kotlin. I believe it is because the Kotlin compiler doesn't support ElementType.TYPE_USE, so that Parameter.getAnnotatedType().getAnnotations() returns an empty array.
TBH I don't grok the significance of TYPE_USE. I'm happy to help if I can - I have a failing Kotlin test case and a passing Java one.
In my opinion, having junit-quickcheck honor configuration annotations on type uses is a nice touch. That, coupled with junit-quickcheck's unabashed JDK >= 8-only mindset, makes me reluctant to undo the additions of ElementType.TYPE_USE on junit-quickcheck's supplied configuration annotations.
That's cool - I'm learning there are unsung additions to Java 8!
If you were to fetch the annotations directly through parameter.getAnnotations() as well as getAnnotatedType().getAnnotations() it would find those added by the Kotlin compiler. Of course you'd then have the problem of how to merge them - is that conceptually hard?
I've just run into the same problem with @ValuesOf.
If you were to fetch the annotations directly through parameter.getAnnotations() as well as getAnnotatedType().getAnnotations() it would find those added by the Kotlin compiler.
+1
Raised a Kotlin issue for supporting TYPE_USE (https://youtrack.jetbrains.com/issue/KT-10558). However, it will likely take a while until Java 8 constructs are supported in Kotlin, and I'd love to use junit-quickcheck before that happens.
@dmcg@pniederw Let me make sure I'm understanding the problem correctly. Is it the case that the Kotlin compiler creates class files such that annotations such as @InRange and @ValuesOf on a method parameter are available via parameter.getAnnotations() but not via parameter.getAnnotatedType().getAnnotations()?
If so, I suspect that we could ask for both sets of annotations on creation of a ParameterTypeContext and union the sets.
Is it the case that the Kotlin compiler creates class files such that annotations such as @inrange and @ValuesOf on a method parameter are available via parameter.getAnnotations() but not via parameter.getAnnotatedType().getAnnotations()?
That's what I've been seeing in my experiments.
If so, I suspect that we could ask for both sets of annotations on creation of a ParameterTypeContext and union the sets.
Sounds good, happy to test a snapshot with this change.
@dmcg@pniederw Give latest 0.6 alpha 3 snapshot at oss.sonatype.org a spin, and let me know if this works any better for you. My admittedly cursory Kotlin tests seemed to honor the config annotations.
Activity
pholser commentedon Jan 2, 2016
ElementType.TYPE_USEis to enable the annotation on constructs likeList<@InRange(...) Integer>:http://pholser.github.io/junit-quickcheck/site/0.6-alpha-3-SNAPSHOT/usage/configuring.html
In my opinion, having junit-quickcheck honor configuration annotations on type uses is a nice touch. That, coupled with junit-quickcheck's unabashed JDK >= 8-only mindset, makes me reluctant to undo the additions of
ElementType.TYPE_USEon junit-quickcheck's supplied configuration annotations.dmcg commentedon Jan 2, 2016
That's cool - I'm learning there are unsung additions to Java 8!
If you were to fetch the annotations directly through parameter.getAnnotations() as well as getAnnotatedType().getAnnotations() it would find those added by the Kotlin compiler. Of course you'd then have the problem of how to merge them - is that conceptually hard?
pniederw commentedon Jan 3, 2016
I've just run into the same problem with
@ValuesOf.+1
Raised a Kotlin issue for supporting
TYPE_USE(https://youtrack.jetbrains.com/issue/KT-10558). However, it will likely take a while until Java 8 constructs are supported in Kotlin, and I'd love to use junit-quickcheck before that happens.pholser commentedon Jan 3, 2016
@dmcg @pniederw Thanks for the info! This'll be interesting to dive into Kotlin a bit.
pholser commentedon Jan 4, 2016
@dmcg @pniederw Let me make sure I'm understanding the problem correctly. Is it the case that the Kotlin compiler creates class files such that annotations such as
@InRangeand@ValuesOfon a method parameter are available viaparameter.getAnnotations()but not viaparameter.getAnnotatedType().getAnnotations()?If so, I suspect that we could ask for both sets of annotations on creation of a
ParameterTypeContextand union the sets.pniederw commentedon Jan 4, 2016
That's what I've been seeing in my experiments.
Sounds good, happy to test a snapshot with this change.
dmcg commentedon Jan 4, 2016
I concur.
Thanks for working on this - I want to play with shrinking!
For #77, Kotlin compiler re: config annotations
pholser commentedon Jan 9, 2016
@dmcg @pniederw Give latest 0.6 alpha 3 snapshot at oss.sonatype.org a spin, and let me know if this works any better for you. My admittedly cursory Kotlin tests seemed to honor the config annotations.
dmcg commentedon Jan 11, 2016
Couldn't find snapshot on sonatype, but building from source gives expected behaviour for
@InRangein Kotlin. Thanks!Merge pull request #83 from /issues/77/scrape-annotations-from-parame…
Update to junit-quickcheck 1.0 and corresponding ParameterTypeContext…