{"id":18718348,"url":"https://github.com/genymobile/mirror","last_synced_at":"2025-04-09T15:08:42.553Z","repository":{"id":27946133,"uuid":"31438780","full_name":"Genymobile/mirror","owner":"Genymobile","description":"Easy reflection for Java and Android","archived":false,"fork":false,"pushed_at":"2019-05-06T22:20:56.000Z","size":816,"stargazers_count":350,"open_issues_count":7,"forks_count":27,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-09T15:08:26.738Z","etag":null,"topics":["android","java","library","reflection"],"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/Genymobile.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-27T20:56:48.000Z","updated_at":"2025-04-06T15:20:05.000Z","dependencies_parsed_at":"2022-07-27T11:32:35.231Z","dependency_job_id":null,"html_url":"https://github.com/Genymobile/mirror","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genymobile%2Fmirror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genymobile%2Fmirror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genymobile%2Fmirror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genymobile%2Fmirror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Genymobile","download_url":"https://codeload.github.com/Genymobile/mirror/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055282,"owners_count":21040157,"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":["android","java","library","reflection"],"created_at":"2024-11-07T13:20:51.914Z","updated_at":"2025-04-09T15:08:42.532Z","avatar_url":"https://github.com/Genymobile.png","language":"Java","readme":"# ![Mirror](icon_mirror.png)Mirror\n\n_Easy reflection for Java and Android_\n\n## Introduction\n\n_Mirror_ turns a private class you want to use reflection on into a Java interface.\n```java\n@Class(\"com.framework.PrivateCoolClass\")\npublic interface CoolClass {\n    @Constructor\n    void callConstructor(String aString);\n\n    // A cool method, we want to call\n    String doCoolStuff(int value);\n}\n```\n\nThe ```Mirror``` class generates an implementation of the ```CoolClass``` interface.\n```java\nCoolClass coolClass = Mirror.create(CoolClass.class)\n```\n\nYou'll need to set up the wrapper with an instance first, for example by calling a constructor.\n```java\ncoolClass.callConstructor(\"Super\"); // this call the PrivateCoolClass(String) constructor;\n```\n\nEach call on the generated ```CoolClass``` wrapper makes a call on the instance of ```PrivateCoolClass```.\n\n```java\n// This will call the method doCoolStuff(int) on the PrivateCoolClass Object\nString cool = coolClass.doCoolStuff(42);\n```\n\n## Refection annotations\n\nUse _Mirror_'s annotations to describe your object wrapper and how you want to interact with it.\n\n### Declaring the private Class\n\nUse the ```Class``` annotation to setup the class you want to use reflection on.\n```java\n@Class(\"com.framework.private.PrivateClass\")\npublic interface NotSoPrivateClass {\n  ...\n}\n```\n\n### Instance management\n\nEach wrapper needs to be fed with an instance before any other call.\n```java\n@Constructor\nvoid callConstructor(String aString);\n// or\n@SetInstance\nvoid setInstance(Object object);\n```\n\nThere are two way for setting an instance into a wrapper:\n  - Calling a ```Constructor``` annotated method that will create the instance using the constructor matching the exact same parameters.\n  - Calling a ```SetInstance``` annotated method that will use this object as the instance.\n\nIf you need to retrieve the instance, simply add a method annotated with ```GetInstance``` returning an object.\n```java\n@GetInstance\nObject getInstance();\n```\n\n### Calling methods\n\nIf not annotated, a method will be directly called on the instance using the exact same signature.\n\n### Playing with fields\n\n```SetField``` and ```GetField``` can be used to set and get fields from the instance. Both annotation needs the name of the field to work.\n```java\n@GetField(\"aField\")\nObject getField();\n\n@SetField(\"aField\")\nvoid setField(String aString);\n```\n\n## Download\n\nGradle:\n\n    compile 'com.genymobile:mirror:1.0.0'\n\nMirror requires at minimum Java 7.\n\n## Cool but wait... Warning!\n\nThis is super slow. Everything is done at runtime (internal reflexion, wrapping...) so don't use this for intensive work.\nThe main goal of this library is to give a tool to quickly play with reflexion and private APIs, classes... and software prototyping.\n\n## What next?\n\nThere is still some refactoring to do, plenty of bugs to fix, safety checks to implements. Maybe a v2 with code generation to get rid of the performance issue.\nAnyway, do not hesitate to file bugs or contribute.\n\n# License\n```\nCopyright 2016 Genymobile\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenymobile%2Fmirror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenymobile%2Fmirror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenymobile%2Fmirror/lists"}