Comments (9)
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.
I run it currently on Java 9. Looks OK. Although we do not use much of the new Jigsaw stuff.
from classindex.
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.
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.
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.
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.
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.
Any updates here? Is it safe to use classindex with java9?
from classindex.
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)
- Deprecated Gradle setup HOT 2
- META-INF is not changed when file is removed HOT 4
- Problem with eclipse and "Indexing when annotations cannot be used" HOT 1
- Removing dependency to jaxb-api HOT 2
- ClassIndex.getAnnotated returns classes that are no longer annotated HOT 1
- Project URL in POM results in HTTP 404 HOT 1
- ClassIndex must check for NoClassDefFoundError also HOT 2
- Missing changelog for 3.9 HOT 1
- Sub interfaces are added to the service list
- `ClassIndex.getAnnotated()` return nothing, but classes with annotation exist. HOT 2
- Incremental compilation using Gradle is disabled
- Add @RegisterService annotation HOT 1
- Shading relocations are ignored in ClassIndexTransformer
- ClassIndex.getAnnotated(MyAnnotation.class) returns no results HOT 2
- Build crashes in a project using Java records HOT 1
- Update documentation with modular @IndexSubclasses gotcha
- Add support for Java modules HOT 3
- Is this project dead? HOT 1
- Gradle incremental - the final problem HOT 4
- Returns classes that are no longer annotated. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from classindex.