Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrjameshamilton/jep457-hello-world-translator
A simple demonstration of transforming a class with the Java Class File API
https://github.com/mrjameshamilton/jep457-hello-world-translator
bytecode jep457 transform
Last synced: about 2 months ago
JSON representation
A simple demonstration of transforming a class with the Java Class File API
- Host: GitHub
- URL: https://github.com/mrjameshamilton/jep457-hello-world-translator
- Owner: mrjameshamilton
- License: mit
- Created: 2024-03-16T15:36:31.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-03-20T19:26:20.000Z (9 months ago)
- Last Synced: 2024-03-20T20:41:51.665Z (9 months ago)
- Topics: bytecode, jep457, transform
- Language: Java
- Homepage: https://jameshamilton.eu/programming/jep-457-hello-world-translator
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JEP457 Hello World Translator
[JEP 457 Class-File API](https://openjdk.org/jeps/457) is a preview API to provide a standard API for parsing,
generating, and transforming Java class files.The example here shows how easy it is to use to read and modify an existing class file.
The example modifies a single `ldc` instruction to change the constant printed from "Hello World" to
another string provided as an argument.For examples of generating a class from scratch see [JEP457 Hello World](https://github.com/mrjameshamilton/jep457-hello-world)
and [JEP457 Brainf*ck Compiler](https://github.com/mrjameshamilton/bf-jep457).# Building
You'll need JDK 22.
The easiest way to install this on Linux is with [SDK man](https://sdkman.io/):```shell
sdk install java 22-open
```If you have Java 22, you can then execute the `run.sh` script which will
compile and execute `HelloWorld.java` and `HelloTranslator.java`.
`HelloTranslator` will transform `HelloWorld.class`, changing
the constant "Hello World" into the script argument,
and then executing it.```shell
$ ./run.sh "Hallo Wereld"
```# Similar projects
There are many similar projects for parsing,
generating, and transforming Java class files, including:* [ASM](https://asm.ow2.io/)
* [ProGuardCORE](https://github.com/Guardsquare/proguard-core)
* [ByteBuddy](https://bytebuddy.net/#/)