{"id":46082465,"url":"https://github.com/taboolib/reflex","last_synced_at":"2026-03-01T16:01:48.511Z","repository":{"id":44817995,"uuid":"450644012","full_name":"TabooLib/reflex","owner":"TabooLib","description":"Reflection API for Kotlin","archived":false,"fork":false,"pushed_at":"2025-11-17T16:08:49.000Z","size":217,"stargazers_count":25,"open_issues_count":0,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-17T17:19:07.426Z","etag":null,"topics":["kotlin","kotlin-library","reflection","reflection-library"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TabooLib.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-01-21T21:23:50.000Z","updated_at":"2025-11-17T16:08:53.000Z","dependencies_parsed_at":"2024-09-15T17:28:13.570Z","dependency_job_id":"d33bfb5d-a63f-4de6-b968-0d349fe68583","html_url":"https://github.com/TabooLib/reflex","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/TabooLib/reflex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TabooLib%2Freflex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TabooLib%2Freflex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TabooLib%2Freflex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TabooLib%2Freflex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TabooLib","download_url":"https://codeload.github.com/TabooLib/reflex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TabooLib%2Freflex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29974321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T15:41:30.362Z","status":"ssl_error","status_checked_at":"2026-03-01T15:37:07.343Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["kotlin","kotlin-library","reflection","reflection-library"],"created_at":"2026-03-01T16:01:47.819Z","updated_at":"2026-03-01T16:01:48.487Z","avatar_url":"https://github.com/TabooLib.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reflex\n![](https://img.shields.io/github/v/release/taboolib/reflex.svg)\n\n```kotlin\nrepositories {\n    maven { url = uri(\"https://repo.tabooproject.org/repository/releases/\") }\n    mavenCentral()\n}\n\ndependencies {\n    // 本体\n    implementation(\"org.tabooproject.reflex:analyser:{version}\")\n    implementation(\"org.tabooproject.reflex:fast-instance-getter:{version}\")\n    implementation(\"org.tabooproject.reflex:reflex:{version}\") // 需要 analyser 模块\n    // 本体依赖\n    implementation(\"org.ow2.asm:asm:9.2\")\n    implementation(\"org.ow2.asm:asm-util:9.2\")\n    implementation(\"org.ow2.asm:asm-commons:9.2\")\n    implementation(kotlin(\"stdlib\"))\n}\n```\n\n## analyser \u0026 reflex\nReflex 为基于 Kotlin 语言开发的反射工具，其与 Java 原生反射 API 及 `kotlin-reflect` 间最大区别在于其可**无视软兼容**反射目标类中的字段或方法。 \n\n如下方代码所示，此类现象在 Bukkit 插件开发中较为常见：\n\n```java\npublic class AnyPlugin extends JavaPlugin {\n    \n    private PlayerPointsAPI api; // PlayerPoints\n    private AnyField target;\n}\n```\n\n习惯于将其他插件内的接口缓存于主类的 Bukkit 开发者不在少数，因即便此时 `PlayerPoints` 并未安装，类的运行和插件的启动也不会受到影响。但此做法造成的结果是开发者无法通过反射获取该类中的任何字段：\n\n```java\nField field = Main.class.getDeclaredField(\"target\"); // NoClassDefFoundError: PlayerPointsAPI\n```\n\n同类问题也存在于 Bukkit 监听器的注册之上。若插件运行于 1.12 版本以下的环境时，下述 `PlayerJoinEvent` 监听器将无法正常注册。\n\n```java\npublic class AnyListener extends Listener {\n    \n    @EventHandler\n    public void onJoin(PlayerJoinEvent event) {\n        // 全版本\n    }\n    \n    @EventHandler\n    public void onSwap(PlayerSwapItemEvent event) {\n        // 1.12 新增\n    }\n}\n```\n\n因此， Reflex 脱身于 [TabooLib](https://github.com/taboolib/taboolib) 并发展为独立类库。通过此类库，下述操作将成为可能：\n\n+ 在 [AnalyserTestAsm.kt](https://github.com/TabooLib/Reflex/blob/master/analyser/src/test/kotlin/org/tabooproject/reflex/AnalyserTestAsm.kt) 中获取 `analyser` 的用法。\n+ 在 [ReflexTest.kt](https://github.com/TabooLib/Reflex/blob/master/reflex/src/test/kotlin/org/tabooproject/reflex/ReflexTest.kt) 中获取 `reflex` 的用法。\n\n## fast-instance-getter\n基于 Java 且不依赖反射的高性能 Kotlin 单例/伴生类实例获取工具，此工具同样解决了上述问题。\n\n```kotlin\nval getter = FastInstGetter(ObjectTarget::class.java.name) // 初始化损耗较高，复用时需手动缓存该实例\ngetter.instance // 获取单例实例\ngetter.companion // 获取伴生类实例\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaboolib%2Freflex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaboolib%2Freflex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaboolib%2Freflex/lists"}