https://github.com/objectionary/hone-maven-plugin
Maven plugin that applies a number of optimizations to your Bytecode, using EOLANG and 𝜑-calculus, trying to make it work faster
https://github.com/objectionary/hone-maven-plugin
bytecode-manipulation code-optimization eolang java maven-plugin
Last synced: 16 days ago
JSON representation
Maven plugin that applies a number of optimizations to your Bytecode, using EOLANG and 𝜑-calculus, trying to make it work faster
- Host: GitHub
- URL: https://github.com/objectionary/hone-maven-plugin
- Owner: objectionary
- License: mit
- Created: 2024-08-09T13:20:46.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-05T08:18:09.000Z (over 1 year ago)
- Last Synced: 2024-11-05T08:27:33.711Z (over 1 year ago)
- Topics: bytecode-manipulation, code-optimization, eolang, java, maven-plugin
- Language: Java
- Homepage: https://www.objectionary.com/hone-maven-plugin/
- Size: 1.05 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Bytecode Optimizing Maven Plugin
[](https://github.com/objectionary/hone-maven-plugin/actions/workflows/mvn.yml)
[](https://maven-badges.herokuapp.com/maven-central/org.eolang/hone-maven-plugin)
[](https://www.javadoc.io/doc/org.eolang/hone-maven-plugin)
[](LICENSE.txt)
[](https://hitsofcode.com/github/objectionary/hone-maven-plugin/view?branch=master&label=Hits-of-Code)

[](https://codecov.io/gh/objectionary/hone-maven-plugin)
This [Maven] plugin _may_ optimize your [Bytecode][bytecode] after compilation,
to make it work faster.
Just add this to your `pom.xml` file (you must have [Docker] installed too):
```xml
[..]
org.eolang
hone-maven-plugin
0.21.0
build
optimize
rmi
streams/*
```
The plugin will do exactly the following:
1. Take Bytecode `.class` files from the `target/classes/` directory and copy
all of them to the `target/classes-before-hone/` directory (as a backup).
1. Using [jeo-maven-plugin],
transform `.class` files to
`.xmir` [format][XMIR],
which is [EO] in XML, and place them into
the `target/hone/jeo-disassemble/` directory.
1. Using [phino],
convert `.xmir` files to `.phi` files
with [𝜑-calculus] expressions,
and place them into the `target/hone/phi/` directory.
1. Using [phino],
apply a number of optimizations to 𝜑-calculus expressions in the `.phi` files
and place new `.phi` files into
the `target/hone/phi-optimized/` directory.
1. Using [phino],
convert `.phi` files back to `.xmir` files and
place them into the `target/hone/unphi/` directory.
1. Using [jeo-maven-plugin],
transform `.xmir` files back to Bytecode and place `.class` files into
the `target/classes/` directory.
The effect of the plugin should be performance-positive (your code should
work faster) along with no functionality degradation (your code should work
exactly the same as it worked before optimizations). If any of these
is not true, [submit a ticket], we will try to fix.
To make it work faster, you may install [phino] on your machine beforehand.
## How to Use in Gradle
You can use this plugin with [Gradle] too, but it requires
some additional steps. You need to add the following to your `build.gradle` file:
```groovy
task hone(type: Exec, dependsOn: compileJava) {
commandLine 'mvn',
"-Dhone.target=${buildDir}",
"-Dhone.classes=${buildDir.toPath().relativize(sourceSets.main.output.classesDirs.singleFile.toPath())}",
'-Dhone.rules=streams/*',
'org.eolang:hone-maven-plugin:0.0.0:build',
'org.eolang:hone-maven-plugin:0.0.0:optimize'
}
compileJava.finalizedBy hone
classes.dependsOn hone
```
See how it works in [this example](src/test/gradle).
## Benchmark
Here is the result of the latest processing of a large Java class
from [JNA](https://github.com/java-native-access/jna):
```text
```
The results were calculated in [this GHA job][benchmark-gha]
on 2025-12-17 at 13:53,
on Linux with 4 CPUs.
## How to Contribute
Fork repository, make changes, then send us a [pull request][guidelines].
We will review your changes and apply them to the `master` branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
```bash
mvn clean install -Pqulice
```
You will need [Maven 3.3+](https://maven.apache.org), Java 11+,
and [Docker](https://docs.docker.com/engine/install/) installed.
The versions of [EO] and
[JEO](https://github.com/objectionary/jeo-maven-plugin),
that we use, are defined in the `pom.xml` file.
[EO]: https://github.com/objectionary/eo
[benchmark-gha]: https://github.com/objectionary/hone-maven-plugin/actions/runs/20305168836
[bytecode]: https://en.wikipedia.org/wiki/Java_bytecode
[guidelines]: https://www.yegor256.com/2014/04/15/github-guidelines.html
[Maven]: https://maven.apache.org/
[Docker]: https://docs.docker.com/engine/install/
[submit a ticket]: https://github.com/objectionary/hone-maven-plugin/issues
[Gradle]: https://gradle.org/
[phino]: https://github.com/objectionary/phino
[jeo-maven-plugin]: https://github.com/objectionary/jeo-maven-plugin
[𝜑-calculus]: https://arxiv.org/abs/2111.13384
[XMIR]: https://news.eolang.org/2022-11-25-xmir-guide.html