{"id":19742669,"url":"https://github.com/angrycarrot789/reghzyasmwrappers","last_synced_at":"2026-06-16T09:32:38.256Z","repository":{"id":107349215,"uuid":"455916955","full_name":"AngryCarrot789/REghZyASMWrappers","owner":"AngryCarrot789","description":"A small library for creating custom MethodAccessors, generated using bytecode ASM, which can act as replacements for reflection","archived":false,"fork":false,"pushed_at":"2022-02-05T23:22:41.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T07:04:00.141Z","etag":null,"topics":["asm","bytecode","bytecode-generation","java","reflection"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AngryCarrot789.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-02-05T16:07:01.000Z","updated_at":"2022-02-05T20:44:32.000Z","dependencies_parsed_at":"2023-05-17T03:15:42.557Z","dependency_job_id":null,"html_url":"https://github.com/AngryCarrot789/REghZyASMWrappers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AngryCarrot789/REghZyASMWrappers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngryCarrot789%2FREghZyASMWrappers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngryCarrot789%2FREghZyASMWrappers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngryCarrot789%2FREghZyASMWrappers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngryCarrot789%2FREghZyASMWrappers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AngryCarrot789","download_url":"https://codeload.github.com/AngryCarrot789/REghZyASMWrappers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngryCarrot789%2FREghZyASMWrappers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34400451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asm","bytecode","bytecode-generation","java","reflection"],"created_at":"2024-11-12T01:33:09.073Z","updated_at":"2026-06-16T09:32:38.239Z","avatar_url":"https://github.com/AngryCarrot789.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REghZyASMWrappers\nA small library for creating MethodAccessors, generating using bytecode ASM, which can act as replacements for reflection.\n\nOne use i can think of, is Scala-Java interop, because i've found it to be quite dodgy\n\n## Example\n```java\n// func_72798_a == getBlockId(int,int,int) -\u003e int\nMethodAccessor\u003cWorld, Integer\u003e getIdAccessor = ASMMethodAccessor.create(World.class, \"func_72798_a\", int.class, int.class, int.class);\nWorld overworld = getWorld(\"world\");\nint blockId = getIdAccessor.invokeInt(overworld, 2250, 67, -2434);\nSystem.out.println(blockId);\n\nMethodAccessor\u003cWorld, Boolean\u003e blockSolidityAccessor = \n        ASMMethodAccessor.create(\n                World.class, \n                \"isBlockSolidOnSide\", \n                int.class, int.class, int.class, ForgeDirection.class);\n// returns primitive boolean, not Boolean wrapper\nif (blockSolidityAccessor.invokeBool(overworld, 2250, 67, -2434, ForgeDirection.DOWN)) {\n    ...\n}\n```\n\n# What it looks like when decompiled\nTake this code:\n```java \nMethodAccessor\u003cMyWorld, Integer\u003e accessor = \n    ASMMethodAccessor.create(\n            MyWorld.class, \n            \"getBlockId\", \n            int.class, int.class, int.class);\n```\n\nWhen fully generated, written to a `.class` file, and opened in jd-gui, it will look like this:\n\n```java\nimport reghzy.asm.Main;\nimport reghzy.asm.MethodAccessor;\n\npublic class REghZyASMMethod_MyWorld_getBlockId_0 implements MethodAccessor {\n    public int invokeInt(Object target, Object[] params) {\n        return ((Main.MyWorld) target).getBlockId(((Integer) params[0]).intValue(), \n                                                  ((Integer) params[1]).intValue(), \n                                                  ((Integer) params[2]).intValue());\n    }\n}\n```\n\n\u003e I manually renamed the args to `target` and `params`, because they won't keep their name during runtime\n\n# The only big problem\nDue to java's access security (private/protected/etc), you can't use the ASM method accessors for invoking inaccessible methods. So basically, you can only really invoke public methods, and i suppose you could invoke package-private/protected methods if you edit the ASM generated class' package location, but i haven't tried that\n\nSo unless it's possible to somehow add a bypass, i can only see this ASM method accessor being useful for dynamically loaded classes, e.g minecraft/bukkit plugins (event handlers maybe), invoking methods where you don't have access to the actual source code (e.g missing a library reference in your intellij project), etc\n\nThere's also a few problems i assume one might run into, and it's to do with NoClassDefErrors being thrown. Classes are defined not only by FQCN (fully qualified class name; class name and package), but also their classloader. So if the ASM tries to invoke a method in a class that was loaded by a classloader that isn't similar to the ASMClassLoader, then the class won't be found.\n\nI'm not sure if making the ASMClassLoader's parent equal to the parent of the target method's classloader will fix it. E.g:\n\n`ASMClassLoader -\u003e LaunchClassLoader -\u003e SystemClassLoader -\u003e null`\n\n`BukkitPluginClassLoader -\u003e LaunchClassLoader -\u003e SystemClassLoader -\u003e null`\n\nBut i remember testing this with minecraft forge, and this didn't work (i was trying to listen to forge events from a bukkit plugin. Plugins are loaded by a PluginClassLoader, whose parents are LaunchClassLoader, but forge events are loaded by LaunchClassLoader, and the ASM event handlers are loaded by an ASMClassLoader whose parent is LaunchClassLoader)\n\nI also have no idea why i kept writing what i wrote above... but if you read it all and understand some of it... nice :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangrycarrot789%2Freghzyasmwrappers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangrycarrot789%2Freghzyasmwrappers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangrycarrot789%2Freghzyasmwrappers/lists"}