如何在 Kettle 的用户定义 Java Class 中创建 ArrayList 对象?

How to create an ArrayList object in an User Defined Java Class in Kettle?

我正在尝试在 pentaho kettle 中的用户定义 Java Class 对象中声明一个 ArrayList 对象。我正在 User Defined Java Class:

中尝试一个简单的代码
import java.util.List;
import java.util.ArrayList;

List<String> where = new ArrayList<String>();

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{    

    return true;

}

但是当我测试这个 class 时,我得到一个错误:

Line 4, Column 6: Identifier expected

可能是什么问题?如果我注释掉行 List<String> where = new ArrayList<String>(); 代码运行良好。

这是 forums.pentaho.com 的 known issue。内置编译器不使用泛型。只需制作一个列表对象,例如:

import java.util.List;

List where;

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{    

    return true;

}

不会引发任何错误。

Pentaho wiki 所述 Janino 不支持泛型。

Another thing to note is that Janino, essentially a Java byte-code generator only supports a sub-set of the Java 1.5 specification. To see a complete list of the features and limitations, please go to the Janino homepage. At the time of writing the most apparent limitation is the absence of generics.

所以,您应该使用像这样的简单列表:

List where;

而不是使用泛型。