Example usage for java.lang NoSuchFieldException printStackTrace

List of usage examples for java.lang NoSuchFieldException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.medsphere.fileman.FMRecord.java

protected void setDomainValue(String fieldName, Object value) {
    try {//from  www.  j  ava  2 s. c om
        Class thisClass = getClass();

        Field field = null;
        Class curClass = thisClass;
        while (!curClass.equals(FMRecord.class)) {
            try {
                field = curClass.getDeclaredField(fieldName);
                String number = field.getAnnotation(FMAnnotateFieldInfo.class).number();
                setDomainValue(fieldName, value, number);
                break;
            } catch (NoSuchFieldException e) {
            }
            curClass = curClass.getSuperclass();

        }

        if (field == null)

            throw new NoSuchFieldException();
    } catch (NoSuchFieldException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.alibaba.android.layoutmanager.ExposeLinearLayoutManagerEx.java

protected static void attachViewHolder(RecyclerView.LayoutParams params, RecyclerView.ViewHolder holder) {
    try {//from   w w w.jav a2 s . c om

        if (vhField == null) {
            vhField = RecyclerView.LayoutParams.class.getDeclaredField("mViewHolder");
        }

        vhField.setAccessible(true);
        vhField.set(params, holder);

        if (vhSetFlags == null) {
            vhSetFlags = RecyclerView.ViewHolder.class.getDeclaredMethod("setFlags", int.class, int.class);
            vhSetFlags.setAccessible(true);
        }

        vhSetFlags.invoke(holder, FLAG_INVALID, FLAG_INVALID);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}

From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java

private void initActionBar() {
    Class<?> windowClass = Window.class;
    try {//from   w  ww.jav  a 2s  . c  om
        Field field = windowClass.getField("FEATURE_ACTION_BAR");
        int fieldValue = field.getInt(null);
        this.getWindow().requestFeature(fieldValue);
    } catch (NoSuchFieldException e) {
        // DOES NOTHING
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.medsphere.fileman.FMRecord.java

protected void setDomainValue(String fieldName, Object value, String number) {
    boolean didFieldSet = false;
    try {/*  w w  w .jav a  2s .  c om*/
        Class thisClass = getClass();
        Field field = null;
        Class curClass = thisClass;
        while (!curClass.equals(FMRecord.class)) {
            try {
                field = curClass.getDeclaredField(fieldName);
                break;
            } catch (NoSuchFieldException e) {
            }
            curClass = curClass.getSuperclass();

        }

        if (field != null) {
            field.setAccessible(true);
            Object currentValue = field.get(this);
            if (valuesChanged(currentValue, value)) {
                field.set(this, value);
                addModifiedField(number);
            }
            didFieldSet = true;
        } else
            throw new NoSuchFieldException();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if (!didFieldSet) {
        acceptField(fieldName, value.toString());
    }
}

From source file:com.yunmall.ymsdk.widget.YmSlidingPaneLayout.java

/**
 * ???//from ww  w . j a  v a 2 s  .  c  om
 * @param dip ???
 */
public void setEdgeWidth(int dip) {
    try {
        float density = getResources().getDisplayMetrics().density;
        Integer edgeSize = (int) (dip * density + 0.5f);

        Field field = ViewDragHelper.class.getDeclaredField("mEdgeSize");
        field.setAccessible(true);
        field.set(mDragHelper, edgeSize);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.mtbs3d.minecrift.control.GuiScreenNaviator.java

public GuiScreenNaviator(GuiScreen screen) {
    mc = Minecraft.getMinecraft();/*w  ww .  j a v a  2 s  . c om*/
    nav = this;

    if (guiLeft == null) {
        try {
            keyDownField = Keyboard.class.getDeclaredField("keyDownBuffer");
            keyDownField.setAccessible(true);
            guiLeft = GuiContainer.class.getDeclaredField("guiLeft");
            guiTop = GuiContainer.class.getDeclaredField("guiTop");
            System.out.println("[Minecrift]GuiScreenNavigator: Reflected guiLeft/guiTop");
        } catch (NoSuchFieldException e) {
            try {
                guiLeft = GuiContainer.class.getDeclaredField("p"); //obfuscated name
                guiTop = GuiContainer.class.getDeclaredField("q"); //obfuscated name
                System.out.println("[Minecrift]GuiScreenNavigator: Reflected obfuscated guiLeft/guiTop (p/q)");
            } catch (NoSuchFieldException e1) {
                System.out.println(
                        "[Minecrift]GuiScreenNavigator: Couldn't get guiLeft/guiTop via reflection! Joystick navigation of inventories may be inaccurate.");
            }
            ;
        }
        if (guiLeft != null)
            guiLeft.setAccessible(true);
        if (guiTop != null)
            guiTop.setAccessible(true);
    }

    this.screen = screen;
    for (Field field : screen.getClass().getDeclaredFields()) {
        if (field.getType().getSuperclass() == GuiSlot.class) {
            field.setAccessible(true);
            try {
                slot = (GuiSlot) field.get(screen);
                break;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    Class<?> screenclazz = screen.getClass();
    parentScreen = null;
    while (parentScreen == null && screenclazz != null) {
        for (Field field : screenclazz.getDeclaredFields()) {
            if (GuiScreen.class.isAssignableFrom(field.getType())) {
                field.setAccessible(true);
                try {
                    //Assume the first declared GuiScreen object is the "parent"
                    //Might not always work.
                    parentScreen = (GuiScreen) field.get(screen);
                    break;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        screenclazz = screenclazz.getSuperclass();
    }
    curPoint = Pair.of(Mouse.getX() * screen.width / this.mc.displayWidth,
            screen.height - Mouse.getY() * screen.height / this.mc.displayHeight - 1);

    if (slot != null && slot.publicGetSize() > 0) {
        slotIndex = 0;
        slot.select(0, false);
        onSlot = true;
    }
}

From source file:lineage2.gameserver.Config.java

/**
 * Method loadGMAccess./*from ww  w.j  ava  2  s.co  m*/
 * @param file File
 */
public static void loadGMAccess(File file) {
    try {
        Field fld;
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false);
        factory.setIgnoringComments(true);
        Document doc = factory.newDocumentBuilder().parse(file);
        for (Node z = doc.getFirstChild(); z != null; z = z.getNextSibling()) {
            for (Node n = z.getFirstChild(); n != null; n = n.getNextSibling()) {
                if (!n.getNodeName().equalsIgnoreCase("char")) {
                    continue;
                }
                PlayerAccess pa = new PlayerAccess();
                for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
                    Class<?> cls = pa.getClass();
                    String node = d.getNodeName();
                    if (node.equalsIgnoreCase("#text")) {
                        continue;
                    }
                    try {
                        fld = cls.getField(node);
                    } catch (NoSuchFieldException e) {
                        _log.info("Not found desclarate ACCESS name: " + node + " in XML Player access Object");
                        continue;
                    }
                    if (fld.getType().getName().equalsIgnoreCase("boolean")) {
                        fld.setBoolean(pa,
                                Boolean.parseBoolean(d.getAttributes().getNamedItem("set").getNodeValue()));
                    } else if (fld.getType().getName().equalsIgnoreCase("int")) {
                        fld.setInt(pa, Integer.valueOf(d.getAttributes().getNamedItem("set").getNodeValue()));
                    }
                }
                gmlist.put(pa.PlayerID, pa);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.mtbs3d.minecrift.control.GuiScreenNavigator.java

public GuiScreenNavigator(GuiScreen screen) {
    mc = Minecraft.getMinecraft();//  w ww . j  a v a 2 s . co m
    nav = this;

    if (guiLeft == null) {
        try {
            keyDownField = Keyboard.class.getDeclaredField("keyDownBuffer");
            keyDownField.setAccessible(true);
            guiLeft = GuiContainer.class.getDeclaredField("field_147003_i"); // was guiLeft
            guiTop = GuiContainer.class.getDeclaredField("field_147009_r"); // was guiTop
            System.out.println("[Minecrift] GuiScreenNavigator: Reflected guiLeft/guiTop");
        } catch (NoSuchFieldException e) {
            try {
                guiLeft = GuiContainer.class.getDeclaredField("i"); //obfuscated name  was p
                guiTop = GuiContainer.class.getDeclaredField("r"); //obfuscated name  was q
                System.out.println("[Minecrift] GuiScreenNavigator: Reflected obfuscated guiLeft/guiTop (i/r)");
            } catch (NoSuchFieldException e1) {
                System.out.println(
                        "[Minecrift] GuiScreenNavigator: Couldn't get guiLeft/guiTop via reflection! Joystick navigation of inventories may be inaccurate.");
            }
            ;
        }
        if (guiLeft != null)
            guiLeft.setAccessible(true);
        if (guiTop != null)
            guiTop.setAccessible(true);
    }

    this.screen = screen;
    for (Field field : screen.getClass().getDeclaredFields()) {
        if (field.getType().getSuperclass() == GuiSlot.class) {
            field.setAccessible(true);
            try {
                slot = (GuiSlot) field.get(screen);
                break;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    Class<?> screenclazz = screen.getClass();
    parentScreen = null;
    while (parentScreen == null && screenclazz != null) {
        for (Field field : screenclazz.getDeclaredFields()) {
            if (GuiScreen.class.isAssignableFrom(field.getType())) {
                field.setAccessible(true);
                try {
                    //Assume the first declared GuiScreen object is the "parent"
                    //Might not always work.
                    parentScreen = (GuiScreen) field.get(screen);
                    break;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        screenclazz = screenclazz.getSuperclass();
    }
    updateCursorPos();

    if (slot != null && slot.publicGetSize() > 0) {
        slotIndex = 0;
        slot.select(0, false);
        onSlot = true;
    }
}

From source file:pt.fct.di.benchmarks.TPCW_Riak.database.TPCW_Riak_Executor.java

@Override
public void start(WorkloadGeneratorInterface workload, BenchmarkNodeID nodeId, int operation_number,
        ResultHandler handler) {//from   w ww.  ja  v  a 2 s  . c  om

    global_executor_counter++;
    executor_id = global_executor_counter;
    client_result_handler = handler;

    for (int operation = 0; operation < operation_number; operation++) {
        long g_init_time = System.currentTimeMillis();

        try {
            long init_time = System.currentTimeMillis();

            Operation op = workload.getNextOperation();
            executeMethod(op);
            long end_time = System.currentTimeMillis();
            client_result_handler.logResult(op.getOperation(), (end_time - init_time));

            simulatedDelay = ThinkTime.getThinkTime();

            if (simulatedDelay > 0) {
                Thread.sleep(simulatedDelay);
            }

        } catch (NoSuchFieldException e) {
            System.out.println("[ERROR:] THIS OPERATION DOES NOT EXIST: " + e.getMessage());
            break;
        } catch (InterruptedException e) {
            System.out.println("[ERROR:] THINK TIME AFTER METHOD EXECUTION INTERRUPTED: " + e.getMessage());
            break;

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("-- Error : Client " + executor_id + " going down....");
            break;

        }
        long end_time = System.currentTimeMillis();
        counter.increment();
        client_result_handler.logResult("OPERATIONS", (end_time - g_init_time));

    }

    client_result_handler.getResulSet().put("bought", partialBought);
    client_result_handler.getResulSet().put("total_bought", bought_qty);
    client_result_handler.getResulSet().put("buying_actions", bought_actions);
    client_result_handler.getResulSet().put("bought_carts", bought_carts);
    client_result_handler.getResulSet().put("zeros", zeros);

}

From source file:cz.tsystems.portablecheckin.MainActivity.java

private void populateTextsAndRbtn(ViewGroup theView) {
    String fieldName = "";
    DMCheckin checkinData = app.getCheckin();
    for (int i = 0; i < theView.getChildCount(); i++) {
        View v = theView.getChildAt(i);
        Class<? extends View> c = v.getClass();
        fieldName = (String) v.getTag();
        if (fieldName == null)
            continue;

        Field field = null;/*from  ww  w.  ja v a 2s.c  o  m*/
        try {
            field = DMCheckin.class.getField(fieldName.toLowerCase(Locale.ENGLISH));
        } catch (NoSuchFieldException e) {
            Log.v(TAG, "NOT FOUND :" + fieldName.toLowerCase(Locale.ENGLISH));
            continue;
        }
        Log.v(TAG, fieldName.toLowerCase(Locale.ENGLISH));

        try {

            if (c == EditText.class || c == vinEditText.class || c == BaseEditText.class) {

                EditText editText = (EditText) v;
                editText.setText("");

                if (field.get(checkinData) == null)
                    continue;
                DecimalFormat nf = new DecimalFormat("#");
                if (field.getType() == String.class)// jnCheckin.hasNonNull(fieldName))
                    editText.setText((String) field.get(checkinData));
                else if (field.getType() == int.class)
                    editText.setText(String.valueOf(field.getInt(checkinData)));
                else if (field.getType() == short.class)
                    editText.setText(String.valueOf(field.getShort(checkinData)));
                else if (field.getType() == double.class)
                    editText.setText(nf.format(field.getDouble(checkinData)));
                else if (field.getType() == Double.class)
                    editText.setText(NumberFormat.getInstance().format((Double) field.get(checkinData)));
                else if (field.getType() == Date.class)
                    editText.setText(sdto.format((Date) field.get(checkinData)));

            } else if (c == Switch.class) {
                ((Switch) v).setChecked(field.getBoolean(checkinData));
            }

        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}