#vulnerable code 
                                public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
        return ~((Integer) MVEL.eval(name, ctx, factory));
    } 
                            #location 2 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
        Object o = MVEL.eval(name, ctx, factory);
        if (o instanceof Integer) {
            return ~((Integer) o);
        }
        else {
            throw new CompileException("was expecting type: Integer; but found type: " + (o == null ? "null" : o.getClass().getName()));
        }
    }