{"id":16375014,"url":"https://github.com/moderocky/glass","last_synced_at":"2025-07-01T18:03:31.557Z","repository":{"id":103957247,"uuid":"433140818","full_name":"Moderocky/Glass","owner":"Moderocky","description":"A lightweight framework for accessing hidden types with version-incompatibility.","archived":false,"fork":false,"pushed_at":"2022-01-13T18:56:04.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T03:06:49.011Z","etag":null,"topics":["bytecode","java","proxy"],"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/Moderocky.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":"2021-11-29T17:43:18.000Z","updated_at":"2024-07-27T10:21:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"8cc04afc-bd09-4b85-8ce9-d097222b395f","html_url":"https://github.com/Moderocky/Glass","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Moderocky/Glass","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FGlass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FGlass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FGlass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FGlass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moderocky","download_url":"https://codeload.github.com/Moderocky/Glass/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FGlass/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263013703,"owners_count":23399812,"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":["bytecode","java","proxy"],"created_at":"2024-10-11T03:19:06.800Z","updated_at":"2025-07-01T18:03:31.524Z","avatar_url":"https://github.com/Moderocky.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Glass\n=====\n\n### Opus #9\n\nThis miniature framework is designed to make working with blind, version-dependent method names much easier.\nIt allows the user to link a single template interface to a nondescript object at runtime and call its methods directly, without needing reflection or multiple per-version classes.\n\n\n## Maven Information\n```xml\n\u003crepository\u003e\n    \u003cid\u003ekenzie\u003c/id\u003e\n    \u003cname\u003eKenzie's Repository\u003c/name\u003e\n    \u003curl\u003ehttps://repo.kenzie.mx/releases\u003c/url\u003e\n\u003c/repository\u003e\n``` \n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003emx.kenzie\u003c/groupId\u003e\n    \u003cartifactId\u003eglass\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n## Introduction\n\nThis utility was designed for Minecraft server development to make working with the proprietary server code (\"NMS\") easier, as method and class names are often changed between major and minor versions.\nThe two existing methods of using NMS are to:\n- create an edition of each dependent class for each version, using the methods directly (low overhead, high effort)\n- use reflection to access NMS methods by name (high overhead, low effort)\n\nGlass aims to solve this problem by giving a low overhead, low effort alternative: a single interface can be mapped to multiple NMS versions, with the linking code written at runtime by the library, when you know which version of the class to use.\nIt functions similarly to a proxy but with the advantage of smarter mapping and no methodhandles.\n\nGlass requires no reflective method calls to the actual object.\n\n## Example\n\n```java\npublic interface Thing\n    extends Window {\n\n    @Target(handler = \"1_16\", name = \"getVersion\")\n    @Target(handler = \"1_17\", name = \"v\")\n    int getVersion();\n\n}\n```\n\nThis example is designed for linking to an internal \"version\" method, for which the name changes between versions.\nYou could then use it as follows:\n```java \nfinal Thing window = glass.createWindow(Thing.class, server, \"1_17\");\nassert window.getVersion() == ...;\n```\n\n## Explanation\n\nWhen a window is mapped, the framework writes a special internal class that implements the template interface, and bridges each method to the one available at runtime.\n\nThe `handler` parameter is used as a way of differentiating between these, and a Target with no `handler` will be used as the default.\n\nGlass is able to intelligently convert compatible parameter types (e.g. Object -\u003e String) in case the actual method parameter or return type is unavailable at the program's compile-time, or otherwise unusable.\n\nMapped window classes will be cached and reused where possible, and disposed of once the creating `Glass` instance and all uses have been garbage-collected for memory efficiency.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoderocky%2Fglass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoderocky%2Fglass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoderocky%2Fglass/lists"}