Skip to content
Java annotation scanner.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Reflective annotation scanner for Java.

Why another annotation scanner?

After scouring the web a few times, I could not find an easy way to do a simple task: take a class and scan for annotated properties.

As part of my development efforts on another project, I wrote such an annotation scanner.

I often found myself needing to do this same task; so, I decided to publish the code to make it accessible to others.


Annoscan is in maven central. Simply add the following dependency:



AnnoScan can be configured using a variety of methods.

It relies on constructor injection and is annotated in compliance with JSR-330 containers (Guice, Spring 3, etc).

In addition, it can be handwired manually or obtained using the provider singleton.


AnnoScan annoScan = new AnnoScanImpl(new GetterLocatorImpl());


AnnoScan annoScan = AnnoScanProvider.instance.get();


To scan a class for annotated properties, simply call one of the methods with your class and annotation class.

In unspecified order:

properties = annoScan.getAnnotatedProperties(TestClass.class,TestAnnotation.class);

In sorted order:

sortedProperties = annoScan.getAnnotatedPropertiesSorted(TestClassWithSort.class, TestAnnotation.class, new TestAnnotationComparator());

Then iterate through all of the properties and get the annotation or the value of the field:

for (AnnotatedProperty<TestAnnotation> property: properties) {
	TestAnnotation annotation = property.getAnnotation();
	Object fieldValue = property.getPropertyAccessor().getValue(annotatedObject);

Additional Notes

The default AnnoScan and GetterLocator implementations are stateless and can be instantiated prototypically with minimal overhead, or as singletons.

The default provider instance get method call demonstrated above returns a singleton.

You can’t perform that action at this time.