{"id":13640300,"url":"https://github.com/java-decompiler/jd-core","last_synced_at":"2025-04-04T12:08:08.433Z","repository":{"id":39580064,"uuid":"186486108","full_name":"java-decompiler/jd-core","owner":"java-decompiler","description":"JD-Core is a JAVA decompiler written in JAVA.","archived":false,"fork":false,"pushed_at":"2024-04-19T08:02:04.000Z","size":2403,"stargazers_count":552,"open_issues_count":57,"forks_count":140,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-28T11:08:54.641Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/java-decompiler.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":"2019-05-13T19:54:30.000Z","updated_at":"2025-03-15T20:15:07.000Z","dependencies_parsed_at":"2024-11-09T10:32:25.908Z","dependency_job_id":"fc111e5d-d91e-4aea-9b4c-a97a33a257bd","html_url":"https://github.com/java-decompiler/jd-core","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-decompiler%2Fjd-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-decompiler%2Fjd-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-decompiler%2Fjd-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-decompiler%2Fjd-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/java-decompiler","download_url":"https://codeload.github.com/java-decompiler/jd-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174419,"owners_count":20896078,"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":[],"created_at":"2024-08-02T01:01:09.779Z","updated_at":"2025-04-04T12:08:08.415Z","avatar_url":"https://github.com/java-decompiler.png","language":"Java","funding_links":[],"categories":["Projects","Java"],"sub_categories":["Decompilation"],"readme":"# JD-Core\n\nJD-Core is a JAVA decompiler written in JAVA.\n\n- Java Decompiler project home page:\n[http://java-decompiler.github.io](https://java-decompiler.github.io)\n- JD-Core source code:\n[https://github.com/java-decompiler/jd-core](https://github.com/java-decompiler/jd-core)\n- JCenter Maven repository:\n[https://jcenter.bintray.com/](https://bintray.com/java-decompiler/maven/org.jd%3Ajd-core/_latestVersion)\n\n## Description\nJD-Core is a standalone JAVA library containing the JAVA decompiler of\n\"Java Decompiler project\". It support Java 1.1.8 to Java 12.0,\nincluding Lambda expressions, method references and default methods.\nJD-Core is the engine of JD-GUI.\n\n## How to build JD-Core ?\n```\n\u003e git clone https://github.com/java-decompiler/jd-core.git\n\u003e cd jd-core\n\u003e ./gradlew build\n```\ngenerate _\"build/libs/jd-core-x.y.z.jar\"_\n\n## How to use JD-Core ?\n\n1. Implement the\n_[org.jd.core.loader.Loader](https://github.com/java-decompiler/jd-core/blob/master/src/main/java/org/jd/core/v1/api/loader/Loader.java)_\ninterface,\n2. Implement the\n_[org.jd.core.printer.Printer](https://github.com/java-decompiler/jd-core/blob/master/src/main/java/org/jd/core/v1/api/printer/Printer.java)_\ninterface,\n3. And call the method _\"decompile(loader, printer, internalTypeName);\"_\n\n## Example\n\n1. Implement the _Loader_ interface:\n```java\nLoader loader = new Loader() {\n    @Override\n    public byte[] load(String internalName) throws LoaderException {\n        InputStream is = this.getClass().getResourceAsStream(\"/\" + internalName + \".class\");\n\n        if (is == null) {\n            return null;\n        } else {\n            try (InputStream in=is; ByteArrayOutputStream out=new ByteArrayOutputStream()) {\n                byte[] buffer = new byte[1024];\n                int read = in.read(buffer);\n\n                while (read \u003e 0) {\n                    out.write(buffer, 0, read);\n                    read = in.read(buffer);\n                }\n\n                return out.toByteArray();\n            } catch (IOException e) {\n                throw new LoaderException(e);\n            }\n        }\n    }\n\n    @Override\n    public boolean canLoad(String internalName) {\n        return this.getClass().getResource(\"/\" + internalName + \".class\") != null;\n    }\n};\n```\n\n2. Implement the _Printer_ interface\n```java\nPrinter printer = new Printer() {\n    protected static final String TAB = \"  \";\n    protected static final String NEWLINE = \"\\n\";\n\n    protected int indentationCount = 0;\n    protected StringBuilder sb = new StringBuilder();\n\n    @Override public String toString() { return sb.toString(); }\n\n    @Override public void start(int maxLineNumber, int majorVersion, int minorVersion) {}\n    @Override public void end() {}\n\n    @Override public void printText(String text) { sb.append(text); }\n    @Override public void printNumericConstant(String constant) { sb.append(constant); }\n    @Override public void printStringConstant(String constant, String ownerInternalName) { sb.append(constant); }\n    @Override public void printKeyword(String keyword) { sb.append(keyword); }\n    @Override public void printDeclaration(int type, String internalTypeName, String name, String descriptor) { sb.append(name); }\n    @Override public void printReference(int type, String internalTypeName, String name, String descriptor, String ownerInternalName) { sb.append(name); }\n\n    @Override public void indent() { this.indentationCount++; }\n    @Override public void unindent() { this.indentationCount--; }\n\n    @Override public void startLine(int lineNumber) { for (int i=0; i\u003cindentationCount; i++) sb.append(TAB); }\n    @Override public void endLine() { sb.append(NEWLINE); }\n    @Override public void extraLine(int count) { while (count-- \u003e 0) sb.append(NEWLINE); }\n\n    @Override public void startMarker(int type) {}\n    @Override public void endMarker(int type) {}\n};\n```\n\n3. And call the method _\"decompile(loader, printer, internalTypeName);\"_\n```java\nClassFileToJavaSourceDecompiler decompiler = new ClassFileToJavaSourceDecompiler();\n\ndecompiler.decompile(loader, printer, \"path/to/YourClass\");\n\nString source = printer.toString();\n```\n\n## License\nReleased under the [GNU GPL v3](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjava-decompiler%2Fjd-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjava-decompiler%2Fjd-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjava-decompiler%2Fjd-core/lists"}