FJsc: (Extended) Featherweight Java smart compiler
FJsc
is a prototype implementation for smartest
(re)compilation of a superset of
Featherweight Java
based on the type system defined in
AnconaZucca04
and the technique developed in
AnconaLagorio04.
The first time a source file is compiled,
FJsc
generates
a
.tc
file containing a minimal
set of type constraints needed for generating the corresponding .
class
file.
By inspecting
.tc
files,
FJsc
is able to
trigger recompilation of only those source files whose
recompilation
would lead to a different
.class
file (note that this
might happen for unmodified source files, since
the generated bytecode also depends on the other classes available in
the context), thus avoiding useless recompilations.
Requirements
JDK 1.4 or higher is needed.
Script for generating
.class
file via JDK
javac
is provided only for UNIX/LINUX.
Download
FJsc.tgz
Installation
The following instructions are valid only for UNIX/LINUX users:
- Move
FJsc.tgz
where you prefer and uncompress it (tar
xzvf FJsc.tgz
)
- Edit files
FJsc/fjsc
and FJsc/rebuild
in order to update the definition of INST_DIR
variable
with the correct path to the directory FJsc
- If you like, update
PATH
for being able to run the
scripts without specifying the path
- In case your JDK version is less than 1.4 and you do not want to
upgrade it, run script
rebuild
If you do not have UNIX/LINUX you will not be able to run the scripts,
however if your JDK
version is >= 1.4 you will still be able to run the application (see
below)
Usage
- Move to the directory where the Java files you want to compile
reside
- For UNIX/LINUX users: run
fjsc
- For other users: run
java -classpath $INST_DIR/FJsc/jar
-jar $INST_DIR/FJsc/jar/FJsc.jar
where $INST_DIR
is replaced with the correct path to the directory FJsc
- Verbose option (
-v
at the end of the command): shows
all type constraints for all classes whose .class
and .tc
files exist and are up-to-date
NOTE: the script
fjsc
allows generation of the
.class
files via the JDK compiler,
since the application only performs
typechecking and generates the corresponding type constraints.
If you cannot run
fjsc
,
you will need to invoke the JDK compiler "by hand"
since recompilation of a file is
triggered whenever the corresponding
.class
file is
missing
Conventions on files
- Each file must contain just one class declaration
- The name of the file must coincide with the class name declared
in
it (except for
.java
extension)
- All files must reside in the same directory
Language specification
The language is a proper super-set of Featherweight Java. Please
refer to the
papers by Igarashi, Pierce and
Wadler for the specification of Featherweight Java.
Here below are listed all implemented extensions:
- Fields can be hidden by subclasses.
- Constructors can be overloaded. The syntax for constructor
bodies is a possibly empty sequence of assignments of the form:
this.
id=
exp;
- Each constructor body begins with the implicit call
super()
,
however the super
explicit notation for constructors is
not supported
- The rules for default constructors are the same as in Java
- Methods can be overloaded
- Primitive type
int
and integer literals are
supported
References
Davide Ancona and Elena Zucca. Principal
typings for Java-like Languages. In POPL 2004 - The 31st ACM
SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages
306-317, ACM press, 2004.
Davide Ancona and Giovanni Lagorio.
Stronger
typings for separate compilation of Java-like languages.
Journal of Object Technology, 3(6), 2004.
Atsushi Igarashi, Benjamin Pierce, and Philip Wadler.
Featherweight Java: A minimal core calculus for Java and GJ. In
ACM
SIGPLAN Conference on Object Oriented Programming: Systems, Languages,
and Applications (OOPSLA), October 1999. Full version in ACM
Transactions on Programming Languages and Systems (TOPLAS), 23(3), May
2001.