History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: OGNL-134
Type: Bug Bug
Status: Closed Closed
Resolution: Not A Problem
Priority: Major Major
Assignee: Jesse Kuhnert
Reporter: Jesse Kuhnert
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OGNL

primitive character conversion in statement compilation

Created: 26/Nov/07 08:49 AM   Updated: 18/Jan/08 03:01 PM
Component/s: ExpressionCompiler
Affects Version/s: 2.7.1
Fix Version/s: 2.7.2

Environment: any


 Description  « Hide
investigate forum post:


The following logic is common ListPropertyAccessor, ArrayPropertyAccessor and ObjectPropertyAccessor. Eg. in ObjectPropertyAccessor's getSourceSetter

conversion = OgnlRuntime.getCompiler().createLocalReference(context,
                                                                            "((" + wrapClass.getName() + ")ognl.OgnlOps#convertValue($3," + wrapClass.getName()
                                                                            + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass),
                                                                            parm);



It uses

OgnlRuntime.getNumericValueGetter(wrapClass)



which looks like

static {
        NUMERIC_VALUES.put(Double.class, "doubleValue()");
        NUMERIC_VALUES.put(Float.class, "floatValue()");
        NUMERIC_VALUES.put(Integer.class, "intValue()");
        NUMERIC_VALUES.put(Long.class, "longValue()");
        NUMERIC_VALUES.put(Short.class, "shortValue()");
        NUMERIC_VALUES.put(Byte.class, "byteValue()");
        NUMERIC_VALUES.put(BigDecimal.class, "doubleValue()");
        NUMERIC_VALUES.put(BigInteger.class, "doubleValue()");
        NUMERIC_VALUES.put(Boolean.class, "booleanValue()");
    }



to return string like eg.
"doubleValue()", "intValue()" etc. to convert the Wrapped object to its primitive types, however it doesn't cover character, so we will get a compilation problem when javassist try to compile the code when we are dealing with character.

Maybe we could define a separate method in OgnlRuntime to deal with all primitive types instead of just numeric values.

Thoughs? Should I open up a jira ticket for this?

Thanks guys

 All   Comments   Change History      Sort Order:
Jesse Kuhnert - [18/Jan/08 03:01 PM ]
It was as I suspected, this numeric value type conversion only happens with the numeric types covered in the mapping - so the Character types should work fine.