sun.util.logging.PlatformLogger Java Examples

The following examples show how to use sun.util.logging.PlatformLogger. 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: XErrorHandlerUtil.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Should be called under LOCK.
 */
public static int SAVED_XERROR_HANDLER(long display, XErrorEvent error) {
    if (saved_error_handler != 0) {
        // Default XErrorHandler may just terminate the process. Don't call it.
        // return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        log.fine("Unhandled XErrorEvent: " +
            "id=" + error.get_resourceid() + ", " +
            "serial=" + error.get_serial() + ", " +
            "ec=" + error.get_error_code() + ", " +
            "rc=" + error.get_request_code() + ", " +
            "mc=" + error.get_minor_code());
    }
    return 0;
}
 
Example #2
Source File: SourceClassName.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void writeLogRecords(PrintStream logps) throws Exception {
    PrintStream err = System.err;
    try {
        System.setErr(logps);

        Object[] params = new Object[] { new Long(1), "string"};
        PlatformLogger plog = PlatformLogger.getLogger("test.log.foo");
        plog.severe("Log message {0} {1}", (Object[]) params);

        // create a java.util.logging.Logger
        // now java.util.logging.Logger should be created for each platform logger
        Logger logger = Logger.getLogger("test.log.bar");
        logger.log(Level.SEVERE, "Log message {0} {1}", params);

        plog.severe("Log message {0} {1}", (Object[]) params);
    } finally {
        logps.flush();
        logps.close();
        System.setErr(err);
    }
}
 
Example #3
Source File: EventQueue.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called from dispatchEvent() under a correct AccessControlContext
 */
private void dispatchEventImpl(final AWTEvent event, final Object src) {
    event.isPosted = true;
    if (event instanceof ActiveEvent) {
        // This could become the sole method of dispatching in time.
        setCurrentEventAndMostRecentTimeImpl(event);
        ((ActiveEvent)event).dispatch();
    } else if (src instanceof Component) {
        ((Component)src).dispatchEvent(event);
        event.dispatched();
    } else if (src instanceof MenuComponent) {
        ((MenuComponent)src).dispatchEvent(event);
    } else if (src instanceof TrayIcon) {
        ((TrayIcon)src).dispatchEvent(event);
    } else if (src instanceof AWTAutoShutdown) {
        if (noEvents()) {
            dispatchThread.stopDispatching();
        }
    } else {
        if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
            eventLog.fine("Unable to dispatch event: " + event);
        }
    }
}
 
Example #4
Source File: XEmbedClientHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void install() {
    if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) {
        xembedLog.fine("Installing xembedder on " + embedded);
    }
    long[] info = new long[] { XEMBED_VERSION, XEMBED_MAPPED };
    long data = Native.card32ToData(info);
    try {
        XEmbedInfo.setAtomData(embedded.getWindow(), data, 2);
    } finally {
        unsafe.freeMemory(data);
    }
    // XEmbeddedFrame is initially created with a null parent..
    // Here it is reparented to the proper parent window.
    long parentWindow = embedded.getParentWindowHandle();
    if (parentWindow != 0) {
        XToolkit.awtLock();
        try {
            XlibWrapper.XReparentWindow(XToolkit.getDisplay(),
                                        embedded.getWindow(),
                                        parentWindow,
                                        0, 0);
        } finally {
            XToolkit.awtUnlock();
        }
    }
}
 
Example #5
Source File: PlatformLoggerTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void checkLoggerLevel(PlatformLogger logger, Level level) {
    PlatformLogger.Level plevel = PlatformLogger.Level.valueOf(level.getName());
    if (plevel != logger.level()) {
        throw new RuntimeException("Retrieved PlatformLogger level "
                + logger.level()
                + " is not the same as set level " + plevel);
    }

    // check the level set in java.util.logging.Logger
    Logger javaLogger = LogManager.getLogManager().getLogger(logger.getName());
    Level javaLevel = javaLogger.getLevel();
    if (javaLogger.getLevel() != level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + javaLevel + " is not the expected " + level);
    }
}
 
Example #6
Source File: XEmbedCanvasPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
void unregisterAccelerator(final long accel_id) {
    postEvent(new InvocationEvent(target, new Runnable() {
            public void run() {
                AWTKeyStroke stroke = null;
                synchronized(ACCEL_LOCK) {
                    stroke = accelerators.get(accel_id);
                    if (stroke != null) {
                        if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) {
                            xembedLog.fine("Unregistering accelerator: " + accel_id);
                        }
                        accelerators.remove(accel_id);
                        accel_lookup.remove(stroke); // FIXME: How about several accelerators with the same stroke?
                    }
                }
                propogateUnRegisterAccelerator(stroke);
            }
        }));
}
 
Example #7
Source File: XBaseMenuWindow.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes item at the specified index from items vector.
 * @param index the position of the item to be removed
 */
public void delItem(int index) {
    synchronized(getMenuTreeLock()) {
        if (selectedIndex == index) {
            selectItem(null, false);
        } else if (selectedIndex > index) {
            selectedIndex--;
        }
        if (index < items.size()) {
            items.remove(index);
        } else {
            if (log.isLoggable(PlatformLogger.Level.FINE)) {
                log.fine("WARNING: Attempt to remove non-existing menu item, index : " + index + ", item count : " + items.size());
            }
        }
    }
    updateSize();
}
 
Example #8
Source File: BufferStrategyPaintManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Cleans up and removes any references.
 */
public void dispose() {
    Container root = getRoot();
    if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) {
        LOGGER.finer("disposed BufferInfo for: " + root);
    }
    if (root != null) {
        root.removeComponentListener(this);
        if (root instanceof Window) {
            ((Window)root).removeWindowListener(this);
        }
        BufferStrategy bs = getBufferStrategy(false);
        if (bs != null) {
            bs.dispose();
        }
    }
    this.root = null;
    weakBS = null;
}
 
Example #9
Source File: EventQueue.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called from dispatchEvent() under a correct AccessControlContext
 */
private void dispatchEventImpl(final AWTEvent event, final Object src) {
    event.isPosted = true;
    if (event instanceof ActiveEvent) {
        // This could become the sole method of dispatching in time.
        setCurrentEventAndMostRecentTimeImpl(event);
        ((ActiveEvent)event).dispatch();
    } else if (src instanceof Component) {
        ((Component)src).dispatchEvent(event);
        event.dispatched();
    } else if (src instanceof MenuComponent) {
        ((MenuComponent)src).dispatchEvent(event);
    } else if (src instanceof TrayIcon) {
        ((TrayIcon)src).dispatchEvent(event);
    } else if (src instanceof AWTAutoShutdown) {
        if (noEvents()) {
            dispatchThread.stopDispatching();
        }
    } else {
        if (getEventLog().isLoggable(PlatformLogger.Level.FINE)) {
            getEventLog().fine("Unable to dispatch event: " + event);
        }
    }
}
 
Example #10
Source File: WComponentPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the shape to the native component window.
 * @since 1.7
 */
@Override
public void applyShape(Region shape) {
    if (shapeLog.isLoggable(PlatformLogger.Level.FINER)) {
        shapeLog.finer("*** INFO: Setting shape: PEER: " + this
                        + "; TARGET: " + target
                        + "; SHAPE: " + shape);
    }

    if (shape != null) {
        AffineTransform tx = winGraphicsConfig.getDefaultTransform();
        double scaleX = tx.getScaleX();
        double scaleY = tx.getScaleY();
        if (scaleX != 1 || scaleY != 1) {
            shape = shape.getScaledRegion(scaleX, scaleY);
        }
        setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
                (shape.isRectangular() ? null : shape));
    } else {
        setRectangularShape(0, 0, 0, 0, null);
    }
}
 
Example #11
Source File: WWindowPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    boolean isDisposed = (Boolean)e.getNewValue();
    if (isDisposed != true) {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine(" Assertion (newValue != true) failed for AppContext.GUI_DISPOSED ");
        }
    }
    AppContext appContext = AppContext.getAppContext();
    synchronized (appContext) {
        appContext.remove(ACTIVE_WINDOWS_KEY);
        appContext.removePropertyChangeListener(AppContext.GUI_DISPOSED, this);

        KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        kfm.removePropertyChangeListener("activeWindow", activeWindowListener);
    }
}
 
Example #12
Source File: XEmbedCanvasPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
void unregisterAccelerator(final long accel_id) {
    postEvent(new InvocationEvent(target, new Runnable() {
            public void run() {
                AWTKeyStroke stroke = null;
                synchronized(ACCEL_LOCK) {
                    stroke = accelerators.get(accel_id);
                    if (stroke != null) {
                        if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) {
                            xembedLog.fine("Unregistering accelerator: " + accel_id);
                        }
                        accelerators.remove(accel_id);
                        accel_lookup.remove(stroke); // FIXME: How about several accelerators with the same stroke?
                    }
                }
                propogateUnRegisterAccelerator(stroke);
            }
        }));
}
 
Example #13
Source File: HttpsClient.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 *  Same as previous constructor except using a Proxy
 */
HttpsClient(SSLSocketFactory sf, URL url, Proxy proxy,
            int connectTimeout)
    throws IOException {
    PlatformLogger logger = HttpURLConnection.getHttpLogger();
    if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
         logger.finest("Creating new HttpsClient with url:" + url + " and proxy:" + proxy +
         " with connect timeout:" + connectTimeout);
    }
    this.proxy = proxy;
    setSSLSocketFactory(sf);
    this.proxyDisabled = true;

    this.host = url.getHost();
    this.url = url;
    port = url.getPort();
    if (port == -1) {
        port = getDefaultPort();
    }
    setConnectTimeout(connectTimeout);
    openServer();
}
 
Example #14
Source File: ProxyClassesDumper.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void dumpClass(String className, final byte[] classBytes) {
    Path file;
    try {
        file = dumpDir.resolve(encodeForFilename(className) + ".class");
    } catch (InvalidPathException ex) {
        PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
                      .warning("Invalid path for class " + className);
        return;
    }

    try {
        Path dir = file.getParent();
        Files.createDirectories(dir);
        Files.write(file, classBytes);
    } catch (Exception ignore) {
        PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
                      .warning("Exception writing to path at " + file.toString());
        // simply don't care if this operation failed
    }
}
 
Example #15
Source File: ScrollPaneWheelScroller.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #16
Source File: XDecoratedPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void handleFocusEvent(XEvent xev) {
        super.handleFocusEvent(xev);
        XFocusChangeEvent xfe = xev.get_xfocus();

        // If we somehow received focus events forward it instead to proxy
        // FIXME: Shouldn't we instead check for inferrior?
        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("Received focus event on shell: " + xfe);
        }
//         focusProxy.xRequestFocus();
   }
 
Example #17
Source File: XBaseWindow.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void xRequestFocus() {
    XToolkit.awtLock();
    try {
        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()));
        }
         XlibWrapper.XSetInputFocus(XToolkit.getDisplay(), getWindow());
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example #18
Source File: XDecoratedPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleFocusEvent(XEvent xev) {
        super.handleFocusEvent(xev);
        XFocusChangeEvent xfe = xev.get_xfocus();

        // If we somehow received focus events forward it instead to proxy
        // FIXME: Shouldn't we instead check for inferrior?
        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("Received focus event on shell: " + xfe);
        }
//         focusProxy.xRequestFocus();
   }
 
Example #19
Source File: BufferStrategyPaintManager.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void endPaint() {
    if (LOGGER.isLoggable(PlatformLogger.Level.FINEST)) {
        LOGGER.finest("endPaint: region " + accumulatedX + " " +
                   accumulatedY + " " +  accumulatedMaxX + " " +
                   accumulatedMaxY);
    }
    if (painting) {
        if (!flushAccumulatedRegion()) {
            if (!isRepaintingRoot()) {
                repaintRoot(rootJ);
            }
            else {
                // Contents lost twice in a row, punt.
                resetDoubleBufferPerWindow();
                // In case we've left junk on the screen, force a repaint.
                rootJ.repaint();
            }
        }
    }

    BufferInfo toDispose = null;
    synchronized(this) {
        painting = false;
        if (disposeBufferOnEnd) {
            disposeBufferOnEnd = false;
            toDispose = bufferInfo;
            bufferInfos.remove(toDispose);
        }
    }
    if (toDispose != null) {
        toDispose.dispose();
    }
}
 
Example #20
Source File: XKeyboardFocusManagerPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setCurrentFocusedWindow(Window win) {
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer("Setting current focused window " + win);
    }

    XWindowPeer from = null, to = null;

    synchronized(this) {
        if (currentFocusedWindow != null) {
            from = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(currentFocusedWindow);
        }

        currentFocusedWindow = win;

        if (currentFocusedWindow != null) {
            to = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(currentFocusedWindow);
        }
    }

    if (from != null) {
        from.updateSecurityWarningVisibility();
    }
    if (to != null) {
        to.updateSecurityWarningVisibility();
    }
}
 
Example #21
Source File: XEmbedHelper.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
XEmbedHelper() {
    if (XEmbed == null) {
        XEmbed = XAtom.get("_XEMBED");
        if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) {
            xembedLog.finer("Created atom " + XEmbed.toString());
        }
    }
    if (XEmbedInfo == null) {
        XEmbedInfo = XAtom.get("_XEMBED_INFO");
        if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) {
            xembedLog.finer("Created atom " + XEmbedInfo.toString());
        }
    }
}
 
Example #22
Source File: Container.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
@Override
void mixOnHiding(boolean isLightweight) {
    synchronized (getTreeLock()) {
        if (mixingLog.isLoggable(PlatformLogger.FINE)) {
            mixingLog.fine("this = " + this +
                    "; isLightweight=" + isLightweight);
        }
        if (isLightweight) {
            recursiveHideHeavyweightChildren();
        }
        super.mixOnHiding(isLightweight);
    }
}
 
Example #23
Source File: AttributeValue.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected AttributeValue(int value, String[] names) {
    if (log.isLoggable(PlatformLogger.Level.FINEST)) {
        log.finest("value = " + value + ", names = " + names);
    }

    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        if ((value < 0) || (names == null) || (value >= names.length)) {
            log.finer("Assertion failed");
        }
    }
    this.value = value;
    this.names = names;
}
 
Example #24
Source File: XCheckboxPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void mouseEntered(MouseEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("mouseEntered() on " + target.getName() + ": armed = " + armed + ", pressed = " + pressed
                  + ", selected = " + selected + ", enabled = " + isEnabled());
    }
    if (pressed) {
        armed = true;
        repaint();
    }
}
 
Example #25
Source File: WDesktopProperties.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void setStringProperty(String key, String value) {
    assert( key != null );
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        log.fine(key + "=" + value);
    }
    map.put(key, value);
}
 
Example #26
Source File: XMenuPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void delItem(int index) {
    XMenuWindow menuWindow = getMenuWindow();
    if (menuWindow != null) {
        menuWindow.delItem(index);
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Attempt to use XMenuWindowPeer without window");
        }
    }
}
 
Example #27
Source File: XEmbedCanvasPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void endDispatching() {
    if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) {
        xembedLog.fine("End dispatching for " + Long.toHexString(xembed.handle));
    }
    XToolkit.awtLock();
    try {
        XDropTargetRegistry.getRegistry().unregisterXEmbedClient(getWindow(), xembed.handle);
        // We can't deselect input since someone else might be interested in it
        XToolkit.removeEventDispatcher(xembed.handle, xembed);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example #28
Source File: XWINProtocol.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void setLayer(XWindowPeer window, int layer) {
    if (window.isShowing()) {
        XClientMessageEvent req = new XClientMessageEvent();
        req.set_type(XConstants.ClientMessage);
        req.set_window(window.getWindow());
        req.set_message_type(XA_WIN_LAYER.getAtom());
        req.set_format(32);
        req.set_data(0, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
        req.set_data(1, 0);
        req.set_data(2, 0);
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Setting layer " + layer + " by root message : " + req);
        }
        XToolkit.awtLock();
        try {
            XlibWrapper.XSendEvent(XToolkit.getDisplay(),
                    XlibWrapper.RootWindow(XToolkit.getDisplay(),
                        window.getScreenNumber()),
                    false,
                    /*XConstants.SubstructureRedirectMask | */XConstants.SubstructureNotifyMask,
                    req.pData);
        }
        finally {
            XToolkit.awtUnlock();
        }
        req.dispose();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Setting layer property to " + layer);
        }
        XA_WIN_LAYER.setCard32Property(window, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
    }
}
 
Example #29
Source File: XIconWindow.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets icon image by selecting one of the images from the list.
 * The selected image is the one having the best matching size.
 */
void setIconImages(java.util.List<IconInfo> icons) {
    if (icons == null || icons.size() == 0) return;

    int minDiff = Integer.MAX_VALUE;
    Image min = null;
    for (IconInfo iconInfo : icons) {
        if (iconInfo.isValid()) {
            Image image = iconInfo.getImage();
            Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
            int widthDiff = Math.abs(dim.width - image.getWidth(null));
            int heightDiff = Math.abs(image.getHeight(null) - dim.height);

            // "=" below allows to select the best matching icon
            if (minDiff >= (widthDiff + heightDiff)) {
                minDiff = (widthDiff + heightDiff);
                min = image;
            }
        }
    }
    if (min != null) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null));
        }
        setIconImage(min);
    }
}
 
Example #30
Source File: BufferStrategyPaintManager.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void endPaint() {
    if (LOGGER.isLoggable(PlatformLogger.Level.FINEST)) {
        LOGGER.finest("endPaint: region " + accumulatedX + " " +
                   accumulatedY + " " +  accumulatedMaxX + " " +
                   accumulatedMaxY);
    }
    if (painting) {
        if (!flushAccumulatedRegion()) {
            if (!isRepaintingRoot()) {
                repaintRoot(rootJ);
            }
            else {
                // Contents lost twice in a row, punt.
                resetDoubleBufferPerWindow();
                // In case we've left junk on the screen, force a repaint.
                rootJ.repaint();
            }
        }
    }

    BufferInfo toDispose = null;
    synchronized(this) {
        painting = false;
        if (disposeBufferOnEnd) {
            disposeBufferOnEnd = false;
            toDispose = bufferInfo;
            bufferInfos.remove(toDispose);
        }
    }
    if (toDispose != null) {
        toDispose.dispose();
    }
}