Giter VIP home page Giter VIP logo

Comments (9)

sentinelt avatar sentinelt commented on June 20, 2024 1

Classindex analyses the classes as they are compiled. And so must be present on the classpath during compilation. For each compilation unit several indexes are created for all the classes which where compiled. Those indexes are then stored as a resources so they can be retrieved from the classpath at run-time. For instance, if you have a Maven project which builds a jar file then the indexes will take into account all the classes from this jar file, but not from any dependencies of this project. This means you will not get the classes from 3rd party libraries by default.

At runtime, when (for instance) you query for the classes implementing given interface, all the indexes which are reachable from the current context are analysed.

Using URLClassLoader, depending on its logic and assuming it's the only type of ClassLoader used was always a kind of hack IMHO. Instead Classindex uses annotation processing and reflection API. Although annotation processing is rough around the edges, especially when doing incremental compilation, it works pretty well with some workarounds applied.

from classindex.

sentinelt avatar sentinelt commented on June 20, 2024 1

I run it currently on Java 9. Looks OK. Although we do not use much of the new Jigsaw stuff.

from classindex.

lukehutch avatar lukehutch commented on June 20, 2024 1

Hi, I figured out how to scan modules, in case you are interested in adding support for this.

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

from classindex.

sentinelt avatar sentinelt commented on June 20, 2024

Hi, I haven't tested the Classindex with Java 9 yet. I will probably give it a try next week. I expect less compatibility issues with changes made in classloaders mechanics as Classindex is not based on runtime reflections and instead does compile time indexing.

I will add some unit tests to ensure the correctness. In the meantime let me know if you find and issues with it.

from classindex.

kaqqao avatar kaqqao commented on June 20, 2024

It's not only the classloader changes that worry me, but the fact that classpath as such is now kind of a legacy thing. Now each module has its own modulepath, and those can now contain not only file system paths to JAR or class files, but the newly specified jrt:// URLs. Without explicit support for these, I think the scanning would work but would be incomplete.
This is currently the situation in most libraries...

There's some helpful hints in my SO thread.

from classindex.

kaqqao avatar kaqqao commented on June 20, 2024

Btw, pardon my ignorance here, how does ClassIndex decide what paths to scan? Since it all happens at compile time, there's no such thing as classpath yet to tell it.

from classindex.

kaqqao avatar kaqqao commented on June 20, 2024

Ah, I understand now. Thanks for the explanation!

Since it doesn't scan 3rd party classes (including JDK's own), it doesn't sound like it should be bothered much by the Java 9 changes.

from classindex.

ptahchiev avatar ptahchiev commented on June 20, 2024

Any updates here? Is it safe to use classindex with java9?

from classindex.

bmarwell avatar bmarwell commented on June 20, 2024

hey everyone. This is closed, BUT I have some information for you.
In Module 1, I am using the APT to generate the info files. In this module, just use require static org.atteo.classindex on your module-info.java.
In Module 2, I only use it for tests – no additional requirements needed.

HTH

from classindex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.