當前位置: 首頁>>代碼示例>>Java>>正文


Java InvocationTargetException.printStackTrace方法代碼示例

本文整理匯總了Java中java.lang.reflect.InvocationTargetException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java InvocationTargetException.printStackTrace方法的具體用法?Java InvocationTargetException.printStackTrace怎麽用?Java InvocationTargetException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.InvocationTargetException的用法示例。


在下文中一共展示了InvocationTargetException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: markedRange

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
/**
 * Cocoa wants the range of characters that are currently marked.  Since Java doesn't store committed and
 * text in progress (composed text) together, we have to synthesize it.  We know where the text will be
 * inserted, so we can return that position, and the length of the text in progress.  If there is no marked text
 * return null.
 */
synchronized private int[] markedRange() {
    if (fCurrentText == null)
        return null;

    final int[] returnValue = new int[2];

    try {
        LWCToolkit.invokeAndWait(new Runnable() {
            public void run() { synchronized(returnValue) {
                // The insert position is always after the composed text, so the range start is the
                // insert spot less the length of the composed text.
                returnValue[0] = fIMContext.getInsertPositionOffset();
            }}
        }, fAwtFocussedComponent);
    } catch (InvocationTargetException ite) { ite.printStackTrace(); }

    returnValue[1] = fCurrentTextLength;
    synchronized(returnValue) { return returnValue; }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:CInputMethod.java

示例2: invoke

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
protected static boolean invoke(Method method, Object obj, Object... args) {
    if (method != null) {
        try {
            method.invoke(obj, args);
            return true;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e2) {
            e2.printStackTrace();
        } catch (InvocationTargetException e3) {
            e3.printStackTrace();
        }
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:16,代碼來源:Proxy.java

示例3: sendKeepAlive

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
public static void sendKeepAlive(List<Player> player) {
	for (Player p : player) {
		try {
			PacketContainer packet = get().createPacket(PacketType.Play.Client.KEEP_ALIVE);
			packet.getIntegers().write(0, random.nextInt());
			get().sendServerPacket(p, packet);
		} catch (InvocationTargetException ex) {
			ex.printStackTrace();
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:12,代碼來源:ProtocolUtils.java

示例4: sendTabListAddPacket

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
@Override
public void sendTabListAddPacket(Player playerToAdd, GameProfileWrapper newProfile, Player seer) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
    int ping = (int) ReflectUtil.getFieldValue(ReflectUtil.invokeMethod(playerToAdd, GET_HANDLE).getOrThrow(), PING).getOrThrow();
    packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
    PlayerInfoData playerInfoData = new PlayerInfoData(getProtocolLibProfileWrapper(newProfile), ping, EnumWrappers.NativeGameMode.fromBukkit(playerToAdd.getGameMode()), WrappedChatComponent.fromText(playerToAdd.getPlayerListName()));
    packet.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, packet);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Alvin-LB,項目名稱:NameTagChanger,代碼行數:14,代碼來源:ProtocolLibPacketHandler.java

示例5: trySend

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
public static boolean trySend(PacketContainer packet, Player destination, Level importance, boolean filters) {
    if (destination == null) return false;
    try {
        manager.sendServerPacket(destination, packet, filters);
        return true;
    } catch (InvocationTargetException e) {
        errorLogger.log(importance, "Failed to send packet of type " + packet.getType().name() + " to player " +
                destination.getName() + "!");
        e.printStackTrace();
    }
    return false;
}
 
開發者ID:iso2013,項目名稱:MultiLineAPI,代碼行數:13,代碼來源:PacketUtil.java

示例6: flushBuffers

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
void flushBuffers() {
    if (isVisible() && !nativeBounds.isEmpty() && !isFullScreenMode) {
        try {
            LWCToolkit.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    //Posting an empty to flush the EventQueue without blocking the main thread
                }
            }, target);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:CPlatformWindow.java

示例7: sendScoreboardRemovePacket

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
@Override
public void sendScoreboardRemovePacket(String playerToRemove, Player seer, String team) {
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, getScoreboardPacket(team, playerToRemove, LEAVE_SCOREBOARD_TEAM_MODE));
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Alvin-LB,項目名稱:NameTagChanger,代碼行數:9,代碼來源:ProtocolLibPacketHandler.java

示例8: characterIndexForPoint

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
synchronized private int characterIndexForPoint(final int screenX, final int screenY) {
    final TextHitInfo[] offsetInfo = new TextHitInfo[1];
    final int[] insertPositionOffset = new int[1];

    try {
        LWCToolkit.invokeAndWait(new Runnable() {
            public void run() { synchronized(offsetInfo) {
                offsetInfo[0] = fIMContext.getLocationOffset(screenX, screenY);
                insertPositionOffset[0] = fIMContext.getInsertPositionOffset();
            }}
        }, fAwtFocussedComponent);
    } catch (InvocationTargetException ite) { ite.printStackTrace(); }

    // This bit of gymnastics ensures that the returned location is within the composed text.
    // If it falls outside that region, the input method will commit the text, which is inconsistent with native
    // Cocoa apps (see TextEdit, for example.)  Clicking to the left of or above the selected text moves the
    // cursor to the start of the composed text, and to the right or below moves it to one character before the end.
    if (offsetInfo[0] == null) {
        return insertPositionOffset[0];
    }

    int returnValue = offsetInfo[0].getCharIndex() + insertPositionOffset[0];

    if (offsetInfo[0].getCharIndex() == fCurrentTextLength)
        returnValue --;

    return returnValue;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:29,代碼來源:CInputMethod.java

示例9: benchmarkClassOperations

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
static void benchmarkClassOperations(String className) throws Exception {
    Class<?> klazz = loadClassInNewClassLoader(className);

    Method[] methods = klazz.getDeclaredMethods();
    if (methods.length != METHOD_COUNT) {
        throw new AssertionError("unexpected method count: " + methods.length +
                                 " expected: " + METHOD_COUNT);
    }

    methods = klazz.getMethods();
    // returned methods includes those inherited from Object
    int objectMethodSlop = 100;
    if (methods.length <= METHOD_COUNT ||
        methods.length >= METHOD_COUNT + objectMethodSlop) {
        throw new AssertionError("unexpected method count: " + methods.length);
    }

    // Invoke methods to make them appear in the constant pool cache
    Object obj = klazz.newInstance();
    Object[] args = new Object[0];
    for (Method m: methods) {
        try {
            Class<?>[] types = m.getParameterTypes();
            String     name  = m.getName();
         // System.out.println("method: " + name + "; argno: " + types.length);
            if (types.length == 0 && name.length() == 2 && name.startsWith("f")) {
                m.invoke(obj, args);
            }
        } catch (InvocationTargetException ex) {
            ex.printStackTrace();
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:34,代碼來源:ManyMethodsBenchmarkApp.java

示例10: invokeAndWait

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
public static void invokeAndWait(final Runnable runnable) throws InterruptedException {
    try {
        EventQueue.invokeAndWait(runnable);
    } catch (InvocationTargetException e) {
        e.printStackTrace(); //?
    }
}
 
開發者ID:addertheblack,項目名稱:myster,代碼行數:8,代碼來源:Util.java

示例11: characterIndexForPoint

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
private synchronized int characterIndexForPoint(final int screenX, final int screenY) {
    final TextHitInfo[] offsetInfo = new TextHitInfo[1];
    final int[] insertPositionOffset = new int[1];

    try {
        LWCToolkit.invokeAndWait(new Runnable() {
            public void run() { synchronized(offsetInfo) {
                offsetInfo[0] = fIMContext.getLocationOffset(screenX, screenY);
                insertPositionOffset[0] = fIMContext.getInsertPositionOffset();
            }}
        }, fAwtFocussedComponent);
    } catch (InvocationTargetException ite) { ite.printStackTrace(); }

    // This bit of gymnastics ensures that the returned location is within the composed text.
    // If it falls outside that region, the input method will commit the text, which is inconsistent with native
    // Cocoa apps (see TextEdit, for example.)  Clicking to the left of or above the selected text moves the
    // cursor to the start of the composed text, and to the right or below moves it to one character before the end.
    if (offsetInfo[0] == null) {
        return insertPositionOffset[0];
    }

    int returnValue = offsetInfo[0].getCharIndex() + insertPositionOffset[0];

    if (offsetInfo[0].getCharIndex() == fCurrentTextLength)
        returnValue --;

    return returnValue;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:CInputMethod.java

示例12: testAwtControls

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
private void testAwtControls() throws InterruptedException {
    try {
        for (Component component : getAWTControls()) {
            testComponent(component);
        }
        if (testEmbeddedFrame && !skipTestingEmbeddedFrame) {
            testEmbeddedFrame();
        }
    } catch (InvocationTargetException ex) {
        ex.printStackTrace();
        fail(ex.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:OverlappingTestBase.java

示例13: actionPerformed

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
@Override
            public void actionPerformed(ActionEvent e) {
//                    System.out.println(e);
                try {
                    float x = Float.parseFloat(tfx.getText());
                    float y = Float.parseFloat(tfy.getText());
                    point.setLocation(x, y);
                    writeMethod.invoke(filter, point);
                    point = (Point2D.Float) readMethod.invoke(filter); // getString the value from the getter method to constrain it
                    set(point);
                } catch (NumberFormatException fe) {
                    tfx.selectAll();
                    tfy.selectAll();
                } catch (InvocationTargetException ite) {
                    ite.printStackTrace();
                } catch (IllegalAccessException iae) {
                    iae.printStackTrace();
                }
            }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:20,代碼來源:ControlPanel.java

示例14: buildInterfaceList

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
/**
	 * Explicitly searches all interface types to build a list of available hardware interfaces. This method is
	 * expensive.  The list should only includes devices that are not already opened.
	 *
	 * @see #getNumInterfacesAvailable()
	 */
	synchronized public void buildInterfaceList() {
		interfaceList.clear();
		HardwareInterface u;
		// System.out.println("****** HardwareInterfaceFactory.building interface list");

		for (final Class factorie : HardwareInterfaceFactory.factories) {
			try {
				final Method m = ((factorie).getMethod("instance")); // get singleton instance of factory
				final HardwareInterfaceFactoryInterface inst = (HardwareInterfaceFactoryInterface) m.invoke(factorie);
				final int num = inst.getNumInterfacesAvailable(); // ask it how many devices are out there

//				 if(num>0) System.out.println("interface "+inst+" has "+num+" devices available"); // TODO comment
				for (int j = 0; j < num; j++) {
					u = inst.getInterface(j); // for each one, construct the HardwareInterface and put it in a list

					if (u == null) {
						continue;
					}

					interfaceList.add(u);
					// System.out.println("HardwareInterfaceFactory.buildInterfaceList: added "+u);// TODO comment
				}
			}
			catch (final NoSuchMethodException e) {
				HardwareInterfaceFactory.log.warning(factorie
					+ " has no instance() method but it needs to be a singleton of this form");
				e.printStackTrace();
			}
			catch (final IllegalAccessException e3) {
				e3.printStackTrace();
			}
			catch (final InvocationTargetException e4) {
				e4.printStackTrace();
			}
			catch (final HardwareInterfaceException e5) {
				e5.printStackTrace();
			}
		}
	}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:46,代碼來源:HardwareInterfaceFactory.java

示例15: getProperty

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
public static Object getProperty(Object o, String name) {
    String getter = "get" + capitalize(name);
    String isGetter = "is" + capitalize(name);

    try {
        Method methods[] = findMethods(o.getClass());
        Method getPropertyMethod = null;

        // First, the ideal case - a getFoo() method
        for (int i = 0; i < methods.length; i++) {
            Class paramT[] = methods[i].getParameterTypes();
            if (getter.equals(methods[i].getName()) && paramT.length == 0) {
                return methods[i].invoke(o, (Object[]) null);
            }
            if (isGetter.equals(methods[i].getName()) && paramT.length == 0) {
                return methods[i].invoke(o, (Object[]) null);
            }

            if ("getProperty".equals(methods[i].getName())) {
                getPropertyMethod = methods[i];
            }
        }

        // Ok, no setXXX found, try a getProperty("name")
        if (getPropertyMethod != null) {
            Object params[] = new Object[1];
            params[0] = name;
            return getPropertyMethod.invoke(o, params);
        }

    } catch (IllegalArgumentException ex2) {
        log.warn("IAE " + o + " " + name, ex2);
    } catch (SecurityException ex1) {
        if (dbg > 0)
            d("SecurityException for " + o.getClass() + " " + name + ")");
        if (dbg > 1)
            ex1.printStackTrace();
    } catch (IllegalAccessException iae) {
        if (dbg > 0)
            d("IllegalAccessException for " + o.getClass() + " " + name
                    + ")");
        if (dbg > 1)
            iae.printStackTrace();
    } catch (InvocationTargetException ie) {
        if (dbg > 0)
            d("InvocationTargetException for " + o.getClass() + " " + name
                    + ")");
        if (dbg > 1)
            ie.printStackTrace();
    }
    return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:53,代碼來源:IntrospectionUtils.java


注:本文中的java.lang.reflect.InvocationTargetException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。