FYI, "Updating JDK libraries to use Project Coin features"
"Zdeněk Troníček"
tronicek at fit.cvut.cz
Sun Dec 26 20:50:32 PST 2010
Hi,
RefactoringNG can be used to update the code in batch.
For example, the following rule used in v0.3
(http://kenai.com/projects/refactoringng/downloads) will update the code
to the diamond operator:
NewClass {
Expression [id: enclosing, nullable: true],
List<Tree> [id: typeArgs],
ParameterizedType {
Expression [id: ident],
List<Tree>
},
List<Expression> [id: args],
Class [id: body, elementKind: CLASS, nullable: true]
} ->
NewClass {
Expression [ref: enclosing],
List<Tree> [ref: typeArgs],
ParameterizedType {
Expression [ref: ident],
List<Tree> { }
},
List<Expression> [ref: args],
Class [ref: body]
}
(NetBeans 7 throws NullPointerException, but it is not severe and you can
continue. In NetBeans 6, it is performed without any error.)
When trying this, I found inconsistency in javac's AST. In NewClassTree,
identifier is ExpressionTree:
public interface NewClassTree extends ExpressionTree {
ExpressionTree getEnclosingExpression();
List<? extends Tree> getTypeArguments();
ExpressionTree getIdentifier();
List<? extends ExpressionTree> getArguments();
ClassTree getClassBody();
}
However, for new ArrayList<Integer>() the identifier is
ParameterizedTypeTree which is not ExpressionTree:
public interface ParameterizedTypeTree extends Tree {
Tree getType();
List<? extends Tree> getTypeArguments();
}
Z.T.
--
Zdenek Tronicek
FIT CTU in Prague
Joe Darcy napsal(a):
> Hello.
>
> FYI, we'll soon start a process to systematically update the JDK
> libraries to use Project Coin features:
>
> http://mail.openjdk.java.net/pipermail/jdk7-dev/2010-December/001727.html
>
> -Joe
>
>
More information about the coin-dev
mailing list