当前位置: 首页>>代码示例>>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;未经允许,请勿转载。