This Maven plugin may optimize your Bytecode after compilation,
to make it work faster.
Just add this to your pom.xml file (you must have Docker installed too):
<project>
[..]
<build>
<plugins>
<plugin>
<groupId>org.eolang</groupId>
<artifactId>hone-maven-plugin</artifactId>
<version>0.20.2</version>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>optimize</goal>
<goal>rmi</goal>
</goals>
<configuration>
<rules>streams/*</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>The plugin will do exactly the following:
- Take Bytecode
.classfiles from thetarget/classes/directory and copy all of them to thetarget/classes-before-hone/directory (as a backup). - Using jeo-maven-plugin,
transform
.classfiles to.xmirformat, which is EO in XML, and place them into thetarget/hone/jeo-disassemble/directory. - Using phino,
convert
.xmirfiles to.phifiles with π-calculus expressions, and place them into thetarget/hone/phi/directory. - Using phino,
apply a number of optimizations to π-calculus expressions in the
.phifiles and place new.phifiles into thetarget/hone/phi-optimized/directory. - Using phino,
convert
.phifiles back to.xmirfiles and place them into thetarget/hone/unphi/directory. - Using jeo-maven-plugin,
transform
.xmirfiles back to Bytecode and place.classfiles into thetarget/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.
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:
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 honeSee how it works in this example.
Here is the result of the latest processing of a large Java class from JNA:
Input: com/sun/jna/Pointer.class
Size of .class: 22Kb (22Kb bytes)
Size of .xmir after disassemble: 2Mb (2Mb bytes, 55205 lines)
Size of .phi: 837Kb (837Kb bytes, 26376 lines)
Size of .xmir after unphi: 2Mb (2Mb bytes, 55190 lines)
Optimization time: 9s (9189 ms)
jeo-maven-plugin:disassemble 3.149 51.21%
exec-maven-plugin:exec 2.289 37.23%
jeo-maven-plugin:assemble 0.711 11.56%
The results were calculated in this GHA job on 2025-09-18 at 15:08, on Linux with 4 CPUs.
Fork repository, make changes, then send us a pull request.
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:
mvn clean install -PquliceYou will need Maven 3.3+, Java 11+, and Docker installed.
The versions of EO and
JEO,
that we use, are defined in the pom.xml file.