I was investigating a report that had a completely empty column of data. After verifying that the expression and data was getting correctly generated, I traced the bug down to a source code generation error in Jasper.
Incorrect source code is generated if the report contains 101 expressions. There is an edge case, where source code generated does not correctly chain methods if there are 101 expressions. If there are less or more expressions, the source code is correct.
Example Incorrect Source:
In the following code, we have 101 expressions and the default: case does not correctly chain to the generated private evaluate1() method. This is a simple edge condition, and if you have 102 expressions then the default: case chains to the evaluate1() method correctly.
/**
*
*/
public Object evaluate(int id) throws Throwable
{
Object value = null;
switch (id)
{
.
.
.
case 99 :
{
value = ((java.lang.String)field_description.getValue()); //$JR_EXPR_ID=99$
break;
}
default :
{
}
}
return value;
}
/**
*
*/
private Object evaluate1(int id) throws Throwable
{
Object value = null;
switch (id)
{
case 100 :
{
value = ((java.math.BigDecimal)variable_AMOUNT_VAR.getValue()); //$JR_EXPR_ID=100$
break;
}
default :
{
}
}
return value;
}
Recommended Comments