{"id":27137705,"url":"https://github.com/oxidewavelength/java-betterreflection","last_synced_at":"2025-04-08T04:07:09.317Z","repository":{"id":54321209,"uuid":"340629202","full_name":"OxideWaveLength/Java-BetterReflection","owner":"OxideWaveLength","description":"Java library that caches reflections to make accessing them faster","archived":false,"fork":false,"pushed_at":"2024-10-30T04:52:35.000Z","size":92,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T23:00:06.198Z","etag":null,"topics":["cache","java","reflection","reflections"],"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/OxideWaveLength.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["OxideWaveLength"]}},"created_at":"2021-02-20T10:42:43.000Z","updated_at":"2024-10-30T04:49:19.000Z","dependencies_parsed_at":"2024-02-05T05:31:02.498Z","dependency_job_id":"c00148d0-341f-48af-b8a1-416315d2a5c8","html_url":"https://github.com/OxideWaveLength/Java-BetterReflection","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OxideWaveLength%2FJava-BetterReflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OxideWaveLength%2FJava-BetterReflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OxideWaveLength%2FJava-BetterReflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OxideWaveLength%2FJava-BetterReflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OxideWaveLength","download_url":"https://codeload.github.com/OxideWaveLength/Java-BetterReflection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773729,"owners_count":20993634,"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":["cache","java","reflection","reflections"],"created_at":"2025-04-08T04:07:08.864Z","updated_at":"2025-04-08T04:07:09.316Z","avatar_url":"https://github.com/OxideWaveLength.png","language":"Java","funding_links":["https://github.com/sponsors/OxideWaveLength"],"categories":[],"sub_categories":[],"readme":"# Java Better-Reflection\n\n## Faster Reflections [![Build Status](https://api.travis-ci.com/OxideWaveLength/Java-BetterReflection.svg?branch=main)](https://travis-ci.com/OxideWaveLength/Java-BetterReflection)\n\nBetterReflection is a Java library that caches reflection to achieve lower access time.\n\n\u003e Note: *BetterReflection is essentially caching reflections. There might be better alternatives for what you are trying\nto achieve.*\n\n#### This library has been created for Java 1.8, results may vary with different Java versions.\n\n## Installation\n\nEvery update has been packed into a Jar and released on GitHub. This library is also being hosted on Maven Central,\nstarting with version 1.0\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003etop.wavelength\u003c/groupId\u003e\n\t\u003cartifactId\u003eJava-BetterReflection\u003c/artifactId\u003e\n\t\u003cversion\u003eLATEST_VERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nNote: the package used to be me.wavelength.betterreflection up until version 1.0, where it's been renamed to\ntop.wavelength.betterreflection\n\n## Usage\n\nThere are no dependencies needed to use this library. Once you've downloaded it and set it up in your IDE you can start\nusing it.\n\nYou can temporarily cache a class by simply creating a new instance of BetterReflectionClass\n\n```Java\nBetterReflectionClass\u003cClassName\u003e className = new BetterReflectionClass\u003c?\u003e(ClassName.class); // You can also provide a string, containing the package and the name in this format: \"com.example.Class\".\n```\n\n## Something more efficient...\n\nTemporarily caching a class, though, might be worse than using normal reflections, because the BetterReflection class\ncaches everything as soon as instantiated.\nTo achieve actually better results than normal reflections you must actually permanently cache said classes.\n\n### Using the BetterReflection class\n\nThe BetterReflection class is a class that keeps in an arraylist the cached classes\n\n#### Create an instance of BetterReflection inside of your main class\n\n```Java\nprivate BetterReflection betterReflection;\n\npublic ExampleClass() {\n\tbetterReflection = new BetterReflection();\n}\n\npublic BetterReflection getBetterReflection() {\n\treturn betterReflection;\n}\n```\n\n#### Get the class from the BetterReflection instance you've just created\n\n```Java\npublic class MyClass {\n\t...\n\tBetterReflectionClass\u003cClassNeeded\u003e classNeeded = exampleClass.getBetterReflection().getBetterReflectionClass(ClassNeeded.class);\n\t...\n}\n```\n\n\u003e Note: *There are some cons to using this method. RAM usage could be somewhat high and once there are many classes\nlooping through a list containing all of them might get expensive*\n\n### Alternative way\n\n#### Creating a class containing public static final fields\n\n```Java\npublic class ListOfMyClasses {\n\t...\n\tpublic static final BetterReflectionClass ClassNeeded = new BetterReflectionClass(ClassNeeded.class);\n\t...\n}\n```\n\n#### Accessing it from anywhere\n\n```Java\nimport static ListOfMyClasses.*;\n\npublic class MyClass {\n\t...\n\tClassNeeded.getField(\"\"); // \u003c-- This is directly referencing the field \"ClassNeeded\" from the class \"ListOfMyClasses\".\n\t...\n}\n```\n\n---\n\n## Results of the Tests\n\n### [10000000 loops](https://gist.github.com/OxideWaveLength/2de71824b31b7261d570af127fb1eee3)\n\n### [100000000 loops](https://gist.github.com/OxideWaveLength/3c71b0ce1d17e1c3bc3d8928dda2cb09)\n\n---\n\n## Contributing\n\nThere are several ways you can contribute.\n\n### Tests\n\nThere are never enough tests! You can create a new test anytime you want to, but your test must meet specific\nrequirements.\n\n- Your test must extend the Test class\n- Your test must be added to the correct array inside of the Tester class\n- Your test must use the Timer class to return the time passed\n- Your test must tackle somewhat real scenarios\n- Your test must have a good English description\n\n### Proper Benchmarks\n\nIf you have some spare time and are generous enough, feel free to implement some proper benchmark and create a pull\nrequest. OpenJDK JHM is suggested, but if you're into some other benchmarking libraries feel free to use them instead\n\n### BetterReflection itself\n\nIf you spot issues in the code, think there are better ways to achieve something or think that there are methods that\nshould be added, feel free to add them.\n\n### Issues\n\nOf course, contributing is not limited to code, you can also open issues to report bugs, performance issues or request\nfeatures.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidewavelength%2Fjava-betterreflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxidewavelength%2Fjava-betterreflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidewavelength%2Fjava-betterreflection/lists"}