Closed allurx closed 4 years ago
There's a couple of bugs in annotation parsing in JDK itself. You can find some more info here: http://stackoverflow.com/questions/39952812/why-annotation-on-generic-type-argument-is-not-visible-for-nested-type
I believe it was fixed in JDK 12, but I'm not 100% sure...
@kaqqao Oh, it turned out to be a jdk bug, I hope jdk can fix this bug as soon as possible. Thank you very much for your reply.
No worries :) Did you verify if it's fixed in newer JDK perhaps?
I just found this problem in jdk1.8. When I have time, I may download the latest jdk to verify this problem, but what confuses me is how to solve this problem if you have to use jdk1.8.
You can't fix it... But you can use TypeFactory
to produce the types instead of using the TypeToken
. Another way is to define all classes at the top level, that seems to dodge the bug. You might also need to declare the types produced by TypeToken
as static class fields.
thanks.:smile:
jdk version
1.8
example
the expected result of the main method
the actual result of the main method
junit result
The test results are unexpected. Do you know where the problem is? thanks.