Java on Parrot

Ben Batha

Short description: The project is based on providing a compiler for Java mostly or entirely written in Java. Previously written compiler projects (OpenJDK javac or GCJ) will likely be used as a starting point for development. Reusing code is a priority for completion of the project, so focus will be on replacing the code generation of a compiler to generate to parrot friendly targets (PIR) by replacing the AST generation with PAST. The result will be integrated with existing open source Java standard libraries.

Ben Batha
Email: bbatha@u.rochester.edu
Google ID: applied under: elektronjunge
           prefered contact: bhbatha

Other contact info: bbatha on irc.parrot.org #parrot

Your Project's Title: Java on Parrot

Abstract
The project is based on providing a compiler for Java mostly or entirely written in Java. Previously written
compiler projects (OpenJDK javac or GCJ) will likely be used as a starting point for development. Reusing
code is a priority for completion of the project, so focus will be on replacing the code generation of a
compiler to generate to parrot friendly targets (PIR) by replacing the AST generation with PAST. The
result will be integrated with existing Java standard libraries (either OpenJDK, or GNU classpath).


Benefits to the Parrot VM and Open Source Community

This project would be a boon to both the Parrot and larger open source community. Java is one of the most
popular languages currently being used unfortunately it is largely locked the JVM which means that other
languages have to target the JVM to properly interact with Java. Bringing Java to Parrot would mean a lot of
preexisting code can run on Parrot. Additionally, Parrot can be language neutral way to interact popular
scripting languages already supported by Parrot with Java with minimal work by developers. Moreover, Parrot
is a more flexible virtual machine allowing for dynamic typing, etc. which would further facilitate
interaction between Java and other languages. The result of this project should be a foundation for for
future development of this important language.

Deliverables
This project should result in a compiler from Java to Parrot VM with support for at least basic Java syntax.
A portable test suite and build infrastructure for major platforms. Complete documentation with a particular
focus on how to extend the project so future improvements can be made. Documentation will be generated using
javadoc and distributed as html pages.


Project Details

The project will be broken into several stages.

1. A bootstrapped compiler (stage 1) using javac or a similar compiler based on an earlier Java compiler with
the internals replaced for code generation to PIR. This will likely be based on GCJ or javac (finalized after
research period). The implementation of Java is likely to remain rather simplistic avoiding newer more
complicated features that have come in more recent Java compilers e.g. generics. This implementation of Java
will rely on previously written Java standard libraries (GNU classpath or OpenJDK).

2. A stage 1 compiler that creates PAST objects. This compiler will be able to use built in Parrot optimization
routines.

3. A testing framework that tests all aspects of the completed code. The java code will use a the JUnit
testing framework, and the PIR code will be tested using Rosella.

4. A build system for major platforms.

<Problem Resolution>
1. Plan ahead to foresee potential problems
2. Interface with Parrot and Java compiler communities for assistance
3. Try different implementation of problematic code sections
4. Revert to backup plan

<Backup plan>
Time will be spent developing a plan for each portion of the code so a backup plan is unnecessary. In the
event of this necessity, there are multiple Java compiler projects that may function better than the chosen
compiler base. Additionally, if integrating PAST into an existing compiler becomes impossible it may be
easier to just rewrite the code generation from the Java compiler. Finally, if all else fails using parser
generators or programming the compiler from hand is an option.


Project Schedule
March 27 - April 8:
Finish proposal study code bases of Java compilers to get familiar with the scope of this project. Discuss
with mentors. Get familiar with Parrot.

April 8 - May 23:
Begin familiarizing myself with Parrot internals. Research the best compiler (OpenJDK, GCJ) to modify versus
the development of a new compiler using parser generators (ANTLR) or a handwritten compiler. Develop some
basic tests for each. Determine viability of each of the Java standards, e.g. generics. Discuss these with
mentor and the Parrot community. Find contacts in the Java community to discuss with as well.

May 23 - July 11: Begin work. (All indented dates are dates of completion).
    June   30: Clean out back end of chosen java compiler. Begin expression and control flow conversion.
    Milestone: Java to Java conversion. Documentation complete to this milestone. No tests this week.

    June    6: Finish expression and control flow conversion. Begin method and class conversion.
    Milestone: Expression and control flow conversion complete. Documentation complete to this milestone.
Begin to integrate tests for the milestone.

    June   13:  Potential absence for the work week, I should be around on the weekends to make up for any
major set back to the project. The worst case is I will be a week behind. If there is no absence then I can
begin work on more advanced Java features sooner, or have more time for debugging, etc.
    June   20: Method and class conversion.
    Milestone: Basic cases work. Documentation complete to this point. No test cases this week.

    June   27: Finish methods and Class calls and definitions. Integrate test suite for this part of the
compiler.
    Milestone: Method and class calls and definitions are complete. Documentation complete up to this point.
Basic tests for these features implemented.

    July    4: Tests for this portion of the compiler. Prepare for interim review. Determine viability of
PAST back end. Set firm criteria for PAST evaluation.
    Milestone: Finish the test suite for the stage 1 compiler. Clean up documentation.

    July   11:  Interim review. Make a decision on PAST, and begin work on PAST back end or alter plan
accordingly. Criteria for the decision will be ability to complete the project on time and in a way that is
maintainable. The focus should be on maintainability as Java is an important language for the Parrot arsenal
and must function properly.  
    Milestone: Java to PIR compiler complete for provided test cases. Compiler should bootstrap.
Decision on PAST.

    July   18: Work on PAST back end or equivalent.
    Milestone: Expression and control flow back end switched. Documentation to go with it. Test cases modified
accordingly.

    July   25: Finish work on PAST back end. Begin integration with java standard library (likely GNU
classpath)
    Milestone: PAST back end complete. Stage 2 compiler compiles with Parrot optimizations. Documentation
updated. Tests reflect any changes made by including PAST.

    August  1: Integration with standard library (likely candidate is GNU classpath).
    Milestone: Finish standard library integration. Documentation reflects this, and includes recommendations
about how to use a different standard library if modification is necessary. Test suite updated to include
tests of the library.

    August  8: Tests for Stage 2 compiler. Improve the build system. Work on cross language support
and other parrot features.
    Milestone: Build test suite of the entire project. Documentation complete for stage 2 compiler.

    August 15: FEATURE FREEZE: Finish anything that is not working. Finish the build system. Document any
notes about adding more parrot features to the compiler
    Milestone: Feature freeze. Finish any remaining debugging, clean code and documentation, build test cases, etc.

    August 22: Final submission
    Milestone: Finished GSOC project.

References and Likely Mentors
Peter Lobsinger

IRC Discussions:
Whiteknight

License
All Parrot projects should use the Artistic 2.0 license.

Bio
I am a sophomore computer science student at the University of Rochester. I have taken the following
computer science classes:
Programming Language Design and Implementation, this covered the design of compiler front ends and basics of
optimization. In this class I wrote a compiler for C.
Computation and Formal Systems,
Data Structures and Algorithms
Artificial Intelligence
Discrete Math
Linear Algebra & Differential Equations
Calculus I & II

I have experience with Java, C/C++, Python, Ruby, FORTRAN, and a host of small scientific languages, and I
am familiar with Linux/Unix. While I do not have familiarity with open source development I do use a variety
of pieces of open source soft ware and have participated in private sector software development. In the
past, I have been responsible in the past for projects of this size in my previous employment at Los Alamos
National Laboratory, where over three summers I completed three projects:
1) Rewrote an old hydrodynamic code from FORTRAN77 to FORTRAN95.
2) Developed a graphing tool for use with a rad-hydro code
3) Developed a graphing tool and scripting interface for use with a different rad-hydro code.


Eligibility
I am an eligible student who is a U.S. citizen and has the documentation to prove it.