Search code examples
javahashmapkettlepdijanino

Meaning of java error "SNO: '+=' reconversion failed"?


I encountered a mysterious error in Pentaho Data Integration (PDI, a.k.a. Kettle) log displayed via Jenkins:

org.codehaus.janino.CompileException: SNO: "+=" reconversion failed

The only code that contains "+=" is like this...

import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
private static final String validKeys = "thing zero,thing two";
private Map/*<String, Long>*/ mapCount;

public boolean init ... {
    mapCount = new HashMap/*<String, Long>*/();
}
public boolean processRow ... {
    mapCount.put("thing zero", 0L);
    mapCount.put("thing one", 1L);
    Long calcUnidentified = 0L;
    Long calcTotal = 0L;
    Iterator it = mapCount.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry keyValuePair = (Map.Entry) it.next();
        
        String currentKey = keyValuePair.getKey().toString();
        Long currentValue = Long.valueOf(keyValuePair.getValue().toString());
        
        if (!validKeys.contains(currentKey)) {
            calcUnidentified += currentValue;
        }
        calcTotal += currentValue;
    }
}

I tried:

  • googled/ecosia for the error message
  • searched stack overflow for the error message: nothing
  • searched stack overflow for the individual concepts: each seems fine afaik
  • looked up the details such as compatible types and return types for Long.valueOf, +=, and HashMap's .put, .getKey, .getValue
  • tested the parts of that code in w3schools online java tester
  • replaced public boolean processRow with their usual public static void main
  • this code doesn't error in w3schools but goes blank until I replace it so much that really I'm just testing the components.
  • whereas Janine seems to dislike the alternative, iterating with a colon in a for a loop -- expected semicolon.

Solution

  • As strange as it may sound for java, the solution was to simply replace...

    calcUnidentified += currentValue;
    

    ...with...

    calcUnidentified = calcUnidentified + currentValue;
    

    As Thomas Kläger noted, this bug seems very specific to Janino (used by PDI for java).