## Polyglot 2.6 Porting Guide

Some Polyglot extensions may need minor changes to work with the new version of Polyglot. This document is intended to help developers fix their extensions accordingly.

### JL5 extension

Polyglot 2.6 supoprts Java 5 and Java 7 language features, via the JL5 and JL7 extensions (packages `polyglot.ext.jl5`, `polyglot.ext.jl7`). There are two options to implement a Polyglot extension that supports these language features (whether porting an existing extension, or writing a new one).

1. Translate to Java 1.4.

   The JL5 extension can be used to translate from Java 1.5 language features to equivalent Java 1.4 code. Extension writers can leverage this to provide support for Java 1.5 langauge features without needing to directly reason about such features in their extensions.

   The easiest way to write an extension that first translates Java 1.5 code to Java 1.4 code is to use the ExtensionRewriter pattern. This pattern rewrites Java 1.5 AST nodes to the extension's AST nodes. An example of this pattern is used by the JL5 extension to output Java 1.4 files. The JL5 AST is translated to JL ASTs, typechecked as Java 1.4, and then output to disk. See the `RemoveJava5isms` goal in `polyglot.ext.jl5.JL5Scheduler` for more info, as well as `polyglot.translate.JLOutputExtensionInfo`, for more information.

2. Directly support Java 5/Java 7.

   The JL5 and JL7 extensions can be directly extended, allowing extensions to directly support language features such as generics, enhanced for loops, enums, and annotations.

For porting extensions not already working with release 2.5, please consult the release 2.5 porting guide for more information.