Graalvm Annotations
Java Annotations for generating Graalvm ReflectionConfigurationFiles (https://github.com/oracle/graal/blob/master/substratevm/Reflection.md).
Can be used in combination with Gradle Graalvm Annotation Processor.
Annotation | Description |
---|---|
@Reflectable | Can be applied to a class add the class to Graalvm's list of reflection classes to process, (based on https://github.com/oracle/graal/blob/master/substratevm/Reflection.md). |
@ReflectableClass | Manually configure Graalvm reflection class (based on https://github.com/oracle/graal/blob/master/substratevm/Reflection.md). Can be used on any class you cannot apply the @Reflectable annotation to. |
@ReflectableClasses | List of ReflectableClass definitions. |
@ReflectableField | Used with @ReflectableClass to define Graalvm reflection for a class field. |
@ReflectableMethod | Used with @ReflectableClass to define Graalvm reflection for a class method. |
@ReflectableImport | Import existing Graalvm 'ReflectionConfigurationFiles' File. |
Maven Installation
Add the following to your pom.xml
<dependency>
<groupId>com.formkiq</groupId>
<artifactId>graalvm-annotations</artifactId>
<version>1.0.0</version>
<!-- Replace 1.0.0 with the version you want to use -->
</dependency>
Gradle Installation
Add the following to your build.gradle
implementation group: 'com.formkiq', name: 'graalvm-annotations', version:'1.0.0'
<!-- Replace 1.0.0 with the version you want to use -->
@Reflectable Example
TestObject.java
@Reflectable class TestObject { /** Preset Key. */ @Reflectable private String id; }
@ReflectableClasses / @ReflectableClass Example
TestObject.java
class TestObject { private String foo; public void bar(String s) {} }
Test.java
@ReflectableClasses({ @ReflectableClass( className=TestObject.class, allDeclaredConstructors=false, fields = {@ReflectableField(allowWrite = true, name = "foo")}, methods = {@ReflectableMethod(name = "bar", parameterTypes = {"java.lang.String"})} ) }) class Test { }
@ReflectableImport classes Example
Test.java
@Reflectable class TestObject { /** Preset Key. */ @Reflectable private String id; }
@ReflectableImport(classes = {TestObject.class}) class Test { }
@ReflectableImport file Example
test.json
[ { "name": "sample.Test", "allDeclaredConstructors": true, "allPublicConstructors": true, "allDeclaredMethods": true, "allPublicMethods": true, "fields": [ { "name": "foo" } ], "methods": [ { "name": "bar", "parameterTypes": [ "int" ] } ] } ] }
Test.java
@ReflectableImport(files="test.json") class Test { }