Reflect is a lightweight Java library designed to simplify and enhance the use of reflection. It provides a fluent and intuitive API for accessing classes, methods, fields, constructors, and annotations.
We use Semantic Versioning 2.0.0 to manage our releases.
- Easy Class and Object Reflection: Access class and object properties effortlessly.
- Method and Field Access: Invoke methods and manipulate fields dynamically.
- Constructor Handling: Create new instances using constructors with or without parameters.
- Annotation Inspection: Inspect methods, fields, and constructors for specific annotations.
- Caching: Efficient reflection with caching of class information.
To use the Reflect library, include it in your project as a dependency.
repositories {
maven("https://repo.jyraf.com/repository/maven-snapshots/")
}
dependencies {
implementation("dev.ckateptb:Reflect:<version>")
}
import dev.ckateptb.reflection.Reflect;
// Reflecting on an object
MyClass instance = new MyClass();
Reflect<MyClass> reflect = Reflect.on(instance);
// Reflection on a class
Reflect<MyClass> reflect = Reflect.on(MyClass.class);
// Accessing fields
String fieldValue = reflect.field("fieldName").get(); // or set
// Invoking methods
reflect.method("methodName").call();
// Creating new instances
MyClass newInstance = reflect.constructor().newInstance().get();
This project is licensed under the GPL-3.0 license.
Contributions are welcome! Feel free to open an issue or submit a pull request.
Special thanks to the developers and contributors of the open-source Java reflection libraries that inspired the creation of Reflect.