List of usage examples for java.lang NoSuchFieldException printStackTrace
public void printStackTrace()
From source file:edu.ku.brc.af.ui.forms.ViewFactory.java
/** * @param cellSubView// w w w . j av a 2 s.co m * @param dataClass * @return */ protected Field getFieldFromDotNotation(final FormCellSubView cellSubView, final Class<?> dataClass) { Class<?> parentCls = dataClass; String[] fieldNames = StringUtils.split(cellSubView.getName(), "."); for (int i = 0; i < fieldNames.length; i++) { try { //System.out.println("["+fieldNames[i]+"]"); if (fieldNames[i].equals("this")) { continue; } Field fld = null; try { fld = parentCls.getDeclaredField(fieldNames[i]); } catch (java.lang.NoSuchFieldException ex) { //edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); //edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewFactory.class, ex); UIRegistry.showError( String.format("There is no field named '%s' for class %s", fieldNames[i], parentCls)); String parentTitle = parentCls.getSimpleName(); DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(parentCls.getName()); if (ti != null) { parentTitle = ti.getTitle(); } UIRegistry.showError(String.format(UIRegistry.getResourceString("INVALID_FIELD_NAME"), fieldNames[i], parentTitle)); } if (fld != null) { if (i == fieldNames.length - 1) { return fld; } parentCls = fld.getType(); } else { log.error("Couldn't find field [" + cellSubView.getName() + "] in class [" + parentCls.getSimpleName() + "]"); } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewFactory.class, ex); ex.printStackTrace(); } } return null; }
From source file:com.xpn.xwiki.XWiki.java
public static Object getPrivateField(Object obj, String fieldName) { try {//from www . j ava2 s.c o m Field field = obj.getClass().getDeclaredField(fieldName); field.setAccessible(true); return field.get(obj); } catch (NoSuchFieldException e) { return null; } catch (IllegalAccessException e) { e.printStackTrace(); return null; } finally { } }