{"id":18564478,"url":"https://github.com/guardsquare/proguard-core","last_synced_at":"2026-02-03T10:16:46.138Z","repository":{"id":38194216,"uuid":"263266232","full_name":"Guardsquare/proguard-core","owner":"Guardsquare","description":"Library to read, write, analyze, and process java bytecode","archived":false,"fork":false,"pushed_at":"2024-05-22T07:10:08.000Z","size":8907,"stargazers_count":270,"open_issues_count":10,"forks_count":60,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-05-22T16:59:32.948Z","etag":null,"topics":["build-tool","bytecode","code-analysis","compiler","java","jvm-bytecode","kotlin","parser"],"latest_commit_sha":null,"homepage":null,"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/Guardsquare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2020-05-12T07:35:44.000Z","updated_at":"2024-05-27T11:53:44.362Z","dependencies_parsed_at":"2023-10-03T14:54:37.026Z","dependency_job_id":"c4dffe10-ed42-4da5-a132-e458f0abad79","html_url":"https://github.com/Guardsquare/proguard-core","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guardsquare%2Fproguard-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guardsquare%2Fproguard-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guardsquare%2Fproguard-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guardsquare%2Fproguard-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Guardsquare","download_url":"https://codeload.github.com/Guardsquare/proguard-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386265,"owners_count":20930619,"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":["build-tool","bytecode","code-analysis","compiler","java","jvm-bytecode","kotlin","parser"],"created_at":"2024-11-06T22:15:21.184Z","updated_at":"2026-02-03T10:16:46.124Z","avatar_url":"https://github.com/Guardsquare.png","language":"Java","readme":"\u003cp align=\"center\"\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003ca href=\"https://www.guardsquare.com/proguard\"\u003e\n    \u003cimg\n      src=\"https://www.guardsquare.com/hubfs/Logos/ProGuard_core_logo.png\"\n      alt=\"ProGuardCORE\" width=\"400\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch4 align=\"center\"\u003eA library to parse, modify and analyze Java class files.\u003c/h4\u003e\n\n\u003c!-- Badges --\u003e\n\u003cp align=\"center\"\u003e\n  \u003c!-- CI --\u003e\n  \u003ca href=\"https://github.com/Guardsquare/proguard-core/actions?query=workflow%3A%22Continuous+Integration%22\"\u003e\n    \u003cimg src=\"https://github.com/Guardsquare/proguard-core/workflows/Continuous%20Integration/badge.svg\"\u003e\n  \u003c/a\u003e\n  \n  \u003c!-- Github version --\u003e\n  \u003c!--\n  \u003ca href=\"releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/guardsquare/proguard-core\"\u003e\n  \u003c/a\u003e\n  --\u003e\n\n  \u003c!-- Maven --\u003e\n  \u003ca href=\"https://search.maven.org/search?q=g:com.guardsquare\"\u003e\n    \u003cimg src=\"https://img.shields.io/maven-central/v/com.guardsquare/proguard-core\"\u003e\n  \u003c/a\u003e\n\n  \u003c!-- License --\u003e\n  \u003ca href=\"LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/guardsquare/proguard-core\"\u003e\n  \u003c/a\u003e\n\n  \u003c!-- Twitter --\u003e\n  \u003ca href=\"https://twitter.com/Guardsquare\"\u003e\n    \u003cimg src=\"https://img.shields.io/twitter/follow/guardsquare?style=social\"\u003e\n  \u003c/a\u003e\n\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#-quick-start\"\u003e\u003cb\u003eQuick Start\u003c/b\u003e\u003c/a\u003e •\n  \u003ca href=\"#-features\"\u003e\u003cb\u003eFeatures\u003c/b\u003e\u003c/a\u003e •\n  \u003ca href=\"#-projects\"\u003e\u003cb\u003eProjects\u003c/b\u003e\u003c/a\u003e •\n  \u003ca href=\"#-contributing\"\u003e\u003cb\u003eContributing\u003c/b\u003e\u003c/a\u003e •\n  \u003ca href=\"#-license\"\u003e\u003cb\u003eLicense\u003c/b\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\nProGuardCORE is a free library to read, analyze, modify, and write Java class\nfiles. It is the core of the well-known shrinker, optimizer, and obfuscator\n[ProGuard](https://www.guardsquare.com/proguard), the [ProGuard\nAssembler and Disassembler](https://github.com/guardsquare/proguard-assembler),\nand the [Kotlin Metadata\nPrinter](https://github.com/Guardsquare/kotlin-metadata-printer).\n\nTypical applications:\n\n- Read and write class files, including any Kotlin metadata.\n- Search for instruction patterns.\n- Create byte code instrumentation tools.\n- Analyze code with abstract evaluation.\n- Build static code analysis tools.\n- Optimize and obfuscate, like ProGuard itself.\n- ... and so much more!\n\nProGuard core comes with a short [manual](https://guardsquare.github.io/proguard-core/) and pretty nice\n[API documentation](https://guardsquare.github.io/proguard-core/api/).\n\n## ❓ Getting Help\nPlease use \u003ca href=\"https://github.com/guardsquare/proguard-core/issues\"\u003e**the issue tracker**\u003c/a\u003e to report actual **bugs 🐛, crashes**, etc.\n\u003cbr /\u003e\n\u003cbr /\u003e\n## 🚀 Quick Start\n\n**ProGuardCORE** requires Java 1.8 or higher. You can download it as a pre-built\nartifact from:\n\n- [Maven Central](https://search.maven.org/search?q=g:com.guardsquare).\n\nJust add it to your project dependencies, e.g. Gradle:\n\n```gradle\ndependencies {\n    compile 'com.guardsquare:proguard-core:9.3.0'\n}\n```\nor Maven:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.guardsquare\u003c/groupId\u003e\n    \u003cartifactId\u003eproguard-core\u003c/artifactId\u003e\n    \u003cversion\u003e9.3.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Building Locally\n\nYou can of course also clone and build this repository manually. Using Gradle,\njust execute the assemble task in the project root:\n\n```shell\ngradle clean assemble\n```\n\n## ✨ Features\n\nThe repository contains some sample code in the [examples](examples) directory.\nTogether with the complete set of manual pages they extensively cover the usage\nof the library and its features in more detail:\n\n\u003ch3 align=\"center\"\u003e\n👉👉👉\u003ca href=\"https://guardsquare.github.io/proguard-core/\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; Manual Pages \u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/a\u003e👈 👈 👈\n\u003c/h3\u003e\n\nBelow we'll highlight just a few of them in order to better showcase the\ncapabilities.\n\n- [Creating classes programmatically](#creating-classes-programmatically-manual)\n- [Replacing instruction sequences](#replacing-instruction-sequences-manual)\n- [Kotlin metadata](#kotlin-metadata-manual)\n- [Code analysis with abstract evaluation](#abstract-evaluation-manual)\n\n### Creating classes programmatically ([manual](https://guardsquare.github.io/proguard-core/creating.html))\n\nUsing the fluent API, it becomes very easy to programmatically create\nclasses from scratch. The data structures directly correspond to the bytecode\nspecifications and ProGuardCORE can even preverify the code for you.\n\nYou can create classes, with fields, methods and sequences of\ninstructions. The following concise code creates the iconic `HelloWorld` class:\n\n```java\nProgramClass programClass =\n    new ClassBuilder(\n        VersionConstants.CLASS_VERSION_1_8,\n        AccessConstants.PUBLIC,\n        \"HelloWorld\",\n        ClassConstants.NAME_JAVA_LANG_OBJECT)\n        .addMethod(\n            AccessConstants.PUBLIC | AccessConstants.STATIC,\n            \"main\",\n            \"([Ljava/lang/String;)V\",\n            50,\n            code -\u003e code\n                .getstatic(\"java/lang/System\", \"out\", \"Ljava/io/PrintStream;\")\n                .ldc(\"Hello, world!\")\n                .invokevirtual(\"java/io/PrintStream\", \"println\", \"(Ljava/lang/String;)V\")\n                .return_())\n        .getProgramClass();\n```\n\n### Replacing instruction sequences ([manual](https://guardsquare.github.io/proguard-core/patternmatching.html))\n\nProGuardCORE has an excellent instruction pattern matching engine, which\ncan also replace matched bytecode instruction sequences.\n\nFor example, the snippet below defines an instruction sequence, including a\nwildcard, and replaces it with an equivalent instruction sequence, in all code\nattributes of all methods of all classes in a class pool.\n\n```java\nInstruction[][] replacements =\n{\n    ____.putstatic(X)\n        .getstatic(X).__(),\n    ____.dup()\n        .putstatic(X).__()\n};\n...\nprogramClassPool.classesAccept(\n    new AllMethodVisitor(\n    new AllAttributeVisitor(\n    new PeepholeEditor(branchTargetFinder, codeAttributeEditor,\n    new InstructionSequenceReplacer(constants, replacements, branchTargetFinder,\n                                    codeAttributeEditor)))));\n```\n\n### Kotlin Metadata ([manual](https://guardsquare.github.io/proguard-core/kotlin.html))\n\nThe library makes it easy to read, write and modify the Kotlin metadata that is\nattached to Java classes. The following example prints all the names of Kotlin\nfunctions in the metadata attached to the Java class `Foo`:\n\n```java\nprogramClassPool.classesAccept(\n   new ClassNameFilter(\"Foo\",\n   new ReferencedKotlinMetadataVisitor(\n   new AllFunctionsVisitor(\n       (clazz, container, function) -\u003e System.out.println(function.name)))));\n```\n\n### Abstract Evaluation ([manual](https://guardsquare.github.io/proguard-core/analyzing.html))\n\nProGuardCORE provides a number of ways to analyze code. One of the most\npowerful techniques is abstract evaluation (closely related to symbolic\nexecution). It **executes the code**, but instead of computing with concrete values\nit can compute with **abstract values**.\n\nConsider the following `getAnswer` method:\n\n```java\nprivate static int getAnswer(int a, int b)\n{\n    return 2 * a + b;\n}\n```\n\nThe table represents the bytecode instructions at their\noffsets, and the resulting evolving stacks and local variables.  Each value\nslot has a numerical value and its origin (an instruction offset), presented as\n`origin:value`.\n\n| Instruction      | Stack             | v0    | v1    |\n|------------------|-------------------|-------|-------|\n| [0] iconst\\_2    | [0:2]             | P0:i0 | P1:i1 |\n| [1] iload\\_0 v0  | [0:2][1:i0]       | P0:i0 | P1:i1 |\n| [2] imul         | [2:(2*i0)]        | P0:i0 | P1:i1 |\n| [3] iload\\_1 v1  | [2:(2*i0)] [3:i1] | P0:i0 | P1:i1 |\n| [4] iadd         | [4:((2*i0)+i1)]   | P0:i0 | P1:i1 |\n| [5] ireturn      |                   | P0:i0 | P1:i1 |\n\nAt every point ProGuardCORE provides access to the symbolic expressions, or\nif possible and requested, the concrete results.\n\n## ⚙️ Projects\n\nSome of the projects using ProGuardCORE:\n\n- [ProGuard](https://github.com/Guardsquare/proguard)\n- [Kotlin Metadata Printer](https://github.com/Guardsquare/kotlin-metadata-printer)\n- [ProGuard Assembler/Disassembler](https://github.com/Guardsquare/proguard-assembler)\n- [Log4Shell Detector](https://github.com/Guardsquare/log4shell-detector)\n- [klox compiler](https://github.com/mrjameshamilton/klox)\n\nIf you've created your own, make sure to reach out through `github _ at _\nguardsquare.com` and we'll add it to the list!\n\n## 🤝 Contributing\n\nContributions, issues and feature requests are welcome.\nFeel free to check the [issues](issues) page and the [contributing\nguide](blob/master/CONTRIBUTING.md) if you would like to contribute.\n\n## 📝 License\n\nCopyright (c) 2002-2022 [Guardsquare NV](https://www.guardsquare.com/).\nProGuardCORE is released under the [Apache 2 license](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguardsquare%2Fproguard-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguardsquare%2Fproguard-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguardsquare%2Fproguard-core/lists"}