Example usage for java.lang IllegalAccessError IllegalAccessError

List of usage examples for java.lang IllegalAccessError IllegalAccessError

Introduction

In this page you can find the example usage for java.lang IllegalAccessError IllegalAccessError.

Prototype

public IllegalAccessError(String s) 

Source Link

Document

Constructs an IllegalAccessError with the specified detail message.

Usage

From source file:org.apache.hadoop.hbase.util.PairOfSameType.java

@Override
public Iterator<T> iterator() {
    return new Iterator<T>() {
        private int returned = 0;

        @Override/*from  w w w . j  a  va  2  s  . c o m*/
        public boolean hasNext() {
            return this.returned < 2;
        }

        @Override
        public T next() {
            if (++this.returned == 1)
                return getFirst();
            else if (this.returned == 2)
                return getSecond();
            else
                throw new IllegalAccessError("this.returned=" + this.returned);
        }

        @Override
        public void remove() {
            throw new NotImplementedException();
        }
    };
}

From source file:com.baasbox.dao.UserDao.java

@Override
@Deprecated//from  w  w  w.j a  v  a 2s.  c o  m
public ODocument create() {
    throw new IllegalAccessError(
            "To create a new user call create(String username, String password) or create(String username, String password, String role)");
}

From source file:org.jenkinsci.plugins.github_branch_source.Connector.java

private Connector() {
    throw new IllegalAccessError("Utility class");
}

From source file:fr.mby.utils.common.prefs.StreamPreferences.java

@Override
protected void syncSpi() throws BackingStoreException {
    throw new IllegalAccessError("Not implemented yet !");
}

From source file:org.mycontroller.standalone.api.jaxrs.json.UserJson.java

@JsonIgnore
public void updateProfile() {
    if (user.getId() != null) {
        User userOld = DaoUtils.getUserDao().get(user);
        user.setUsername(userOld.getUsername());//Self should not change user name
        if (user.getPassword() == null || currentPassword == null || user.getPassword().length() == 0
                || currentPassword.length() == 0) {
            user.setPassword(userOld.getPassword());
        } else if (user.getPassword() != null && currentPassword != null) {
            if (!McCrypt.decrypt(userOld.getPassword()).equals(currentPassword)) {
                throw new IllegalAccessError("Incorrect current password!");
            } else {
                user.setPassword(McCrypt.encrypt(user.getPassword()));
            }//from  ww w  .  jav a 2s  .c om
        }
        //Update user
        DaoUtils.getUserDao().update(user);
    } else {
        throw new IllegalAccessError("user id missing!");
    }
}

From source file:fr.mby.utils.common.prefs.StreamPreferences.java

@Override
protected void flushSpi() throws BackingStoreException {
    throw new IllegalAccessError("Not implemented yet !");
}

From source file:be.fgov.kszbcss.rhq.websphere.component.jdbc.db2.pool.ConnectionContextImpl.java

ConnectionContextImpl(Map<String, Object> properties) {
    dataSource = new DB2SimpleDataSource();
    BeanInfo beanInfo;/* w  w  w  . ja  va 2s  .  co  m*/
    try {
        beanInfo = Introspector.getBeanInfo(DB2SimpleDataSource.class);
    } catch (IntrospectionException ex) {
        throw new Error(ex);
    }
    for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
        String name = descriptor.getName();
        if (properties.containsKey(name)) {
            Object value = properties.get(name);
            Class<?> propertyType = descriptor.getPropertyType();
            if (log.isDebugEnabled()) {
                log.debug("Setting property " + name + ": propertyType=" + propertyType.getName() + ", value="
                        + value + " (class=" + (value == null ? "<N/A>" : value.getClass().getName()) + ")");
            }
            if (propertyType != String.class && value instanceof String) {
                // Need to convert value to correct type
                if (propertyType == Integer.class || propertyType == Integer.TYPE) {
                    value = Integer.valueOf((String) value);
                }
                if (log.isDebugEnabled()) {
                    log.debug("Converted value to " + value + " (class=" + value.getClass().getName() + ")");
                }
            }
            try {
                descriptor.getWriteMethod().invoke(dataSource, value);
            } catch (IllegalArgumentException ex) {
                throw new RuntimeException("Failed to set '" + name + "' property", ex);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InvocationTargetException ex) {
                Throwable cause = ex.getCause();
                if (cause instanceof RuntimeException) {
                    throw (RuntimeException) cause;
                } else if (cause instanceof Error) {
                    throw (Error) cause;
                } else {
                    throw new RuntimeException(ex);
                }
            }
        }
    }
}

From source file:com.android.deskclock.Utils.java

public static void enforceMainLooper() {
    if (Looper.getMainLooper() != Looper.myLooper()) {
        throw new IllegalAccessError("May only call from main thread.");
    }/* www .jav a  2 s .com*/
}

From source file:org.apache.gora.infinispan.query.InfinispanQuery.java

public void build() {
    LOG.debug("build()");

    FilterConditionContext context = null;

    if (q != null) {
        LOG.trace("Query already built; ignoring.");
        return;/*from w w  w . j  a v  a  2s .  c om*/
    }

    QueryBuilder qb = ((InfinispanStore<K, T>) dataStore).getClient().getQueryBuilder();

    if (filter instanceof MapFieldValueFilter) {
        MapFieldValueFilter mfilter = (MapFieldValueFilter) filter;
        if (!(mfilter.getMapKey() instanceof Utf8))
            throw new IllegalAccessError("Invalid map key, must be a string.");
        if (mfilter.getOperands().size() > 1)
            throw new IllegalAccessError("MapFieldValueFilter operand not supported.");
        if (!(mfilter.getOperands().get(0) instanceof String))
            throw new IllegalAccessError("Invalid operand, must be a string.");
        String value = mfilter.getMapKey() + Support.DELIMITER + mfilter.getOperands().get(0).toString();
        switch (mfilter.getFilterOp()) {
        case EQUALS:
            if (value.equals("*")) {
                context = qb.having(mfilter.getFieldName()).like(value);
            } else {
                context = qb.having(mfilter.getFieldName()).eq(value);
            }
            if (!((MapFieldValueFilter) filter).isFilterIfMissing()) {
                LOG.warn("Forcing isFilterMissing to true");
                ((MapFieldValueFilter) filter).setFilterIfMissing(true);
            }
            break;
        case NOT_EQUALS:
            if (value.equals("*")) {
                context = qb.not().having(mfilter.getFieldName()).like(value);
            } else {
                context = qb.not().having(mfilter.getFieldName()).eq(value);
            }
            if (!((MapFieldValueFilter) filter).isFilterIfMissing()) {
                LOG.warn("Forcing isFilterMissing to false");
                ((MapFieldValueFilter) filter).setFilterIfMissing(false);
            }
            break;
        default:
            throw new IllegalAccessError("FilterOp not supported..");
        }

    } else if (filter instanceof SingleFieldValueFilter) {
        SingleFieldValueFilter sfilter = (SingleFieldValueFilter) filter;
        if (sfilter.getOperands().size() > 1)
            throw new IllegalAccessError("SingleFieldValueFilter operand not supported.");
        Object value = sfilter.getOperands().get(0);
        switch (sfilter.getFilterOp()) {
        case EQUALS:
            if (value.equals("*")) {
                context = qb.having(sfilter.getFieldName()).like((String) value);
            } else {
                context = qb.having(sfilter.getFieldName()).eq(value);
            }
            break;
        case NOT_EQUALS:
            if (value.equals("*")) {
                context = qb.not().having(sfilter.getFieldName()).like((String) value);
            } else {
                context = qb.not().having(sfilter.getFieldName()).eq(value);
            }
            break;
        case LESS:
            context = qb.having(sfilter.getFieldName()).lt(value);
            break;
        case LESS_OR_EQUAL:
            context = qb.having(sfilter.getFieldName()).lte(value);
            break;
        case GREATER:
            context = qb.having(sfilter.getFieldName()).gt(value);
            break;
        case GREATER_OR_EQUAL:
            context = qb.having(sfilter.getFieldName()).gte(value);
            break;
        default:
            throw new IllegalAccessError("FilterOp not supported..");
        }

    } else if (filter != null) {
        throw new IllegalAccessError("Filter not supported.");
    }

    if (this.startKey == this.endKey && this.startKey != null) {
        (context == null ? qb : context.and()).having(getPrimaryFieldName()).eq(this.startKey);
    } else {
        if (this.startKey != null && this.endKey != null)
            context = (context == null ? qb : context.and()).having(getPrimaryFieldName())
                    .between(this.startKey, this.endKey);
        else if (this.startKey != null)
            context = (context == null ? qb : context.and()).having(getPrimaryFieldName())
                    .between(this.startKey, null);
        else if (this.endKey != null)
            (context == null ? qb : context.and()).having(getPrimaryFieldName()).between(null, this.endKey);
    }

    // if projection enabled, keep the primary field.
    if (fields != null && fields.length > 0) {
        String[] fieldsWithPrimary;
        List<String> fieldsList = new ArrayList<>(Arrays.asList(fields));
        if (!fieldsList.contains(getPrimaryFieldName())) {
            fieldsWithPrimary = Arrays.copyOf(fields, fields.length + 1);
            fieldsWithPrimary[fields.length] = getPrimaryFieldName();
        } else {
            fieldsWithPrimary = fieldsList.toArray(new String[] {});
        }
        qb.setProjection(fieldsWithPrimary);
    }

    qb.orderBy((getSortingField().equals("")) ? getPrimaryFieldName() : getSortingField(),
            isAscendant ? SortOrder.ASC : SortOrder.DESC);

    if (this.getOffset() >= 0)
        qb.startOffset(this.getOffset());

    if (this.getLimit() > 0)
        qb.maxResults((int) this.getLimit());

    q = (RemoteQuery) qb.build();

    if (location != null)
        q.setLocation(location);
}

From source file:org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.java

/**
 * Builds up the {@link #setters} map that encapsulates where/how to set the value.
 */// w ww. j  av a2 s .com
private synchronized void buildMap() {
    if (setters != null)
        return;

    setters = new HashMap<String, Setter>();
    for (final Field f : getClass().getFields()) {
        final Parameter p = f.getAnnotation(Parameter.class);
        if (p != null) {
            setters.put(f.getName(), new Setter() {
                public Class getType() {
                    return f.getType();
                }

                public void set(Object target, Object value) {
                    try {
                        f.set(target, value);
                    } catch (IllegalAccessException e) {
                        throw (IllegalAccessError) new IllegalAccessError(e.getMessage()).initCause(e);
                    }
                }

                public boolean required() {
                    return p.required();
                }
            });
        }
    }

    for (final Method m : getClass().getMethods()) {
        final Parameter p = m.getAnnotation(Parameter.class);
        if (p != null) {
            final Class<?>[] pt = m.getParameterTypes();
            if (pt.length != 1)
                throw new IllegalArgumentException(
                        "Expecting one-arg method for @Parameter but found " + m + " instead");

            String name = m.getName();
            if (name.startsWith("set")) {
                name = Introspector.decapitalize(name.substring(3));
            }

            setters.put(name, new Setter() {
                public Class getType() {
                    return pt[0];
                }

                public void set(Object target, Object value) {
                    try {
                        m.invoke(target, value);
                    } catch (IllegalAccessException e) {
                        throw (IllegalAccessError) new IllegalAccessError(e.getMessage()).initCause(e);
                    } catch (InvocationTargetException e) {
                        throw new Error(e);
                    }
                }

                public boolean required() {
                    return p.required();
                }
            });
        }
    }
}