aspa: a patching tool for JVM class files
Description
aspa derives and applies patches between Java classes compiled to the Java Virtual Machine (JVM) bytecode format, resorting to an abstract syntax tree representation of JVM bytecode.
Fine-grained patches for Java software upgrades [PDF],
Eduardo R.B. Marques, HotSWUp'13, 2013.
Abstract
We present a novel methodology for deriving fine-grained patches of Java software. We consider an abstract-syntax tree (AST) representation of Java classes compiled to the Java Virtual Machine (JVM) format, and a difference analysis over the AST representation to derive patches. The AST representation defines an appropriate abstraction level for analyzing differences, yielding compact patches that correlate modularly to actual source code changes. The approach contrasts to other common, coarse-grained approaches, like plain binary differences, which may easily lead to disproportionately large patches. We present the main traits of the methodology, a prototype tool called aspa that implements it, and a case-study analysis on the use of aspa to derive patches for the Java 2 SE API. The case-study results illustrates that aspa patches have a significantly smaller size than patches derived by binary differencing tools.
Results
Beyond the early results reported in the paper draft (see above),
check out a brief report of some newer results
for an ongoing analysis
of aspa patches over the core Java runtime library
in Oracle's Java JRE. The plot below summarizes part of these results,
comparing the size of patch files generated by
aspa
with three distinct binary-difference patch utilities.

Download
To try out aspa, download the ZIP archive available here (version 0.2.1).
The archive contains aspa in Java source (source.zip) and compiled forms (aspa.jar), plus some utility scripts described below.
Usage
Two utility scripts are provided in the distribution to derive and apply JVM-level patches: jvmdiff.sh and jvmpatch.sh.
Two other scripts are included to derive and apply entire JAR archive patches: jardiff.sh and jarpatch.sh. In the current version, aspa only handles the JVM class files inside a JAR archive, ignoring all other content.
:: jvmdiff.sh ::
Execute
jvmdiff.sh path_v1/SomeClass.class path_v2/SomeClass.class patch.aspa
to derive a patch file patch.aspa reflecting the differences from
path_v1/SomeClass.class to path_v2/SomeClass.class.
The patch file will not be generated if both classes are found
to be equivalent.
:: jvmpatch.sh ::
Execute
jvmpatch.sh path_v1/SomeClass.class patch.aspa path_v2/SomeClass.class
to apply patch file patch.aspa over
path_v1/SomeClass.class, yielding class file path_v2/SomeClass.class.
:: jardiff.sh ::
Execute
jardiff.sh v1.jar v2.jar patch.aspa
to derive a patch file patch.aspa reflecting the differences from
v1.jar to v2.jar.
The patch file will not be generated if the two JAR archive files
contain exactly the same classes and no differences are found
for each class.
:: jarpatch.sh ::
Execute
jarpatch.sh v1.jar patch.aspa v2.jar
to apply patch file patch.aspa over JAR archive
v1.jar, yielding JAR archive v2.jar.
License
The aspa source code is available under the terms of the GNU GPL license (version 3).
Contact
For any issues on aspa please contact Eduardo R. B. Marques (edrdo __at__ dcc.fc.up.pt).
Comments, bug reports, or other feedback are highly appreciated. Thank you.
(C) Eduardo R. B. Marques, 2013