{"id":18675540,"url":"https://github.com/bithatch/native-image-annotations","last_synced_at":"2025-11-07T05:30:42.730Z","repository":{"id":57743616,"uuid":"476857066","full_name":"bithatch/native-image-annotations","owner":"bithatch","description":"A set of annotations and an annotation processor to help with GraalVM native image","archived":false,"fork":false,"pushed_at":"2024-08-08T21:11:52.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T20:35:15.218Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bithatch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-01T20:16:23.000Z","updated_at":"2024-08-08T21:11:56.000Z","dependencies_parsed_at":"2022-08-26T01:50:35.643Z","dependency_job_id":"1408e4c9-43a0-4f3b-bb8f-521f0862fc2e","html_url":"https://github.com/bithatch/native-image-annotations","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Fnative-image-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Fnative-image-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Fnative-image-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Fnative-image-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bithatch","download_url":"https://codeload.github.com/bithatch/native-image-annotations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239520208,"owners_count":19652651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T09:25:21.142Z","updated_at":"2025-11-07T05:30:42.680Z","avatar_url":"https://github.com/bithatch.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# native-image-annotations\n\nA set of annotations and an [annotation processor](https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html) to help with [GraalVM native image](https://www.graalvm.org/native-image/).\n\nFor a native image to be built, all reflection, proxies, JNI, classpath resource and other elements that would usually be discovered at runtime, must be declared at compile time.\n\nInstead of using the [GraalVM tracing agent](https://www.graalvm.org/22.0/reference-manual/native-image/Agent/), or hand crafting native image [configuration files](https://www.graalvm.org/22.0/reference-manual/native-image/BuildConfiguration/), you can annotate your classes, interfaces, methods and fields. These annotations are then turned into JSON files consumed by the native image compiler.\n\nIt is currently most useful for exposing certain elements to reflection, and the reason I created it was to help generate natively compiled DBus services using [DBus Java](https://github.com/hypfvieh/dbus-java) on Linux.  \n\nThe annotations are only source only, so the library is only needed during development and build time. \n\n## Installation\n\nThe library is available in Maven Central (and OSS Snapshots). You need to add it as a compile time dependency, and an annotation processor. Gradle also supports annotations processors, or you can use them with the standard Java compiler.\n\n### Dependency\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003euk.co.bithatch\u003c/groupId\u003e\n    \u003cartifactId\u003enative-image-annotations\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.1-SNAPSHOT\u003c/version\u003e\n    \u003cscope\u003eprovided\u003c/scope\u003e\n\u003c/dependency\u003e \n```\n\n#### Snapshot Repository\n\n*Not required if using a stable version.*\n\n```xml\n\n\u003crepository\u003e\n    \u003cid\u003eoss-snapshots\u003c/id\u003e\n    \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n    \u003csnapshots /\u003e\n    \u003creleases\u003e\n        \u003cenabled\u003efalse\u003c/enabled\u003e\n    \u003c/releases\u003e\n\u003c/repository\u003e\n```\n\n\n### Annotation Processor\n\nYou must add the annotation processor to your compiler. \n\n#### Maven\n\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n            \u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n            \u003cconfiguration\u003e\n                \u003cannotationProcessorPaths\u003e\n                    \u003cpath\u003e\n                        \u003cgroupId\u003euk.co.bithatch\u003c/groupId\u003e\n                        \u003cartifactId\u003enative-image-annotations\u003c/artifactId\u003e\n                        \u003cversion\u003e0.0.1-SNAPSHOT\u003c/version\u003e\n                    \u003c/path\u003e\n                \u003c/annotationProcessorPaths\u003e\n            \u003c/configuration\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n### JPMS\n\nThe module must be added, even though it won't be available at runtime.\n\n```java\nrequires static uk.co.bithatch.nativeimage.annotations\n```\n\n## Usage\n\nTo use, simply annotation you source elements appropriately. In the example below, reflection configuration will be created, exposing `MyNativeService` and all of its methods, as well as a single field and a method from `MyObject`.\n\n```java\n@Reflectable\n@TypeReflect(methods = true, classes = true)\npublic class MyNativeService {\n\n    public List\u003cString\u003e getListOfSomething() {\n        return Arrays.asList(\"one\", \"two\", \"three\");\n    }\n\n    public MyObject getAnObject(String name) {\n        return new MyObject(name, name + \" private\");\n    }\n\n    @Reflectable\n    @TypeReflect(constructors = true)\n    public static class MyObject {\n        @Reflectable\n        private String someValue;\n        private String somePrivateValue;\n\n        public MyObject(String someValue, String somePrivateValue) {\n            this.someValue = someValue;\n            this.somePrivateValue = somePrivateValue;\n        }\n        \n        @Reflectable\n        public String getSomeValue() {\n            return someValue;\n        }\n        \n        public String getSomePrivateValue() {\n            return somePrivateValue;\n        }\n    }\n}\n```\n\n### Annotations\n\n#### @Reflectable\n\nMarks either a `TYPE`, `CONSTRUCTOR`, `FIELD` or `METHOD` as a candidate for reflection. It has a single attribute, `all()` that will signal that *all* child elements will also be reflectable.\n\nConfiguration will be added to `reflect-config.json`.\n\n#### @TypeReflect\n\nUsed in on a `TYPE` in conjunction with a `@Reflectable`, this annotation provides 4 attributes allowing control of whether all child elements of a certain type should be reflectable.\n\nIt supports, `constructors()`, `fields()`, `methods()` or `classes()`.\n\nConfiguration will be added to `reflect-config.json`.\n\n#### @Proxy\n\nMarks a `TYPE` as a Proxy type. \n\nConfiguration will be added to `proxy-config.json`.\n\n#### @Serialization\n\nMarks a `TYPE` for serialization. \n\nConfiguration will be added to `serialization-config.json`.\n\n#### @Bundle\n\nAdds an i18n resource bundle for a `TYPE`. A single attribute is supported, `locales()` which is an optional list of locales to include.\n\nFor example, if the class `com.acme.MyObject` was annotated with `@Bundle`, then the default resource path of `com/acme/MyObject.properties` must exist. There can be optional resources such as `com/acme/MyObject_fr.properties` etc.\n\n#### @Resource\n\nIntroduces classpath resources. Exact behaviour will depend on attributes used.\n\n * If the annotation has no attributes, then all resources in the same package, and prefixed with the same class name will be included. For example, if the annotated class's full qualified name is `com.acme.MyObject`, then `/com/acme/MyObject.properties`, `/com/acme/MyObject.css` and so on will be included.\n * If the annotation sets the `siblings()` attribute to true, then all resources in the same project will be incluided.\n * Otherwise, the annotation `value()` is an array of *absolute* resource paths. \n\nConfiguration will be added to `resources-config.json`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbithatch%2Fnative-image-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbithatch%2Fnative-image-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbithatch%2Fnative-image-annotations/lists"}