{"id":19458709,"url":"https://github.com/luontola/clojure-native-image-agent","last_synced_at":"2025-04-25T06:30:33.063Z","repository":{"id":42781059,"uuid":"407929421","full_name":"luontola/clojure-native-image-agent","owner":"luontola","description":"Helps GraalVM's native-image-agent to be more useful for Clojure applications.","archived":false,"fork":false,"pushed_at":"2022-07-12T11:43:48.000Z","size":27,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T17:22:58.264Z","etag":null,"topics":["clojure","graalvm-native-image"],"latest_commit_sha":null,"homepage":"","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/luontola.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-18T17:50:09.000Z","updated_at":"2025-03-22T11:27:40.000Z","dependencies_parsed_at":"2022-09-18T05:11:24.036Z","dependency_job_id":null,"html_url":"https://github.com/luontola/clojure-native-image-agent","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Fclojure-native-image-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Fclojure-native-image-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Fclojure-native-image-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Fclojure-native-image-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luontola","download_url":"https://codeload.github.com/luontola/clojure-native-image-agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250766964,"owners_count":21483896,"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":["clojure","graalvm-native-image"],"created_at":"2024-11-10T17:28:11.654Z","updated_at":"2025-04-25T06:30:32.649Z","avatar_url":"https://github.com/luontola.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clojure-native-image-agent for GraalVM\n\n*Helps [GraalVM's native-image-agent](https://www.graalvm.org/reference-manual/native-image/Agent/) to be more useful\nfor Clojure applications.*\n\nBecause Clojure does lots of reflection and bytecode generation when a namespace is loaded, it's necessary to\nuse [build-time initialization](https://www.graalvm.org/reference-manual/native-image/ClassInitialization/)\nfor all Clojure namespaces when compiling it with GraalVM Native Image. We would like `native-image-agent` to not report\nabout the reflection and resource usages that happen during Clojure namespace loading. Also we would like to generate\nthe correct list of classes to put in `--initialize-at-build-time`, i.e. all Clojure namespaces and the Java classes\nwhich were used during Clojure namespace loading.\n\nThat's where this Java agent comes in. You give it the main class of your Clojure application as a parameter, and it\nwill initialize the Clojure namespaces and track all classes that were loaded, before letting `native-image-agent` do\nits thing. As a result, you get a list of classes to `--initialize-at-build-time`, and the configuration files generated\nby `native-image-agent` will be shorter.\n\n## Using\n\nDownload [clojure-native-image-agent.jar](https://github.com/luontola/clojure-native-image-agent/releases/latest/download/clojure-native-image-agent.jar)\nfrom [releases](https://github.com/luontola/clojure-native-image-agent/releases).\n\nRun `clojure-native-image-agent.jar` as a Java agent together with `native-image-agent`.\n\n**The order of command line parameters matters:** `clojure-native-image-agent.jar` must be before `native-image-agent`\non the command line, so that it will run first.\n\n    /usr/bin/java \\\n        -javaagent:clojure-native-image-agent.jar=initialize-class=your_clojure_app.main,output-dir=/tmp/native-image \\\n        -agentlib:native-image-agent=config-merge-dir=/tmp/native-image,config-write-period-secs=5 \\\n        -jar your-clojure-app.jar\n\nThis will generate a `native-image.properties` configuration file in the `output-dir` directory, based on the classes\nthat were loaded during the initialization of `initialize-class`.\n\nThe configuration is simplified for Clojure namespaces, so that only the top level package is listed. Most JDK classes\nare excluded from the configuration, because GraalVM Native Image already handles those. The unredacted list of classes\nis written to `initialized-classes.txt` for debugging purposes.\n\n## Future plans\n\nCurrently, the agent initializes all classes that were loaded during initialization. But the Clojure compiler also loads\nsome classes (Java libraries) without initializing them. Excluding those classes from `--initialize-at-build-time` would\nreduce the risk of encountering incompatible classes.\n\n## Developing\n\nBuild `target/clojure-native-image-agent.jar `\n\n    mvn clean package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluontola%2Fclojure-native-image-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluontola%2Fclojure-native-image-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluontola%2Fclojure-native-image-agent/lists"}