Introducing: the Java Access Modifier Inference Tool
JAMIT, the Java Access Modifier Inference Tool can be used
on Java class-files to infer tighter access modifiers.
Tight access modifiers are commonly perceived as good
programming practice. Nevertheless, refactoring of code
or just ignorance at the time where the code is written
often lead to modifiers that are less restrictive than
they could be.
More restrictive modifiers help to increase encapsulation,
one of the major goals in object oriented program design.
They can also serve as a criteria for good software
engineering. In some cases, more restrictive modifiers
can even help the compiler to produce better (= faster)
code.
The most restrictive modifier supported by Jamit is
dead. In other words, Jamit can be used to
eliminate dead code from Java applications and libraries.
In this sense it is similar to JAX.
Eliminating dead code with Jamit is easy. You specify
the main method, a file that defines native and reflective
behavior, the input directory with the original classes
and an output directory where the optimized classes are to
be written to. The resulting code can often be significantly
smaller, especially if the code was using small parts of
a larger framework.
News
Jamit 5.0 released
This version supports Java 5.0 (hence the jump in the version
number). In particular, all Java 5.0 attributes are recognized,
and annotation classes are marked as live as necessary. Also,
the bytecode engine understands the changes to the instruction
set (LDC) that come with Java 5.0.
The new Jamit release uses the integrated XTC
installer based on izpack.
Jamit 3.0 released
Jamit 3.0 now allows the specification of native and reflective
behavior. Previously applying Jamit to code that was only
reachable via reflection or native methods would not work. With
the native specification it is possible to handle reflection and
native code correctly. A sample file that contains native
specifications for the
runabout, xtc and
junit is included in
the distribution (src/org/grothoff/xtc/tools/jamit/xtc.jamit).
Various bugs have been fixed, including preservation of
line number tables and local variable tables (if you want to go
for minimal size, remove those by adding the option -minimal),
preservation of access modifiers in subclasses of untouchable
library classes (i.e. toString() must always be public).
protected was selected too aggressively sometimes. An
unresolved bug with final classes was worked around by
not making any classes final for now.
Jamit 3.0 is now part of the xtc
branch of OVM, which dramatically reduces the size of the download and
simplifies compilation.
Jamit 2.0 released
The new version features dead code elimination (for statically
unreachable classes and methods), dumping of class files (with the
tighter access modifiers) and support for libraries (libraries are
immutable code, its access modifiers and method definitions may not be
changed).
Download latest stable version
The latest code of Jamit can be found in the XTC
subversion repository.
Contact
Jamit is developed by
Christian Grothoff using
XTC.