reflections icon indicating copy to clipboard operation
reflections copied to clipboard

Java 9 support and jrt: URLs

Open kaqqao opened this issue 7 years ago • 12 comments

I was recently trying to research the effects Java 9 will have on class and resource loading and specifically on libraries like Reflections. Based on the info I got (mostly from Mark Reinhold himself), scanning for classes is still possible and Reflections should still work but he noted that, for completeness, it should also scan jrt: URLs. I won't pretend to understand fully what that entails, but was hoping to start a conversation on Java 9 support in Reflections.

kaqqao avatar Jul 20 '17 11:07 kaqqao

Relevant link to the description: https://stackoverflow.com/questions/45166757/loading-classes-and-resources-in-java-9/45173837#45173837

ljacqu avatar Jul 22 '17 09:07 ljacqu

More references on JRT urls http://openjdk.java.net/jeps/220

xiumeteo avatar Aug 05 '17 04:08 xiumeteo

Here's an answer with helpful clues: https://stackoverflow.com/a/45612376/294657

kaqqao avatar Aug 14 '17 07:08 kaqqao

Here is a cheatsheet from competing project: https://github.com/lukehutch/fast-classpath-scanner/issues/36

vkopichenko avatar Oct 20 '17 17:10 vkopichenko

Just to let you know in case anyone is looking on this too, I'm working on an impl of this. It's not ready yet. I'll be able to submit a PR maybe next week. Currently, I'm able to read from jrt paths. But I'm facing some issues during checking against subTypes as described in #202

You can actually see the impl here https://github.com/xiumeteo/reflections/commits/issue-186-add-jrt-support but don't expect clean code yet.

xiumeteo avatar Nov 24 '17 05:11 xiumeteo

Haha! actually I found another rock... http://openjdk.java.net/jeps/261 seems like this issue has to be a migration.

xiumeteo avatar Nov 24 '17 06:11 xiumeteo

Hi guys I couldn't find the time to address this issue. I'll be looking at it but I don't have a estimation of completion

xiumeteo avatar Dec 06 '17 00:12 xiumeteo

Any update on this? Also, how broken is this on java 9, does (like fast-classpath-scanner) everything still work fine when using solely the classpath? Or is the whole API "unusable"?

HoldYourWaffle avatar Feb 19 '18 23:02 HoldYourWaffle

My understanding is that it works just fine, but not with modules. I haven't actually tried it, mind you, I'm basing this on my knowledge on how classpath scanning and modules work... but I'm flaky on the modules bit, so I might be wrong.

kaqqao avatar Feb 20 '18 00:02 kaqqao

Hi, I figured out how to scan modules -- here's the solution:

https://stackoverflow.com/a/45612376/3950982

lukehutch avatar Jun 13 '18 10:06 lukehutch

Has there been any progress on this? It would be great to support module based applications.

tlf30 avatar Oct 24 '22 15:10 tlf30

@tlf30 the module scanning method I posted above is included in the ClassGraph class path scanning library.

https://github.com/classgraph/classgraph

I posted the method here in case the Reflections author wanted to add it to Reflections, but that hasn't happened, so I wouldn't hold my breath!

lukehutch avatar Oct 24 '22 17:10 lukehutch