{"id":22442820,"url":"https://github.com/eric2788/reflectionproxy","last_synced_at":"2025-10-15T09:14:41.059Z","repository":{"id":266250279,"uuid":"897817688","full_name":"eric2788/ReflectionProxy","owner":"eric2788","description":"using java reflection elegantly with metaprogramming","archived":false,"fork":false,"pushed_at":"2024-12-13T09:51:31.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T15:09:25.105Z","etag":null,"topics":["java","java-proxy","metaprogramming","reflection","reflection-library"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eric2788.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-12-03T09:43:31.000Z","updated_at":"2024-12-13T09:51:35.000Z","dependencies_parsed_at":"2024-12-03T10:46:51.214Z","dependency_job_id":null,"html_url":"https://github.com/eric2788/ReflectionProxy","commit_stats":null,"previous_names":["eric2788/reflectionproxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eric2788%2FReflectionProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eric2788%2FReflectionProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eric2788%2FReflectionProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eric2788%2FReflectionProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eric2788","download_url":"https://codeload.github.com/eric2788/ReflectionProxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245823317,"owners_count":20678173,"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":["java","java-proxy","metaprogramming","reflection","reflection-library"],"created_at":"2024-12-06T02:20:38.812Z","updated_at":"2025-10-15T09:14:41.041Z","avatar_url":"https://github.com/eric2788.png","language":"Java","readme":"# ReflectionProxy\n\n\u003e [!IMPORTANT]\n\u003e This project is proof of concept and just for fun. \n\u003e Use it at your own risk if you want to use it in production.\n\nReflectionProxy is a simple library that allows you to use reflection more elegantly with metaprogramming, eliminating ugly reflection codes on your programs.\n\n## Hook\n\n- [Maven Central](https://central.sonatype.com/artifact/xyz.ericlamm.toolkits/reflection-proxy)\n- [Github Packages](https://github.com/eric2788/ReflectionProxy/packages/2334237)\n\n## Example\n\nAssume you would like to change a private field of an object from a library:\n\n```java\npackage me.example.secret;\n\npublic final class SecretManager {\n\tprivate static final SecretManager instance = new SecretManager();\n\n\tpublic static SecretManager getInstance() {\n\t\treturn instance;\n\t}\n\n\tprivate String secret = \"I am a secret\"; // edit this one\n\n\tpublic void printSecret() {\n\t\tSystem.out.println(secret);\n\t}\n}\n```\n\nCreate a fake inteface for the class:\n\n```java\n@ForClass(\"me.example.secret.SecretManager\")\npublic interface SecretManagerProxy {\n\t\n\t@Declared // declare that this is a declared field\n\t@Field // declare that this is a field\n\tString getSecret();\n\t\n\t@Declared // declare that this is a declared field\n\t@Field // declare that this is a field\n\tvoid setSecret(String secret);\n\n}\n```\n\nRegister the interface and use it\n\n```java\npublic static void main(String[] args) {\n\tvar proxy = ReflectionProxy\n\t\t\t.builder()\n\t\t\t.prepare(SecretManagerProxy.class)\n\t\t\t.build();\n\t\n\tvar ins = SecretManager.getInstance();\n    \tvar secretManager = proxy.createProxyForInstance(SecretManagerProxy.class, ins);\n\tSystem.out.println(\"before\");\n\tins.printSecret();\n\tsecretManager.setSecret(\"this is a new secret\");\n    \tSystem.out.println(\"after\");\n\tins.printSecret();\n}\n```\n\nor checkout the examples from [test package](/src/test/java/xyz/ericlamm/toolkits/reflectionproxy/TestReflectionProxy.java)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feric2788%2Freflectionproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feric2788%2Freflectionproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feric2788%2Freflectionproxy/lists"}