Example usage for java.lang IllegalAccessException printStackTrace

List of usage examples for java.lang IllegalAccessException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:edu.umass.cs.reconfiguration.reconfigurationpackets.ReconfigurationPacket.java

private static BasicReconfigurationPacket<?> getReconfigurationPacket(JSONObject json,
        Map<ReconfigurationPacket.PacketType, Class<?>> typeMap, Stringifiable<?> unstringer,
        boolean forcePrintException) throws JSONException {
    BasicReconfigurationPacket<?> rcPacket = null;
    ReconfigurationPacket.PacketType rcType = null;
    String canonicalClassName = null;
    try {//  w w w.  ja  v a 2  s.  c om
        long t = System.nanoTime();
        if ((rcType = ReconfigurationPacket.PacketType.intToType.get(JSONPacket.getPacketType(json))) != null
                && (canonicalClassName = getPacketTypeCanonicalClassName(rcType)) != null) {
            rcPacket = (BasicReconfigurationPacket<?>) (Class.forName(canonicalClassName)
                    .getConstructor(JSONObject.class, Stringifiable.class).newInstance(json, unstringer));
        }
        DelayProfiler.updateDelayNano("rc_reflection", t);
    } catch (NoSuchMethodException nsme) {
        nsme.printStackTrace();
    } catch (InvocationTargetException ite) {
        ite.printStackTrace();
    } catch (IllegalAccessException iae) {
        iae.printStackTrace();
    } catch (ClassNotFoundException cnfe) {
        Reconfigurator.getLogger().info("Class " + canonicalClassName + " not found");
        cnfe.printStackTrace();
    } catch (InstantiationException ie) {
        ie.printStackTrace();
    } finally {
        if (forcePrintException
                && ReconfigurationPacket.PacketType.intToType.get(JSONPacket.getPacketType(json)) == null) {
            (new RuntimeException("No reconfiguration packet type found in: " + json)).printStackTrace();
        }
    }

    return rcPacket;
}

From source file:com.mmj.app.lucene.solr.client.SolrClient.java

public static Object toBean(SolrDocument record, Class<?> clazz) {

    Object o = null;// w  ww  . j  ava  2 s .c o m
    try {
        o = clazz.newInstance();
    } catch (InstantiationException e1) {
        e1.printStackTrace();
    } catch (IllegalAccessException e1) {
        e1.printStackTrace();
    }
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        Object value = record.get(field.getName());
        ConvertUtils.register(new DateConverter(null), java.util.Date.class);
        try {
            BeanUtils.setProperty(o, field.getName(), value);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
    return o;
}

From source file:com.wit.android.support.fragment.util.FragmentAnnotations.java

/**
 * Attaches the given <var>view</var> instance to the given <var>field</var> as its value for the
 * given <var>fieldParent</var> object.
 *
 * @param field       A field to which should be the given view set as value.
 * @param fieldParent A context in which is the passed view <var>field</var> presented.
 * @param view        View to be set as value of the given field.
 * @return {@code True} when attaching succeeded, {@code false} otherwise.
 * @throws RuntimeException If the given field is not instance of {@link android.view.View}.
 *///from   ww  w.  j av  a2 s .  c  om
private static boolean attachView(Field field, Object fieldParent, View view) {
    // Check correct type of the field.
    if (View.class.isAssignableFrom(field.getType())) {
        field.setAccessible(true);
        try {
            field.set(fieldParent, view);
            return true;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    throw new RuntimeException("Field(" + fieldParent.getClass().getSimpleName() + "." + field.getName()
            + ") is not instance of view, thus can not be injected.");
}

From source file:org.zywx.wbpalmstar.plugin.uexiconlist.utils.IconListUtils.java

/**
 * getCustomScale?x5scale??// ww  w .  j  av  a 2 s .c o m
 * 
 * @param mBrwView
 * @return
 */
public static float getWebScale(EBrowserView mBrwView) {
    float scale = 1.0f;
    try {
        Method gatScale = EBrowserView.class.getMethod("getCustomScale", null);
        try {
            scale = (Float) gatScale.invoke(mBrwView, null);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        scale = getWebScaleOld(mBrwView);
    }

    return scale;
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindFragmentArgument(Fragment receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);/*from   w ww. j  a  va2s .  c o m*/
        FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class);
        if (fragmentArgument != null) {
            try {
                Bundle bundle = receiver.getArguments();
                if (bundle != null) {
                    Class<?> type = field.getType();
                    if (type == Boolean.class || type == boolean.class) {
                        field.set(receiver, bundle.getBoolean(fragmentArgument.value()));
                    } else if (type == Byte.class || type == byte.class) {
                        field.set(receiver, bundle.getByte(fragmentArgument.value()));
                    } else if (type == Character.class || type == char.class) {
                        field.set(receiver, bundle.getChar(fragmentArgument.value()));
                    } else if (type == Double.class || type == double.class) {
                        field.set(receiver, bundle.getDouble(fragmentArgument.value()));
                    } else if (type == Float.class || type == float.class) {
                        field.set(receiver, bundle.getFloat(fragmentArgument.value()));
                    } else if (type == Integer.class || type == int.class) {
                        field.set(receiver, bundle.getInt(fragmentArgument.value()));
                    } else if (type == Long.class || type == long.class) {
                        field.set(receiver, bundle.getLong(fragmentArgument.value()));
                    } else if (type == Short.class || type == short.class) {
                        field.set(receiver, bundle.getShort(fragmentArgument.value()));
                    } else if (type == String.class) {
                        field.set(receiver, bundle.getString(fragmentArgument.value()));
                    } else if (type == Boolean[].class || type == boolean[].class) {
                        field.set(receiver, bundle.getBooleanArray(fragmentArgument.value()));
                    } else if (type == Byte[].class || type == byte[].class) {
                        field.set(receiver, bundle.getByteArray(fragmentArgument.value()));
                    } else if (type == Character[].class || type == char[].class) {
                        field.set(receiver, bundle.getCharArray(fragmentArgument.value()));
                    } else if (type == Double[].class || type == double[].class) {
                        field.set(receiver, bundle.getDoubleArray(fragmentArgument.value()));
                    } else if (type == Float[].class || type == float[].class) {
                        field.set(receiver, bundle.getFloatArray(fragmentArgument.value()));
                    } else if (type == Integer[].class || type == int[].class) {
                        field.set(receiver, bundle.getIntArray(fragmentArgument.value()));
                    } else if (type == Long[].class || type == long[].class) {
                        field.set(receiver, bundle.getLongArray(fragmentArgument.value()));
                    } else if (type == Short[].class || type == short[].class) {
                        field.set(receiver, bundle.getShortArray(fragmentArgument.value()));
                    } else if (type == String[].class) {
                        field.set(receiver, bundle.getStringArray(fragmentArgument.value()));
                    } else if (Serializable.class.isAssignableFrom(type)) {
                        field.set(receiver, bundle.getSerializable(fragmentArgument.value()));
                    } else if (type == Bundle.class) {
                        field.set(receiver, bundle.getBundle(fragmentArgument.value()));
                    }
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindIntentExtra(Object receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);//  w ww.j  av a 2s.  co  m
        IntentExtra intentExtra = field.getAnnotation(IntentExtra.class);
        if (intentExtra != null) {
            try {
                Intent intent = null;
                if (receiver instanceof Activity) {
                    intent = ((Activity) receiver).getIntent();
                } else if (receiver instanceof Fragment) {
                    intent = ((Fragment) receiver).getActivity().getIntent();
                }
                if (intent != null) {
                    Class<?> type = field.getType();
                    if (type == Boolean.class || type == boolean.class) {
                        field.set(receiver, intent.getBooleanExtra(intentExtra.value(), false));
                    } else if (type == Byte.class || type == byte.class) {
                        field.set(receiver, intent.getByteExtra(intentExtra.value(), (byte) 0));
                    } else if (type == Character.class || type == char.class) {
                        field.set(receiver, intent.getCharExtra(intentExtra.value(), '\u0000'));
                    } else if (type == Double.class || type == double.class) {
                        field.set(receiver, intent.getDoubleExtra(intentExtra.value(), 0.0d));
                    } else if (type == Float.class || type == float.class) {
                        field.set(receiver, intent.getFloatExtra(intentExtra.value(), 0.0f));
                    } else if (type == Integer.class || type == int.class) {
                        field.set(receiver, intent.getIntExtra(intentExtra.value(), 0));
                    } else if (type == Long.class || type == long.class) {
                        field.set(receiver, intent.getLongExtra(intentExtra.value(), 0L));
                    } else if (type == Short.class || type == short.class) {
                        field.set(receiver, intent.getShortExtra(intentExtra.value(), (short) 0));
                    } else if (type == String.class) {
                        field.set(receiver, intent.getStringExtra(intentExtra.value()));
                    } else if (type == Boolean[].class || type == boolean[].class) {
                        field.set(receiver, intent.getBooleanArrayExtra(intentExtra.value()));
                    } else if (type == Byte[].class || type == byte[].class) {
                        field.set(receiver, intent.getByteArrayExtra(intentExtra.value()));
                    } else if (type == Character[].class || type == char[].class) {
                        field.set(receiver, intent.getCharArrayExtra(intentExtra.value()));
                    } else if (type == Double[].class || type == double[].class) {
                        field.set(receiver, intent.getDoubleArrayExtra(intentExtra.value()));
                    } else if (type == Float[].class || type == float[].class) {
                        field.set(receiver, intent.getFloatArrayExtra(intentExtra.value()));
                    } else if (type == Integer[].class || type == int[].class) {
                        field.set(receiver, intent.getIntArrayExtra(intentExtra.value()));
                    } else if (type == Long[].class || type == long[].class) {
                        field.set(receiver, intent.getLongArrayExtra(intentExtra.value()));
                    } else if (type == Short[].class || type == short[].class) {
                        field.set(receiver, intent.getShortArrayExtra(intentExtra.value()));
                    } else if (type == String[].class) {
                        field.set(receiver, intent.getStringArrayExtra(intentExtra.value()));
                    } else if (Serializable.class.isAssignableFrom(type)) {
                        field.set(receiver, intent.getSerializableExtra(intentExtra.value()));
                    } else if (type == Bundle.class) {
                        field.set(receiver, intent.getBundleExtra(intentExtra.value()));
                    }
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.chrynan.teleport.Teleport.java

/**
 * Retrieves and stores data into their corresponding fields within the specified binding object.
 *
 * @param bindObject The binding object that is searched for Data annotation named fields,
 *                   which these fields are then propagated with corresponding fetched data.
 * @param context    The Context used to store and retrieve data.
 *///from  w w w .  j  a v a2s .  co m
public static final void bind(@NonNull Object bindObject, @NonNull Context context) {
    if (bindObject == null) {
        throw new IllegalArgumentException("Object parameter in bind method of "
                + Teleport.class.getSimpleName() + " class must not be null.");
    }
    if (context == null) {
        throw new IllegalArgumentException("Context parameter in bind method of "
                + Teleport.class.getSimpleName() + " class must not be null.");
    }
    StorageMap map = StorageMap.with(context);
    for (Field f : getAnnotatedFields(bindObject)) {
        try {
            f.setAccessible(true);
            Data d = f.getAnnotation(Data.class);
            if (d.bind()) {
                f.set(bindObject, map.get((d == null) ? "" : d.value(), f.getType()));
            }
        } catch (IllegalAccessException iae) {
            iae.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.chrynan.teleport.Teleport.java

/**
 * Retrieves and stores data into their corresponding fields within the specified binding object.
 *
 * @param bindObject The binding object that is searched for Data annotation named fields,
 *                   which these fields are then propagated with corresponding fetched data.
 * @param context    The underlying Context used for storing and retrieving data. This needed Context is
 *                   only used for certain scenarios (ex: saving files) but if the Intent parameter is
 *                   null, then it is used as the default storage mechanism (SharedPreferences created by Context).
 * @param intent     The Intent used to store and retrieve data.
 *//*from   www.ja v  a  2  s.c om*/
public static final void bind(@NonNull Object bindObject, @NonNull Context context, Intent intent) {
    if (bindObject == null) {
        throw new IllegalArgumentException("Object parameter in bind method of "
                + Teleport.class.getSimpleName() + " class must not be null.");
    }
    if (context == null) {
        throw new IllegalArgumentException("Context parameter in bind method of "
                + Teleport.class.getSimpleName() + " class must not be null.");
    }
    if (intent == null) {
        bind(bindObject, context);
    } else {
        StorageMap map = StorageMap.with(context, intent);
        for (Field f : getAnnotatedFields(bindObject)) {
            try {
                f.setAccessible(true);
                Data d = f.getAnnotation(Data.class);
                if (d.bind()) {
                    f.set(bindObject, map.get((d == null) ? "" : d.value(), f.getType()));
                }
            } catch (IllegalAccessException iae) {
                iae.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.chrynan.teleport.Teleport.java

/**
 * Retrieves and stores data into their corresponding fields within the specified binding object.
 *
 * @param bindObject The binding object that is searched for Data annotation named fields,
 *                   which these fields are then propagated with corresponding fetched data.
 * @param context    The underlying Context used for storing and retrieving data. This needed Context is
 *                   only used for certain scenarios (ex: saving files) but if the Intent parameter is
 *                   null, then it is used as the default storage mechanism (SharedPreferences created by Context).
 * @param bundle     The Bundle used to store and retrieve data.
 *//*w  w w . j  a v a 2 s  .  c om*/
public static final void bind(@NonNull Object bindObject, @NonNull Context context, Bundle bundle) {
    if (bindObject == null) {
        throw new IllegalArgumentException("Object parameter in bind method of "
                + Teleport.class.getSimpleName() + " class must not be null.");
    }
    if (context == null) {
        throw new IllegalArgumentException("Context parameter in bind method of "
                + Teleport.class.getSimpleName() + " class must not be null.");
    }
    if (bundle == null) {
        bind(bindObject, context);
    } else {
        StorageMap map = StorageMap.with(context, bundle);
        for (Field f : getAnnotatedFields(bindObject)) {
            try {
                f.setAccessible(true);
                Data d = f.getAnnotation(Data.class);
                if (d.bind()) {
                    f.set(bindObject, map.get((d == null) ? "" : d.value(), f.getType()));
                }
            } catch (IllegalAccessException iae) {
                iae.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.github.fcannizzaro.resourcer.Resourcer.java

/**
 * Bind a class//  w w  w  .jav  a  2  s. c  o  m
 */
public static void bind(Object annotated) {

    for (Field field : annotated.getClass().getDeclaredFields())
        try {
            switchAnnotation(field, annotated);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
}