-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace hardcoded classnames and reflection with ServiceLoader #458
Conversation
…sses. By using ServiceLoader the hardcoded dependency of implementation classes becomes obsolete, so that the API will be truly independent from the implementation. Also this approach paves the way for migration to JPMS modules, as these also leverage the ServiceLoader API.
…mplementation classes.
… reflection to invert dependencies.
…d hardcoded reference.
…hardcoded reference.
Strange... the builds for JDK7 and JDK10 failed with the following error:
Neither the JDK8 or JDK9 builds failed for this reason, while they're using the exact same plugin. Also, when I manually look up all artifacts mentioned in above error message I can all download them from Maven central. Must have been a glitch or something. Will close and re-open to trigger a fresh build. |
So this time the JDK7 and 10 builds succeeded, but now the JDK9 build failed for the same reason. That's eerily flaky. I unfortunately can't connect the error nor the flakiness with the changes in the PR. |
Turns out more people are experiencing similar issues with Travis and Maven Central: https://travis-ci.community/t/continuous-maven-repo-403/3908. Apparently Travis is currently investigating. |
An issue was also reported at Sonatype: https://issues.sonatype.org/browse/MVNCENTRAL-4985. According to the comments on that issue several more IP's are now whitelisted. Will trigger a build again to see if this resolved the issue. |
According to the Travis incident report the issue is now resolved. https://www.traviscistatus.com/incidents/mm020jn4nzcn |
@jaapcoomans I just wanted to let you know I haven't forgotten about this - but it is substantial and I need to dig in to it a little further. For example, for semantic versioning reasons, we cannot move existing classes or interfaces into other packages - they must remain in the packages where they currently are, and it's not yet clear to me if your PR re-arranges packages yet. Also, things in the Thanks! |
P.S. I do want to say that this PR does look promising! I like the idea of the |
Also, @jaapcoomans have you tested this on Android? Does |
Looks like it has been available in Android since Service Level 9, aka "Gingerbread": https://developer.android.com/reference/java/util/ServiceLoader |
Hi @lhazlewood, thanks for the constructive feedback :) I must admit I haven't tested on Android, as I have no idea how to do that. Is support starting from Gingerbread sufficient in your opinion? I took the backwards compatibility requirement into account. If I'm not mistaken the PR does not break clients of the |
I think that because Gingerbread onwards has support for |
Resolved conflicts and continued work in #496 Thanks again @jaapcoomans !! |
Replace hardcoded class names and reflection with ServiceLoader Fixes: #458
Currently there are several dependencies on class names between modules that go in the reverse direction of the actual dependency. This is because hardcoded class names and reflection are being used. By using
ServiceLoader
instead of the current setup, the dependency points in the right direction at all source levels. This makesjjwt-api
fully independent and agnostic ofjjwt-impl
andjjwt-impl
fully independent and agnostic ofjjwt-jackson
andjjwt-orgjson
.It is quite a big change, but I believe it's worth it. It makes it easier to develop API's, implementations and extensions separately. Currently many reported issues are blocked by the fact that jjwt is used on both Android (JDK 1.7) and regular Java (JDK 8+). This PR still is fully JDK 1.7 compliant, yet at the same is a first step to supporting JPMS.