Java Code Examples for java.lang.reflect.InvocationTargetException#printStackTrace()

The following examples show how to use java.lang.reflect.InvocationTargetException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDialogTypeAhead.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void waitForIdle() {
    try {
        Toolkit.getDefaultToolkit().sync();
        sun.awt.SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 2
Source File: AIO.java    From Explvs-AIO with MIT License 6 votes vote down vote up
/**
 * Load the task list from the GUI
 *
 * @throws InterruptedException
 */
private List<Task> loadTasksFromGUI() throws InterruptedException {
    try {
        EventDispatchThreadRunner.runOnDispatchThread(() -> {
            gui = new Gui();
            gui.open();
        }, true);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        log("Failed to create GUI");
        return Collections.emptyList();
    }

    if (!gui.isStarted()) {
        return Collections.emptyList();
    }

    return gui.getTasksAsList();
}
 
Example 3
Source File: TestDialogTypeAhead.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void waitForIdle() {
    try {
        Toolkit.getDefaultToolkit().sync();
        sun.awt.SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 4
Source File: Robot.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 5
Source File: TestDialogTypeAhead.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void waitForIdle() {
    try {
        Toolkit.getDefaultToolkit().sync();
        sun.awt.SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 6
Source File: CInputMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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; }
}
 
Example 7
Source File: CPlatformWindow.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 8
Source File: OverlappingTestBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void testAwtControls() throws InterruptedException {
    try {
        for (Component component : getAWTControls()) {
            testComponent(component);
        }
        if (testEmbeddedFrame && !skipTestingEmbeddedFrame) {
            testEmbeddedFrame();
        }
    } catch (InvocationTargetException ex) {
        ex.printStackTrace();
        fail(ex.getMessage());
    }
}
 
Example 9
Source File: ManyMethodsBenchmarkApp.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 10
Source File: PercentLayoutHelper.java    From FimiX8-RE with MIT License 5 votes vote down vote up
private void supportMinOrMaxDimesion(int widthHint, int heightHint, View view, PercentLayoutInfo info) {
    try {
        Class clazz = view.getClass();
        invokeMethod("setMaxWidth", widthHint, heightHint, view, clazz, info.maxWidthPercent);
        invokeMethod("setMaxHeight", widthHint, heightHint, view, clazz, info.maxHeightPercent);
        invokeMethod("setMinWidth", widthHint, heightHint, view, clazz, info.minWidthPercent);
        invokeMethod("setMinHeight", widthHint, heightHint, view, clazz, info.minHeightPercent);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e2) {
        e2.printStackTrace();
    } catch (IllegalAccessException e3) {
        e3.printStackTrace();
    }
}
 
Example 11
Source File: Equals.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an InterfaceAddress instance with its fields set the the values
 * specificed.
 */
static InterfaceAddress createInterfaceAddress(
            InetAddress address, InetAddress broadcast, short prefixlength) {
    try {
        Class<InterfaceAddress> IAClass = InterfaceAddress.class;
        InterfaceAddress ia;
        Constructor<InterfaceAddress> ctr = IAClass.getDeclaredConstructor();
        ctr.setAccessible(true);

        Field addressField = IAClass.getDeclaredField("address");
        addressField.setAccessible(true);

        Field broadcastField = IAClass.getDeclaredField("broadcast");
        broadcastField.setAccessible(true);

        Field maskLengthField = IAClass.getDeclaredField("maskLength");
        maskLengthField.setAccessible(true);

        ia = ctr.newInstance();
        addressField.set(ia, address);
        broadcastField.set(ia, broadcast);
        maskLengthField.setShort(ia, prefixlength);

        return ia;
    } catch (NoSuchFieldException nsfe) {
        nsfe.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InstantiationException ie) {
        ie.printStackTrace();
    } catch (IllegalAccessException iae) {
        iae.printStackTrace();
    } catch (InvocationTargetException ite) {
        ite.printStackTrace();
    }

    return null;
}
 
Example 12
Source File: CPlatformWindow.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 13
Source File: RefectUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static Object invoke(Object o, Method m, Object... objects) {
    m.setAccessible(true);

    try {
        return m.invoke(o, objects);
    } catch (IllegalAccessException var4) {
        var4.printStackTrace();
    } catch (InvocationTargetException var5) {
        var5.printStackTrace();
    }

    return null;
}
 
Example 14
Source File: BungeePipelineUtil.java    From ViaVersion with MIT License 5 votes vote down vote up
public static ByteBuf decompress(ChannelHandlerContext ctx, ByteBuf bytebuf) {
    try {
        return (ByteBuf) callDecode((MessageToMessageDecoder) ctx.pipeline().get("decompress"), ctx.pipeline().context("decompress"), bytebuf).get(0);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        return ctx.alloc().buffer();
    }
}
 
Example 15
Source File: StructureCUI.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
private void sendOp() {
    Player player = this.<Player>getPlayer().parent;
    ProtocolManager manager = ProtocolLibrary.getProtocolManager();

    PacketConstructor statusCtr = manager.createPacketConstructor(PacketType.Play.Server.ENTITY_STATUS, player, (byte) 28);
    PacketContainer status = statusCtr.createPacket(player, (byte) 28);

    try {
        manager.sendServerPacket(player, status);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
Example 16
Source File: CInputMethod.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
    * Cocoa assumes the marked text and committed text is all stored in the same storage, but
 * Java does not.  So, we have to see where the request is and based on that return the right
 * substring.
 */
synchronized private String attributedSubstringFromRange(final int locationIn, final int lengthIn) {
    final String[] retString = new String[1];

    try {
        LWCToolkit.invokeAndWait(new Runnable() {
            public void run() { synchronized(retString) {
                int location = locationIn;
                int length = lengthIn;

                if ((location + length) > (fIMContext.getCommittedTextLength() + fCurrentTextLength)) {
                    length = fIMContext.getCommittedTextLength() - location;
                }

                AttributedCharacterIterator theIterator = null;

                if (fCurrentText == null) {
                    theIterator = fIMContext.getCommittedText(location, location + length, null);
                } else {
                    int insertSpot = fIMContext.getInsertPositionOffset();

                    if (location < insertSpot) {
                        theIterator = fIMContext.getCommittedText(location, location + length, null);
                    } else if (location >= insertSpot && location < insertSpot + fCurrentTextLength) {
                        theIterator = fCurrentText.getIterator(null, location - insertSpot, location - insertSpot +length);
                    } else  {
                        theIterator = fIMContext.getCommittedText(location - fCurrentTextLength, location - fCurrentTextLength + length, null);
                    }
                }

                // Get the characters from the iterator
                char selectedText[] = new char[theIterator.getEndIndex() - theIterator.getBeginIndex()];
                char current = theIterator.first();
                int index = 0;
                while (current != CharacterIterator.DONE) {
                    selectedText[index++] = current;
                    current = theIterator.next();
                }

                retString[0] = new String(selectedText);
            }}
        }, fAwtFocussedComponent);
    } catch (InvocationTargetException ite) { ite.printStackTrace(); }

    synchronized(retString) { return retString[0]; }
}
 
Example 17
Source File: CInputMethod.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
    * Cocoa assumes the marked text and committed text is all stored in the same storage, but
 * Java does not.  So, we have to see where the request is and based on that return the right
 * substring.
 */
private synchronized String attributedSubstringFromRange(final int locationIn, final int lengthIn) {
    final String[] retString = new String[1];

    try {
        LWCToolkit.invokeAndWait(new Runnable() {
            public void run() { synchronized(retString) {
                int location = locationIn;
                int length = lengthIn;

                if ((location + length) > (fIMContext.getCommittedTextLength() + fCurrentTextLength)) {
                    length = fIMContext.getCommittedTextLength() - location;
                }

                AttributedCharacterIterator theIterator = null;

                if (fCurrentText == null) {
                    theIterator = fIMContext.getCommittedText(location, location + length, null);
                } else {
                    int insertSpot = fIMContext.getInsertPositionOffset();

                    if (location < insertSpot) {
                        theIterator = fIMContext.getCommittedText(location, location + length, null);
                    } else if (location >= insertSpot && location < insertSpot + fCurrentTextLength) {
                        theIterator = fCurrentText.getIterator(null, location - insertSpot, location - insertSpot +length);
                    } else  {
                        theIterator = fIMContext.getCommittedText(location - fCurrentTextLength, location - fCurrentTextLength + length, null);
                    }
                }

                // Get the characters from the iterator
                char selectedText[] = new char[theIterator.getEndIndex() - theIterator.getBeginIndex()];
                char current = theIterator.first();
                int index = 0;
                while (current != CharacterIterator.DONE) {
                    selectedText[index++] = current;
                    current = theIterator.next();
                }

                retString[0] = new String(selectedText);
            }}
        }, fAwtFocussedComponent);
    } catch (InvocationTargetException ite) { ite.printStackTrace(); }

    synchronized(retString) { return retString[0]; }
}
 
Example 18
Source File: CInputMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
    * Cocoa assumes the marked text and committed text is all stored in the same storage, but
 * Java does not.  So, we have to see where the request is and based on that return the right
 * substring.
 */
synchronized private String attributedSubstringFromRange(final int locationIn, final int lengthIn) {
    final String[] retString = new String[1];

    try {
        LWCToolkit.invokeAndWait(new Runnable() {
            public void run() { synchronized(retString) {
                int location = locationIn;
                int length = lengthIn;

                if ((location + length) > (fIMContext.getCommittedTextLength() + fCurrentTextLength)) {
                    length = fIMContext.getCommittedTextLength() - location;
                }

                AttributedCharacterIterator theIterator = null;

                if (fCurrentText == null) {
                    theIterator = fIMContext.getCommittedText(location, location + length, null);
                } else {
                    int insertSpot = fIMContext.getInsertPositionOffset();

                    if (location < insertSpot) {
                        theIterator = fIMContext.getCommittedText(location, location + length, null);
                    } else if (location >= insertSpot && location < insertSpot + fCurrentTextLength) {
                        theIterator = fCurrentText.getIterator(null, location - insertSpot, location - insertSpot +length);
                    } else  {
                        theIterator = fIMContext.getCommittedText(location - fCurrentTextLength, location - fCurrentTextLength + length, null);
                    }
                }

                // Get the characters from the iterator
                char selectedText[] = new char[theIterator.getEndIndex() - theIterator.getBeginIndex()];
                char current = theIterator.first();
                int index = 0;
                while (current != CharacterIterator.DONE) {
                    selectedText[index++] = current;
                    current = theIterator.next();
                }

                retString[0] = new String(selectedText);
            }}
        }, fAwtFocussedComponent);
    } catch (InvocationTargetException ite) { ite.printStackTrace(); }

    synchronized(retString) { return retString[0]; }
}
 
Example 19
Source File: CAccessibility.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void invokeLater(final Runnable runnable, final Component c) {
    try {
        LWCToolkit.invokeLater(runnable, c);
    } catch (InvocationTargetException e) { e.printStackTrace(); }
}
 
Example 20
Source File: CAccessibility.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static void invokeLater(final Runnable runnable, final Component c) {
    try {
        LWCToolkit.invokeLater(runnable, c);
    } catch (InvocationTargetException e) { e.printStackTrace(); }
}