3

I am trying to declare an ArrayList object in an User Defined Java Class object in pentaho kettle. I am trying a simple code inside the 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;

}

But when I test this class, I get an error:

Line 4, Column 6: Identifier expected

What can be the issue? If I comment out the line List<String> where = new ArrayList<String>(); the code works well.

iamgr007
  • 966
  • 1
  • 8
  • 28
psr
  • 2,619
  • 4
  • 32
  • 57
  • 1
    I don't see where you have your class declaration? – Michael Markidis Jun 29 '16 at 05:59
  • There is not need for defining the class in Kettle's `User Defined Java Class` step. Kettle already does that in it's environment while running the transformation. If I write `private String where` instead of `List where = new ArrayList(); `, the code functions well. – psr Jun 29 '16 at 06:01

2 Answers2

7

As mentioned on the Pentaho wiki Janino doesn't support generics.

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.

So, you should use a simple List like this :

List where;

instead of using generics.

Ashish Ranjan
  • 5,523
  • 2
  • 18
  • 39
0

This was a known issue at forums.pentaho.com. The built in compiler doesn't use generics. Simply making a List Object such as:

import java.util.List;

List where;

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

    return true;

}

doesn't raise any error.

psr
  • 2,619
  • 4
  • 32
  • 57