我在通过 Jenkins 显示的 Pentaho 数据集成(PDI,又名 Kettle)日志中遇到了一个神秘错误:
org.codehaus.janino.CompileException:SNO:“+=”重新转换失败
唯一包含“+=”的代码是这样的......
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;
}
}
我试过了:
- 谷歌搜索/ecosia 的错误信息
- 搜索堆栈溢出的错误消息:没有
- 搜索堆栈溢出的各个概念:每个似乎都很好 afaik
- 查找 Long.valueOf、+= 和 HashMap 的 .put、.getKey、.getValue 的兼容类型和返回类型等详细信息
- 在 w3schools 在线 Java 测试器中测试了该部分代码
- 换成
public boolean processRow
他们平时的public static void main
- 这段代码在 w3schools 中没有错误,但在我替换它之前一直是空白的,以至于我只是在测试组件。
- 而 Janine 似乎不喜欢替代方案,在 for 循环中使用冒号进行迭代——预期的分号。