if (indexInParent != maxIndex || context.containsKey(INSTANTIATE_LEAF_NODES)) {
if ( (indexInParent != -1 && indexInParent < maxIndex) || context.containsKey(INSTANTIATE_LEAF_NODES) ) {
    public Object nullPropertyValue(Map context, Object target, Object property) {        Object result = null;        OgnlContext ctx = (OgnlContext) context;        int indexInParent = ctx.getCurrentEvaluation().getNode().getIndexInParent();        int maxIndex = ctx.getRootEvaluation().getNode().jjtGetNumChildren() -1 ;        // If the null value isn't the terminal value in the expression...        if (indexInParent != maxIndex || context.containsKey(INSTANTIATE_LEAF_NODES)) {            try {                if (target instanceof List) {                    // If the target is a list, cross your fingers and hope the getters and setters                    // are using generic types...if they are we can fill in the blanks                    Integer index = (Integer) property;                    List list = (List) target;                    Object listContainer = ctx.getCurrentEvaluation().getPrevious().getSource();                    String listProperty = ctx.getCurrentEvaluation().getPrevious().getNode().toString();                    Method method = OgnlRuntime.getSetMethod(ctx, listContainer.getClass(), listProperty);                    Type[] types = method.getGenericParameterTypes();                    if (types[0] instanceof ParameterizedType) {                        ParameterizedType ptype = (ParameterizedType) types[0];                        Type actualType = ptype.getActualTypeArguments()[0];                        if (actualType instanceof Class) {                            // Yippee! We know how to make one of these                            Class clazz = (Class) actualType;                            result = clazz.newInstance();                        }                    }                    if (result == null) {                        throw new RuntimeException("You appear to be trying to get or set a nested " +                            "property through a List without supplying Generic getter/setter methods. " +                            "without Generic method signatures there is no way for Stripes to get " +                            "the type of object that should be in your List. List was on an object of " +                            "type " + listContainer.getClass() + ", property name was: " + listProperty);                    }                    else if (ctx.getRootEvaluation().isSetOperation()) {                        while (list.size() <= index) {                            list.add(null);                        }                        list.set(index, result);                    }                }                else if (target instanceof Map) {                    // If the target is a Map, cross your fingers and hope the getters and setters                    // are using generic types...if they are we can fill in the blanks                    Map map = (Map) target;                    Object mapContainer = ctx.getCurrentEvaluation().getPrevious().getSource();                    String mapProperty = ctx.getCurrentEvaluation().getPrevious().getNode().toString();                    Method method = OgnlRuntime.getSetMethod(ctx, mapContainer.getClass(), mapProperty);                    Type[] types = method.getGenericParameterTypes();                    if (types[0] instanceof ParameterizedType) {                        ParameterizedType ptype = (ParameterizedType) types[0];                        Type actualType = ptype.getActualTypeArguments()[1];                        if (actualType instanceof Class) {                            // Yippee! We know how to make one of these                            Class clazz = (Class) actualType;                            result = clazz.newInstance();                        }                    }                    if (result == null) {                        throw new RuntimeException("You appear to be trying to get or set a nested " +                                "property through a Map without supplying Generic getter/setter methods. " +                                "without Generic method signatures there is no way for Stripes to get " +                                "the type of object that should be in your Map. Map was on an object of " +                                "type " + mapContainer.getClass() + ", property name was: " + mapProperty);                    }                    else if (ctx.getRootEvaluation().isSetOperation()) {                        map.put(property, result);                    }                }                else {                    String propertyName = (String) property;                    // Get the set method, determine the type of object that was null, and make one!                    Method method =                        OgnlRuntime.getSetMethod(ctx, target.getClass(), propertyName);                    Class clazzes[] = method.getParameterTypes();                    // If the target type is an array we have to instantiate it a little differently                    if (clazzes[0].isArray()) {                        result = Array.newInstance(clazzes[0].getComponentType(), 0);                    }                    else if (clazzes[0].isEnum()) {                        result = clazzes[0].getEnumConstants()[0];                    }                    else if (interfaceImplementations.containsKey(clazzes[0]) ) {                        result = interfaceImplementations.get(clazzes[0]).newInstance();                    }                    else {                        result = clazzes[0].newInstance();                    }                    // Now, if the caller was doing a set operation, lets make this change permanent                    if (ctx.getRootEvaluation().isSetOperation()) {                        Object[] args = new Object[1];                        args[0] = result;                        method.invoke(target, args);                    }                }            }            catch (Exception e) { // There's really not a lot we can do about this.                log.info("Problem encountered trying to create and set property [", property,                        "] on object of type [", target.getClass().getName(), "]. ", e.getMessage());            }        }        return result;    }