https://github.com/dorkbox/annotations
Extremely fast and lightweight annotation scanner for the classpath, classloader, or files for Java 6+
https://github.com/dorkbox/annotations
Last synced: about 1 year ago
JSON representation
Extremely fast and lightweight annotation scanner for the classpath, classloader, or files for Java 6+
- Host: GitHub
- URL: https://github.com/dorkbox/annotations
- Owner: dorkbox
- License: other
- Created: 2015-02-02T11:53:42.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-11-27T16:15:01.000Z (over 2 years ago)
- Last Synced: 2025-04-01T06:02:25.200Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 292 KB
- Stars: 9
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Annotations
===========
###### [](https://git.dorkbox.com/dorkbox/Annotations) [](https://github.com/dorkbox/Annotations) [](https://gitlab.com/dorkbox/Annotations)
The Annotations project is based on, and **almost** identical to the excellent [infomas AnnotationDetector](https://github.com/rmuller/infomas-asl).
There are **major** changes to the API to provide for a way to easily extend the scanning functionality, hence it lives here on it's own.
This library can be used to scan (part of) the class path for annotated classes, methods or instance variables. Main advantages of this library compared with similar solutions are: light weight (simple API, **20 kb jar file**) and **very fast** (fastest annotation detection library as far as I know).
The main features of this annotations scanning library:
- scans the bytecode for annotation information, meaning classes do not have to be loaded by the JVM
- small footprint
- *extremely fast* performance (on moderate hardware, about 200 MB/s)!
- can scan the classpath, classloader, or specified location
- uses the SLF4j logging interface
- simple builder style API
- lightweight
- This is for cross-platform use, specifically - linux 32/64, mac 32/64, and windows 32/64. Java 6+
``` java
try {
// Get a list of all classes annotated with @Module, inside the "dorkbox.client" and "dorkbox.common" packages.
List classModules = AnnotationDetector.scanClassPath("dorkbox.client", "dorkbox.common")
.forAnnotations(Module.class) // one or more annotations
.on(ElementType.METHOD) // optional, default ElementType.TYPE. One ore more element types
.filter((File dir, String name) -> !name.endsWith("Client.class")) // optional, default all *.class files
.collect(AnnotationDefaults.getType);
} catch (IOException e) {
throw new IllegalArgumentException("Unable to start the client", e);
}
```
Maven Info
---------
```
...
com.dorkbox
Annotations
3.2
```
Gradle Info
---------
````
dependencies {
...
compile "com.dorkbox:Annotations:3.1"
}
````
License
---------
This project is © 2014, XIAM Solutions B.V. (http://www.xiam.nl) and © 2020 dorkbox llc, and is distributed under the terms of the
Apache v2.0 License. See file "LICENSE" for further references.