diff options
Diffstat (limited to 'src')
55 files changed, 582 insertions, 295 deletions
diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index e0e07f0d2..86b65a00f 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -538,9 +538,9 @@ public final class LWCToolkit extends LWToolkit { return super.getImage(filename); } - String fileneame2x = getScaledImageName(filename); - return (imageExists(fileneame2x)) - ? getImageWithResolutionVariant(filename, fileneame2x) + String filename2x = getScaledImageName(filename); + return (imageExists(filename2x)) + ? getImageWithResolutionVariant(filename, filename2x) : super.getImage(filename); } @@ -891,6 +891,9 @@ public final class LWCToolkit extends LWToolkit { } private static boolean isValidPath(String path) { - return !path.isEmpty() && !path.endsWith("/") && !path.endsWith("."); + return path != null && + !path.isEmpty() && + !path.endsWith("/") && + !path.endsWith("."); } } diff --git a/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java index 8d3db2230..725697054 100644 --- a/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java +++ b/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java @@ -1254,8 +1254,11 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { if (name.equals("IHDR")) { IHDR_width = getIntAttribute(node, "width"); IHDR_height = getIntAttribute(node, "height"); - IHDR_bitDepth = getEnumeratedAttribute(node, "bitDepth", - IHDR_bitDepths); + IHDR_bitDepth = + Integer.valueOf(IHDR_bitDepths[ + getEnumeratedAttribute(node, + "bitDepth", + IHDR_bitDepths)]); IHDR_colorType = getEnumeratedAttribute(node, "colorType", IHDR_colorTypeNames); IHDR_compressionMethod = diff --git a/src/share/classes/com/sun/java/swing/SwingUtilities3.java b/src/share/classes/com/sun/java/swing/SwingUtilities3.java index 1ca240dd7..b50fb2ae1 100644 --- a/src/share/classes/com/sun/java/swing/SwingUtilities3.java +++ b/src/share/classes/com/sun/java/swing/SwingUtilities3.java @@ -27,6 +27,8 @@ package com.sun.java.swing; import sun.awt.EventQueueDelegate; import sun.awt.AppContext; +import sun.awt.SunToolkit; + import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; @@ -117,8 +119,8 @@ public class SwingUtilities3 { public static RepaintManager getDelegateRepaintManager(Component component) { RepaintManager delegate = null; - if (Boolean.TRUE == AppContext.getAppContext().get( - DELEGATE_REPAINT_MANAGER_KEY)) { + if (Boolean.TRUE == SunToolkit.targetToAppContext(component) + .get(DELEGATE_REPAINT_MANAGER_KEY)) { while (delegate == null && component != null) { while (component != null && ! (component instanceof JComponent)) { diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java b/src/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java index 8fec402dc..70edf604d 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -130,11 +130,14 @@ class AnimationController implements ActionListener, PropertyChangeListener { //one second seems plausible value duration = 1000; } else { - duration = XPStyle.getXP().getThemeTransitionDuration( - c, part, - normalizeState(oldState), - normalizeState(newState), - Prop.TRANSITIONDURATIONS); + XPStyle xp = XPStyle.getXP(); + duration = (xp != null) + ? xp.getThemeTransitionDuration( + c, part, + normalizeState(oldState), + normalizeState(newState), + Prop.TRANSITIONDURATIONS) + : 1000; } controller.startAnimation(c, part, oldState, newState, duration); } diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java index 2656d1de6..d708d00a4 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import java.awt.*; import static com.sun.java.swing.plaf.windows.TMSchema.Part; import static com.sun.java.swing.plaf.windows.TMSchema.State; import static com.sun.java.swing.plaf.windows.XPStyle.Skin; + import sun.swing.DefaultLookup; import sun.swing.StringUIClientPropertyKey; @@ -231,6 +232,9 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { private void paintXPComboBoxBackground(Graphics g, JComponent c) { XPStyle xp = XPStyle.getXP(); + if (xp == null) { + return; + } State state = getXPComboBoxState(c); Skin skin = null; if (! comboBox.isEditable() @@ -400,17 +404,18 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { * @return a button which represents the popup control */ protected JButton createArrowButton() { - if (XPStyle.getXP() != null) { - return new XPComboBoxButton(); + XPStyle xp = XPStyle.getXP(); + if (xp != null) { + return new XPComboBoxButton(xp); } else { return super.createArrowButton(); } } private class XPComboBoxButton extends XPStyle.GlyphButton { - public XPComboBoxButton() { + public XPComboBoxButton(XPStyle xp) { super(null, - (! XPStyle.getXP().isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) + (! xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) ? Part.CP_DROPDOWNBUTTON : (comboBox.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) ? Part.CP_DROPDOWNBUTTONLEFT @@ -423,10 +428,11 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { protected State getState() { State rv; rv = super.getState(); + XPStyle xp = XPStyle.getXP(); if (rv != State.DISABLED && comboBox != null && ! comboBox.isEditable() - && XPStyle.getXP().isSkinDefined(comboBox, - Part.CP_DROPDOWNBUTTONRIGHT)) { + && xp != null && xp.isSkinDefined(comboBox, + Part.CP_DROPDOWNBUTTONRIGHT)) { /* * for non editable ComboBoxes Vista seems to have the * same glyph for all non DISABLED states diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java index 63eb27b9b..8e168066d 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,6 +125,9 @@ public class WindowsGraphicsUtils { static void paintXPText(AbstractButton b, Part part, State state, Graphics g, int x, int y, String text, int mnemIndex) { XPStyle xp = XPStyle.getXP(); + if (xp == null) { + return; + } Color textColor = b.getForeground(); if (textColor instanceof UIResource) { diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java index 3bc26eb46..90bdc9293 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java @@ -613,8 +613,8 @@ public class WindowsIconFactory implements Serializable private static class MenuArrowIcon implements Icon, UIResource, Serializable { public void paintIcon(Component c, Graphics g, int x, int y) { - if (WindowsMenuItemUI.isVistaPainting()) { - XPStyle xp = XPStyle.getXP(); + XPStyle xp = XPStyle.getXP(); + if (WindowsMenuItemUI.isVistaPainting(xp)) { State state = State.NORMAL; if (c instanceof JMenuItem) { state = ((JMenuItem) c).getModel().isEnabled() @@ -647,16 +647,18 @@ public class WindowsIconFactory implements Serializable } } public int getIconWidth() { - if (WindowsMenuItemUI.isVistaPainting()) { - Skin skin = XPStyle.getXP().getSkin(null, Part.MP_POPUPSUBMENU); + XPStyle xp = XPStyle.getXP(); + if (WindowsMenuItemUI.isVistaPainting(xp)) { + Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU); return skin.getWidth(); } else { return 4; } } public int getIconHeight() { - if (WindowsMenuItemUI.isVistaPainting()) { - Skin skin = XPStyle.getXP().getSkin(null, Part.MP_POPUPSUBMENU); + XPStyle xp = XPStyle.getXP(); + if (WindowsMenuItemUI.isVistaPainting(xp)) { + Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU); return skin.getHeight(); } else { return 8; @@ -682,7 +684,8 @@ public class WindowsIconFactory implements Serializable } static int getIconWidth() { - return XPStyle.getXP().getSkin(null, Part.MP_POPUPCHECK).getWidth() + XPStyle xp = XPStyle.getXP(); + return ((xp != null) ? xp.getSkin(null, Part.MP_POPUPCHECK).getWidth() : 16) + 2 * OFFSET; } @@ -745,12 +748,17 @@ public class WindowsIconFactory implements Serializable Icon icon = getIcon(); int height = 0; if (icon != null) { - height = icon.getIconHeight() + 2 * OFFSET; + height = icon.getIconHeight(); } else { - Skin skin = - XPStyle.getXP().getSkin(null, Part.MP_POPUPCHECK); - height = skin.getHeight() + 2 * OFFSET; + XPStyle xp = XPStyle.getXP(); + if (xp != null) { + Skin skin = xp.getSkin(null, Part.MP_POPUPCHECK); + height = skin.getHeight(); + } else { + height = 16; + } } + height += 2 * OFFSET; return height; } @@ -798,14 +806,16 @@ public class WindowsIconFactory implements Serializable ? State.BULLETDISABLED : State.CHECKMARKDISABLED; } - Skin skin; XPStyle xp = XPStyle.getXP(); - skin = xp.getSkin(c, backgroundPart); - skin.paintSkin(g, x, y, - getIconWidth(), getIconHeight(), backgroundState); - if (icon == null) { - skin = xp.getSkin(c, part); - skin.paintSkin(g, x + OFFSET, y + OFFSET, state); + if (xp != null) { + Skin skin; + skin = xp.getSkin(c, backgroundPart); + skin.paintSkin(g, x, y, + getIconWidth(), getIconHeight(), backgroundState); + if (icon == null) { + skin = xp.getSkin(c, part); + skin.paintSkin(g, x + OFFSET, y + OFFSET, state); + } } } } diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java index d3ccff283..7ff9129a2 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,14 +85,15 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane { } } else { buttonWidth += 2; - selectedTitleGradientColor = - UIManager.getColor("InternalFrame.activeTitleGradient"); - notSelectedTitleGradientColor = - UIManager.getColor("InternalFrame.inactiveTitleGradient"); Color activeBorderColor = UIManager.getColor("InternalFrame.activeBorderColor"); setBorder(BorderFactory.createLineBorder(activeBorderColor, 1)); } + // JDK-8039383: initialize these colors because getXP() may return null when theme is changed + selectedTitleGradientColor = + UIManager.getColor("InternalFrame.activeTitleGradient"); + notSelectedTitleGradientColor = + UIManager.getColor("InternalFrame.inactiveTitleGradient"); } protected void uninstallListeners() { diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java index d063e23a6..66838fe3f 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java @@ -2399,8 +2399,9 @@ public class WindowsLookAndFeel extends BasicLookAndFeel } public Object getXPValue(UIDefaults table) { - Border xpBorder = XPStyle.getXP().getBorder(null, (Part)xpValue); - if (extraMargin != null) { + XPStyle xp = XPStyle.getXP(); + Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null; + if (xpBorder != null && extraMargin != null) { return new BorderUIResource. CompoundBorderUIResource(xpBorder, extraMargin); } else { @@ -2416,7 +2417,8 @@ public class WindowsLookAndFeel extends BasicLookAndFeel public Object getXPValue(UIDefaults table) { XPColorValueKey key = (XPColorValueKey)xpValue; - return XPStyle.getXP().getColor(key.skin, key.prop, null); + XPStyle xp = XPStyle.getXP(); + return xp != null ? xp.getColor(key.skin, key.prop, null) : null; } private static class XPColorValueKey { diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java index c56b83bef..b55a01c53 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java @@ -155,8 +155,8 @@ public class WindowsMenuBarUI extends BasicMenuBarUI @Override public void paint(Graphics g, JComponent c) { - if (WindowsMenuItemUI.isVistaPainting()) { - XPStyle xp = XPStyle.getXP(); + XPStyle xp = XPStyle.getXP(); + if (WindowsMenuItemUI.isVistaPainting(xp)) { Skin skin; skin = xp.getSkin(c, Part.MP_BARBACKGROUND); int width = c.getWidth(); diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java index cac7af54a..dddbeeb50 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,8 +108,9 @@ public class WindowsMenuItemUI extends BasicMenuItemUI { static void paintBackground(WindowsMenuItemUIAccessor menuItemUI, Graphics g, JMenuItem menuItem, Color bgColor) { - assert isVistaPainting(); - if (isVistaPainting()) { + XPStyle xp = XPStyle.getXP(); + assert isVistaPainting(xp); + if (isVistaPainting(xp)) { int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); if (menuItem.isOpaque()) { @@ -118,7 +119,6 @@ public class WindowsMenuItemUI extends BasicMenuItemUI { g.fillRect(0,0, menuWidth, menuHeight); g.setColor(oldColor); } - XPStyle xp = XPStyle.getXP(); Part part = menuItemUI.getPart(menuItem); Skin skin = xp.getSkin(menuItem, part); skin.paintSkin(g, 0 , 0, @@ -170,8 +170,11 @@ public class WindowsMenuItemUI extends BasicMenuItemUI { * is it possible that in some theme some Vista parts are not defined while * others are? */ - static boolean isVistaPainting() { - XPStyle xp = XPStyle.getXP(); + static boolean isVistaPainting(final XPStyle xp) { return xp != null && xp.isSkinDefined(null, Part.MP_POPUPITEM); } + + static boolean isVistaPainting() { + return isVistaPainting(XPStyle.getXP()); + } } diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java index 797aa5a7b..f040812a2 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { public void paint(Graphics g, JComponent c) { Dimension s = c.getSize(); - if (WindowsMenuItemUI.isVistaPainting()) { + XPStyle xp = XPStyle.getXP(); + if (WindowsMenuItemUI.isVistaPainting(xp)) { int x = 1; Component parent = c.getParent(); if (parent instanceof JComponent) { @@ -67,7 +68,7 @@ public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { x += WindowsPopupMenuUI.getGutterWidth(); } } - Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR); + Skin skin = xp.getSkin(c, Part.MP_POPUPSEPARATOR); int skinHeight = skin.getHeight(); int y = (s.height - skinHeight) / 2; skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL); diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java index 584641bca..06dde67d7 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -194,8 +194,8 @@ public class WindowsPopupMenuUI extends BasicPopupMenuUI { @Override public void paint(Graphics g, JComponent c) { - if (WindowsMenuItemUI.isVistaPainting()) { - XPStyle xp = XPStyle.getXP(); + XPStyle xp = XPStyle.getXP(); + if (WindowsMenuItemUI.isVistaPainting(xp)) { Skin skin = xp.getSkin(c, Part.MP_POPUPBACKGROUND); skin.paintSkin(g, 0, 0, c.getWidth(),c.getHeight(), State.NORMAL); int textOffset = getTextOffset(c); diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java index ef5d176fa..45947fc2b 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -322,8 +322,9 @@ public class WindowsProgressBarUI extends BasicProgressBarUI private Rectangle getFullChunkBounds(Rectangle box) { boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL); XPStyle xp = XPStyle.getXP(); - int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null, - Prop.PROGRESSSPACESIZE, 0); + int gap = (xp != null) ? xp.getInt(progressBar, Part.PP_PROGRESS, + null, Prop.PROGRESSSPACESIZE, 0) + : 0; if (!vertical) { int chunksize = box.width+gap; @@ -338,6 +339,9 @@ public class WindowsProgressBarUI extends BasicProgressBarUI boolean vertical, int bgwidth, int bgheight) { XPStyle xp = XPStyle.getXP(); + if (xp == null) { + return; + } // create a new graphics to keep drawing surface state Graphics2D gfx = (Graphics2D)g.create(); @@ -396,6 +400,9 @@ public class WindowsProgressBarUI extends BasicProgressBarUI private void paintXPBackground(Graphics g, boolean vertical, int barRectWidth, int barRectHeight) { XPStyle xp = XPStyle.getXP(); + if (xp == null) { + return; + } Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR; Skin skin = xp.getSkin(progressBar, part); diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java index dbfb7b812..1bae3f8f4 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -215,7 +215,6 @@ public class WindowsSliderUI extends BasicSliderUI } private Part getXPThumbPart() { - XPStyle xp = XPStyle.getXP(); Part part; boolean vertical = (slider.getOrientation() == JSlider.VERTICAL); boolean leftToRight = slider.getComponentOrientation().isLeftToRight(); diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java index ccc6d039b..c17328e50 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,6 +63,9 @@ public class WindowsSpinnerUI extends BasicSpinnerUI { private void paintXPBackground(Graphics g, JComponent c) { XPStyle xp = XPStyle.getXP(); + if (xp == null) { + return; + } Skin skin = xp.getSkin(c, Part.EP_EDIT); State state = getXPState(c); skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state); diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java index 391f019ae..e667c05e8 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java @@ -90,9 +90,10 @@ public class WindowsTableHeaderUI extends BasicTableHeaderUI { this.column = column; this.hasRollover = (column == getRolloverColumn()); if (skin == null) { - skin = XPStyle.getXP().getSkin(header, Part.HP_HEADERITEM); + XPStyle xp = XPStyle.getXP(); + skin = (xp != null) ? xp.getSkin(header, Part.HP_HEADERITEM) : null; } - Insets margins = skin.getContentMargin(); + Insets margins = (skin != null) ? skin.getContentMargin() : null; Border border = null; int contentTop = 0; int contentLeft = 0; diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java b/src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java index 7379533ad..72cf9256f 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java @@ -115,7 +115,7 @@ class XPStyle { } } } - return xp; + return ThemeReader.isXPStyleEnabled() ? xp : null; } static boolean isVista() { @@ -180,9 +180,10 @@ class XPStyle { * should probably be cached there instead of here. */ Dimension getDimension(Component c, Part part, State state, Prop prop) { - return ThemeReader.getPosition(part.getControlName(c), part.getValue(), - State.getValue(part, state), - prop.getValue()); + Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), + State.getValue(part, state), + prop.getValue()); + return (d != null) ? d : new Dimension(); } /** Get a named <code>Point</code> (e.g. a location or an offset) value @@ -199,11 +200,7 @@ class XPStyle { Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); - if (d != null) { - return new Point(d.width, d.height); - } else { - return null; - } + return (d != null) ? new Point(d.width, d.height) : new Point(); } /** Get a named <code>Insets</code> value from the current style @@ -217,9 +214,10 @@ class XPStyle { * The return value is already cached in those places. */ Insets getMargin(Component c, Part part, State state, Prop prop) { - return ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(), - State.getValue(part, state), - prop.getValue()); + Insets insets = ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(), + State.getValue(part, state), + prop.getValue()); + return (insets != null) ? insets : new Insets(0, 0, 0, 0); } @@ -505,16 +503,17 @@ class XPStyle { int boundingWidth = 100; int boundingHeight = 100; - return ThemeReader.getThemeBackgroundContentMargins( + Insets insets = ThemeReader.getThemeBackgroundContentMargins( part.getControlName(null), part.getValue(), 0, boundingWidth, boundingHeight); + return (insets != null) ? insets : new Insets(0, 0, 0, 0); } private int getWidth(State state) { if (size == null) { size = getPartSize(part, state); } - return size.width; + return (size != null) ? size.width : 0; } int getWidth() { @@ -525,7 +524,7 @@ class XPStyle { if (size == null) { size = getPartSize(part, state); } - return size.height; + return (size != null) ? size.height : 0; } int getHeight() { @@ -582,6 +581,9 @@ class XPStyle { * @param state which state to paint */ void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) { + if (XPStyle.getXP() == null) { + return; + } if (ThemeReader.isGetThemeTransitionDurationDefined() && component instanceof JComponent && SwingUtilities.getAncestorOfClass(CellRendererPane.class, @@ -607,6 +609,9 @@ class XPStyle { * @param state which state to paint */ void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) { + if (XPStyle.getXP() == null) { + return; + } skinPainter.paint(null, g, dx, dy, dw, dh, this, state); } @@ -625,6 +630,9 @@ class XPStyle { */ void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state, boolean borderFill) { + if (XPStyle.getXP() == null) { + return; + } if(borderFill && "borderfill".equals(getTypeEnumName(component, part, state, Prop.BGTYPE))) { return; @@ -679,7 +687,7 @@ class XPStyle { public GlyphButton(Component parent, Part part) { XPStyle xp = getXP(); - skin = xp.getSkin(parent, part); + skin = xp != null ? xp.getSkin(parent, part) : null; setBorder(null); setContentAreaFilled(false); setMinimumSize(new Dimension(5, 5)); @@ -704,13 +712,16 @@ class XPStyle { } public void paintComponent(Graphics g) { + if (XPStyle.getXP() == null || skin == null) { + return; + } Dimension d = getSize(); skin.paintSkin(g, 0, 0, d.width, d.height, getState()); } public void setPart(Component parent, Part part) { XPStyle xp = getXP(); - skin = xp.getSkin(parent, part); + skin = xp != null ? xp.getSkin(parent, part) : null; revalidate(); repaint(); } diff --git a/src/share/classes/com/sun/jndi/ldap/Connection.java b/src/share/classes/com/sun/jndi/ldap/Connection.java index d41c94480..c5a957ce6 100644 --- a/src/share/classes/com/sun/jndi/ldap/Connection.java +++ b/src/share/classes/com/sun/jndi/ldap/Connection.java @@ -111,6 +111,7 @@ public final class Connection implements Runnable { private static final boolean debug = false; private static final int dump = 0; // > 0 r, > 1 rw + public static final long DEFAULT_READ_TIMEOUT_MILLIS = 15 * 1000; // 15 second timeout; final private Thread worker; // Initialized in constructor @@ -460,7 +461,7 @@ public final class Connection implements Runnable { // available ldr.wait(readTimeout); } else { - ldr.wait(15 * 1000); // 15 second timeout + ldr.wait(DEFAULT_READ_TIMEOUT_MILLIS); } waited = true; } else { diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index 3acacf276..f15013c9c 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -3400,7 +3400,7 @@ public abstract class Component implements ImageObserver, MenuContainer, (width > 0) && (height > 0)) { PaintEvent e = new PaintEvent(this, PaintEvent.UPDATE, new Rectangle(x, y, width, height)); - Toolkit.getEventQueue().postEvent(e); + SunToolkit.postEvent(SunToolkit.targetToAppContext(this), e); } } } diff --git a/src/share/classes/java/lang/management/ManagementFactory.java b/src/share/classes/java/lang/management/ManagementFactory.java index 0c7297abe..c44471354 100644 --- a/src/share/classes/java/lang/management/ManagementFactory.java +++ b/src/share/classes/java/lang/management/ManagementFactory.java @@ -52,6 +52,7 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.management.JMX; import sun.management.ManagementFactoryHelper; +import sun.management.ExtendedPlatformComponent; /** * The {@code ManagementFactory} class is a factory class for getting @@ -489,6 +490,12 @@ public class ManagementFactory { for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) { addDynamicMBean(platformMBeanServer, e.getValue(), e.getKey()); } + for (final PlatformManagedObject o : + ExtendedPlatformComponent.getMXBeans()) { + if (!platformMBeanServer.isRegistered(o.getObjectName())) { + addMXBean(platformMBeanServer, o); + } + } } return platformMBeanServer; } @@ -655,9 +662,14 @@ public class ManagementFactory { public static <T extends PlatformManagedObject> T getPlatformMXBean(Class<T> mxbeanInterface) { PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); - if (pc == null) + if (pc == null) { + T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); + if (mbean != null) { + return mbean; + } throw new IllegalArgumentException(mxbeanInterface.getName() + " is not a platform management interface"); + } if (!pc.isSingleton()) throw new IllegalArgumentException(mxbeanInterface.getName() + " can have zero or more than one instances"); @@ -690,9 +702,14 @@ public class ManagementFactory { public static <T extends PlatformManagedObject> List<T> getPlatformMXBeans(Class<T> mxbeanInterface) { PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); - if (pc == null) + if (pc == null) { + T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); + if (mbean != null) { + return Collections.singletonList(mbean); + } throw new IllegalArgumentException(mxbeanInterface.getName() + " is not a platform management interface"); + } return Collections.unmodifiableList(pc.getMXBeans(mxbeanInterface)); } @@ -737,9 +754,17 @@ public class ManagementFactory { throws java.io.IOException { PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); - if (pc == null) + if (pc == null) { + T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); + if (mbean != null) { + ObjectName on = mbean.getObjectName(); + return ManagementFactory.newPlatformMXBeanProxy(connection, + on.getCanonicalName(), + mxbeanInterface); + } throw new IllegalArgumentException(mxbeanInterface.getName() + " is not a platform management interface"); + } if (!pc.isSingleton()) throw new IllegalArgumentException(mxbeanInterface.getName() + " can have zero or more than one instances"); @@ -781,6 +806,13 @@ public class ManagementFactory { { PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); if (pc == null) { + T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); + if (mbean != null) { + ObjectName on = mbean.getObjectName(); + T proxy = ManagementFactory.newPlatformMXBeanProxy(connection, + on.getCanonicalName(), mxbeanInterface); + return Collections.singletonList(proxy); + } throw new IllegalArgumentException(mxbeanInterface.getName() + " is not a platform management interface"); } diff --git a/src/share/classes/java/security/package-info.java b/src/share/classes/java/security/package-info.java index 599e95259..2c8205b09 100644 --- a/src/share/classes/java/security/package-info.java +++ b/src/share/classes/java/security/package-info.java @@ -92,14 +92,14 @@ * </b></a></li> * * <li><b>keytool</b> - * (<a href="{@docRoot}/../technotes/tools/solaris/keytool.html"> + * (<a href="{@docRoot}/../technotes/tools/unix/keytool.html"> * for Solaris/Linux</a>) * (<a href="{@docRoot}/../technotes/tools/windows/keytool.html"> * for Windows</a>) * </li> * * <li><b>jarsigner</b> - * (<a href="{@docRoot}/../technotes/tools/solaris/jarsigner.html"> + * (<a href="{@docRoot}/../technotes/tools/unix/jarsigner.html"> * for Solaris/Linux</a>) * (<a href="{@docRoot}/../technotes/tools/windows/jarsigner.html"> * for Windows</a>) diff --git a/src/share/classes/java/util/Collections.java b/src/share/classes/java/util/Collections.java index f2360772f..49124a47b 100644 --- a/src/share/classes/java/util/Collections.java +++ b/src/share/classes/java/util/Collections.java @@ -3077,10 +3077,7 @@ public class Collections { public void remove() { it.remove(); }}; } - public boolean add(E e) { - typeCheck(e); - return c.add(e); - } + public boolean add(E e) { return c.add(typeCheck(e)); } private E[] zeroLengthElementArray; // Lazily initialized @@ -3187,11 +3184,7 @@ public class Collections { public E peek() {return queue.peek();} public E poll() {return queue.poll();} public E remove() {return queue.remove();} - - public boolean offer(E e) { - typeCheck(e); - return add(e); - } + public boolean offer(E e) {return queue.offer(typeCheck(e));} } /** @@ -3440,13 +3433,11 @@ public class Collections { public int lastIndexOf(Object o) { return list.lastIndexOf(o); } public E set(int index, E element) { - typeCheck(element); - return list.set(index, element); + return list.set(index, typeCheck(element)); } public void add(int index, E element) { - typeCheck(element); - list.add(index, element); + list.add(index, typeCheck(element)); } public boolean addAll(int index, Collection<? extends E> c) { @@ -3467,13 +3458,11 @@ public class Collections { public void remove() { i.remove(); } public void set(E e) { - typeCheck(e); - i.set(e); + i.set(typeCheck(e)); } public void add(E e) { - typeCheck(e); - i.add(e); + i.add(typeCheck(e)); } @Override diff --git a/src/share/classes/javax/swing/JComponent.java b/src/share/classes/javax/swing/JComponent.java index 803c13fd0..55695dbe9 100644 --- a/src/share/classes/javax/swing/JComponent.java +++ b/src/share/classes/javax/swing/JComponent.java @@ -63,6 +63,7 @@ import javax.swing.plaf.*; import static javax.swing.ClientPropertyKey.*; import javax.accessibility.*; +import sun.awt.SunToolkit; import sun.swing.SwingUtilities2; import sun.swing.UIClientPropertyKey; @@ -4795,7 +4796,8 @@ public abstract class JComponent extends Container implements Serializable, * @see RepaintManager#addDirtyRegion */ public void repaint(long tm, int x, int y, int width, int height) { - RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height); + RepaintManager.currentManager(SunToolkit.targetToAppContext(this)) + .addDirtyRegion(this, x, y, width, height); } @@ -4849,7 +4851,7 @@ public abstract class JComponent extends Container implements Serializable, // which was causing some people grief. return; } - if (SwingUtilities.isEventDispatchThread()) { + if (SunToolkit.isDispatchThreadForAppContext(this)) { invalidate(); RepaintManager.currentManager(this).addInvalidComponent(this); } @@ -4863,15 +4865,12 @@ public abstract class JComponent extends Container implements Serializable, } setFlag(REVALIDATE_RUNNABLE_SCHEDULED, true); } - Runnable callRevalidate = new Runnable() { - public void run() { - synchronized(JComponent.this) { - setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false); - } - revalidate(); + SunToolkit.executeOnEventHandlerThread(this, () -> { + synchronized(JComponent.this) { + setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false); } - }; - SwingUtilities.invokeLater(callRevalidate); + revalidate(); + }); } } diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java b/src/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java index 7acfff532..8dec6eda0 100644 --- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java +++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java @@ -550,6 +550,7 @@ public class InsnList { } // this class is not generified because it will create bridges + @SuppressWarnings("rawtypes") private final class InsnListIterator implements ListIterator { AbstractInsnNode next; diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java b/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java index bb01f7a7a..156144276 100644 --- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java +++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java @@ -399,6 +399,7 @@ public class MethodNode extends MethodVisitor { } @Override + @SuppressWarnings("unchecked") public AnnotationVisitor visitParameterAnnotation(final int parameter, final String desc, final boolean visible) { AnnotationNode an = new AnnotationNode(desc); diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java b/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java index 8f987532e..b8d6fdaa1 100644 --- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java +++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java @@ -131,6 +131,7 @@ public class Analyzer<V extends Value> implements Opcodes { * @throws AnalyzerException * if a problem occurs during the analysis. */ + @SuppressWarnings("unchecked") public Frame<V>[] analyze(final String owner, final MethodNode m) throws AnalyzerException { if ((m.access & (ACC_ABSTRACT | ACC_NATIVE)) != 0) { diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java b/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java index cbb5f86f5..4ba309d0c 100644 --- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java +++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java @@ -112,6 +112,7 @@ public class Frame<V extends Value> { * @param nStack * the maximum stack size of the frame. */ + @SuppressWarnings("unchecked") public Frame(final int nLocals, final int nStack) { this.values = (V[]) new Value[nLocals + nStack]; this.locals = nLocals; diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/version.txt b/src/share/classes/jdk/internal/org/objectweb/asm/version.txt index b1d916092..d93a6c4b4 100644 --- a/src/share/classes/jdk/internal/org/objectweb/asm/version.txt +++ b/src/share/classes/jdk/internal/org/objectweb/asm/version.txt @@ -1,12 +1,12 @@ Path: . -Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-05-27 +Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-06-19 URL: file:///svnroot/asm/trunk/asm Repository Root: file:///svnroot/asm Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9 -Revision: 1748 +Revision: 1750 Node Kind: directory Schedule: normal -Last Changed Author: ebruneton -Last Changed Rev: 1747 -Last Changed Date: 2014-05-24 10:22:13 +0200 (Sat, 24 May 2014) +Last Changed Author: forax +Last Changed Rev: 1750 +Last Changed Date: 2014-06-06 00:31:02 +0200 (Fri, 06 Jun 2014) diff --git a/src/share/classes/jdk/net/Sockets.java b/src/share/classes/jdk/net/Sockets.java index ef75631a0..2b31a1d57 100644 --- a/src/share/classes/jdk/net/Sockets.java +++ b/src/share/classes/jdk/net/Sockets.java @@ -119,6 +119,8 @@ public class Sockets { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof IOException) { throw (IOException)t; + } else if (t instanceof RuntimeException) { + throw (RuntimeException)t; } } throw new RuntimeException(e); @@ -135,6 +137,8 @@ public class Sockets { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof IOException) { throw (IOException)t; + } else if (t instanceof RuntimeException) { + throw (RuntimeException)t; } } throw new RuntimeException(e); diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java index 767a4b8ab..d86dd1bb1 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java @@ -221,24 +221,24 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo { } OutputStream os = new UnsyncBufferedOutputStream(bos); - try { - os.close(); - } catch (IOException e) { - if (log.isLoggable(java.util.logging.Level.FINE)) { - log.log(java.util.logging.Level.FINE, e.getMessage(), e); - } - // Impossible - } DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true); - try { ((DOMCanonicalizationMethod) - canonicalizationMethod).canonicalize(subTree, context, bos); + canonicalizationMethod).canonicalize(subTree, context, os); } catch (TransformException te) { throw new XMLSignatureException(te); } + try { + os.flush(); + } catch (IOException e) { + if (log.isLoggable(java.util.logging.Level.FINE)) { + log.log(java.util.logging.Level.FINE, e.getMessage(), e); + } + // Impossible + } + byte[] signedInfoBytes = bos.toByteArray(); // this whole block should only be done if logging is enabled @@ -253,6 +253,15 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo { } this.canonData = new ByteArrayInputStream(signedInfoBytes); + + try { + os.close(); + } catch (IOException e) { + if (log.isLoggable(java.util.logging.Level.FINE)) { + log.log(java.util.logging.Level.FINE, e.getMessage(), e); + } + // Impossible + } } public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) diff --git a/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java b/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java index 7fdab9bd6..89578cc32 100644 --- a/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java +++ b/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java @@ -383,7 +383,8 @@ class LCMSImageLayout { } public static LCMSImageLayout createImageLayout(Raster r) { LCMSImageLayout l = new LCMSImageLayout(); - if (r instanceof ByteComponentRaster) { + if (r instanceof ByteComponentRaster && + r.getSampleModel() instanceof ComponentSampleModel) { ByteComponentRaster br = (ByteComponentRaster)r; ComponentSampleModel csm = (ComponentSampleModel)r.getSampleModel(); diff --git a/src/share/classes/sun/management/ExtendedPlatformComponent.java b/src/share/classes/sun/management/ExtendedPlatformComponent.java new file mode 100644 index 000000000..ff33ff9b5 --- /dev/null +++ b/src/share/classes/sun/management/ExtendedPlatformComponent.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.management; + +import java.util.Collections; +import java.util.List; +import java.lang.management.PlatformManagedObject; + +/** + * Class to allow for an extended set of platform MXBeans + */ +public final class ExtendedPlatformComponent { + private ExtendedPlatformComponent() {} // Don't create any instances + + /** + * Get the extended set of platform MXBeans that should be registered in the + * platform MBeanServer, or an empty list if there are no such MXBeans. + */ + public static List<? extends PlatformManagedObject> getMXBeans() { + return Collections.emptyList(); + } + + /** + * Returns the extended platform MXBean implementing the given + * mxbeanInterface, or null if there is no such MXBean. + */ + public static <T extends PlatformManagedObject> + T getMXBean(Class<T> mxbeanInterface) { + return null; + } +} diff --git a/src/share/classes/sun/print/CustomMediaSizeName.java b/src/share/classes/sun/print/CustomMediaSizeName.java index e1df99073..7ba0e4f39 100644 --- a/src/share/classes/sun/print/CustomMediaSizeName.java +++ b/src/share/classes/sun/print/CustomMediaSizeName.java @@ -67,6 +67,22 @@ class CustomMediaSizeName extends MediaSizeName { MediaSize.INCH); } catch (IllegalArgumentException iae) { } + // The public API method finds a closest match even if it not + // all that close. Here we want to be sure its *really* close. + if (mediaName != null) { + MediaSize sz = MediaSize.getMediaSizeForName(mediaName); + if (sz == null) { + mediaName = null; + } else { + float w = sz.getX(MediaSize.INCH); + float h = sz.getY(MediaSize.INCH); + float dw = Math.abs(w - width); + float dh = Math.abs(h - length); + if (dw > 0.1 || dh > 0.1) { + mediaName = null; + } + } + } } /** diff --git a/src/share/classes/sun/security/jgss/GSSNameImpl.java b/src/share/classes/sun/security/jgss/GSSNameImpl.java index 53acbe069..4c44ff44b 100644 --- a/src/share/classes/sun/security/jgss/GSSNameImpl.java +++ b/src/share/classes/sun/security/jgss/GSSNameImpl.java @@ -257,6 +257,10 @@ public class GSSNameImpl implements GSSName { ((0xFF & bytes[pos++]) << 16) | ((0xFF & bytes[pos++]) << 8) | (0xFF & bytes[pos++])); + if (pos > bytes.length - mechPortionLen) { + throw new GSSExceptionImpl(GSSException.BAD_NAME, + "Exported name mech name is corrupted!"); + } byte[] mechPortion = new byte[mechPortionLen]; System.arraycopy(bytes, pos, mechPortion, 0, mechPortionLen); diff --git a/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java b/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java index 2f35f894c..e7707e848 100644 --- a/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java +++ b/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java @@ -32,9 +32,11 @@ package sun.security.krb5.internal.ccache; import java.io.IOException; import java.io.InputStream; -import java.util.Hashtable; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import java.util.StringTokenizer; + +import sun.misc.IOUtils; import sun.security.krb5.*; import sun.security.krb5.internal.*; import sun.security.krb5.internal.util.KrbDataInputStream; @@ -74,7 +76,6 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC // this needs to be public for Kinit. public Tag readTag() throws IOException { char[] buf = new char[1024]; - byte[] bytes; int len; int tag = -1; int taglen; @@ -85,7 +86,6 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC if (len < 0) { throw new IOException("stop."); } - bytes = new byte[len + 2]; if (len > buf.length) { throw new IOException("Invalid tag length."); } @@ -101,11 +101,7 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC } len = len - (4 + taglen); } - Tag result; - if (tag == -1) { - } - result = new Tag(len, tag, time_offset, usec_offset); - return result; + return new Tag(len, tag, time_offset, usec_offset); } /* * In file-based credential cache, the realm name is stored as part of @@ -123,7 +119,7 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC type = read(4); } length = read(4); - String[] result = new String[length + 1]; + List<String> result = new ArrayList<String>(); /* * DCE includes the principal's realm in the count; the new format * does not. @@ -132,21 +128,26 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC length--; for (int i = 0; i <= length; i++) { namelength = read(4); - if (namelength > MAXNAMELENGTH) { - throw new IOException("Invalid name length in principal name."); - } - byte[] bytes = new byte[namelength]; - read(bytes, 0, namelength); - result[i] = new String(bytes); + byte[] bytes = IOUtils.readFully(this, namelength, true); + result.add(new String(bytes)); } - if (isRealm(result[0])) { - realm = result[0]; - pname = new String[length]; - System.arraycopy(result, 1, pname, 0, length); - return new PrincipalName(type, pname, new Realm(realm)); + if (result.isEmpty()) { + throw new IOException("No realm or principal"); + } + if (isRealm(result.get(0))) { + realm = result.remove(0); + if (result.isEmpty()) { + throw new IOException("No principal name components"); + } + return new PrincipalName( + type, + result.toArray(new String[result.size()]), + new Realm(realm)); } try { - return new PrincipalName(result, type); + return new PrincipalName( + result.toArray(new String[result.size()]), + type); } catch (RealmException re) { return null; } @@ -184,10 +185,7 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC if (version == KRB5_FCC_FVNO_3) read(2); /* keytype recorded twice in fvno 3 */ keyLen = read(4); - byte[] bytes = new byte[keyLen]; - for (int i = 0; i < keyLen; i++) { - bytes[i] = (byte)read(); - } + byte[] bytes = IOUtils.readFully(this, keyLen, true); return new EncryptionKey(bytes, keyType, new Integer(version)); } @@ -211,7 +209,7 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC int numAddrs, addrType, addrLength; numAddrs = read(4); if (numAddrs > 0) { - HostAddress[] addrs = new HostAddress[numAddrs]; + List<HostAddress> addrs = new ArrayList<>(); for (int i = 0; i < numAddrs; i++) { addrType = read(2); addrLength = read(4); @@ -224,9 +222,9 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC byte[] result = new byte[addrLength]; for (int j = 0; j < addrLength; j++) result[j] = (byte)read(1); - addrs[i] = new HostAddress(addrType, result); + addrs.add(new HostAddress(addrType, result)); } - return addrs; + return addrs.toArray(new HostAddress[addrs.size()]); } return null; } @@ -235,18 +233,15 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC int num, adtype, adlength; num = read(4); if (num > 0) { - AuthorizationDataEntry[] auData = new AuthorizationDataEntry[num]; + List<AuthorizationDataEntry> auData = new ArrayList<>(); byte[] data = null; for (int i = 0; i < num; i++) { adtype = read(2); adlength = read(4); - data = new byte[adlength]; - for (int j = 0; j < adlength; j++) { - data[j] = (byte)read(); - } - auData[i] = new AuthorizationDataEntry(adtype, data); + data = IOUtils.readFully(this, adlength, true); + auData.add(new AuthorizationDataEntry(adtype, data)); } - return auData; + return auData.toArray(new AuthorizationDataEntry[auData.size()]); } else return null; } @@ -257,9 +252,7 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC if (length == 0) { return null; } else { - byte[] bytes = new byte[length]; - read(bytes, 0, length); - return bytes; + return IOUtils.readFully(this, length, true); } } @@ -341,15 +334,29 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC * returns null. */ Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception { - PrincipalName cpname = readPrincipal(version); - if (DEBUG) + PrincipalName cpname = null; + try { + cpname = readPrincipal(version); + } catch (Exception e) { + // Do not return here. All data for this cred should be fully + // consumed so that we can read the next one. + } + if (DEBUG) { System.out.println(">>>DEBUG <CCacheInputStream> client principal is " + cpname); - PrincipalName spname = readPrincipal(version); - if (DEBUG) + } + PrincipalName spname = null; + try { + spname = readPrincipal(version); + } catch (Exception e) { + // same as above + } + if (DEBUG) { System.out.println(">>>DEBUG <CCacheInputStream> server principal is " + spname); + } EncryptionKey key = readKey(version); - if (DEBUG) + if (DEBUG) { System.out.println(">>>DEBUG <CCacheInputStream> key type: " + key.getEType()); + } long times[] = readTimes(); KerberosTime authtime = new KerberosTime(times[0]); KerberosTime starttime = @@ -382,6 +389,11 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC byte[] ticketData = readData(); byte[] ticketData2 = readData(); + // Skip this cred if either cpname or spname isn't created. + if (cpname == null || spname == null) { + return null; + } + try { return new Credentials(cpname, spname, key, authtime, starttime, endtime, renewTill, skey, tFlags, diff --git a/src/share/classes/sun/security/krb5/internal/ccache/FileCCacheConstants.java b/src/share/classes/sun/security/krb5/internal/ccache/FileCCacheConstants.java index ffca35e3b..c01ec623c 100644 --- a/src/share/classes/sun/security/krb5/internal/ccache/FileCCacheConstants.java +++ b/src/share/classes/sun/security/krb5/internal/ccache/FileCCacheConstants.java @@ -49,7 +49,6 @@ public interface FileCCacheConstants { public final int KRB5_FCC_FVNO_4 = 0x504; public final int FCC_TAG_DELTATIME = 1; public final int KRB5_NT_UNKNOWN = 0; - public final int MAXNAMELENGTH = 1024; public final int TKT_FLG_FORWARDABLE = 0x40000000; public final int TKT_FLG_FORWARDED = 0x20000000; public final int TKT_FLG_PROXIABLE = 0x10000000; diff --git a/src/share/classes/sun/security/pkcs11/P11Signature.java b/src/share/classes/sun/security/pkcs11/P11Signature.java index 4a0733d71..1bac22ca6 100644 --- a/src/share/classes/sun/security/pkcs11/P11Signature.java +++ b/src/share/classes/sun/security/pkcs11/P11Signature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -340,7 +340,10 @@ final class P11Signature extends SignatureSpi { } int minKeySize = (int) mechInfo.ulMinKeySize; int maxKeySize = (int) mechInfo.ulMaxKeySize; - + // need to override the MAX keysize for SHA1withDSA + if (md != null && mechanism == CKM_DSA && maxKeySize > 1024) { + maxKeySize = 1024; + } int keySize = 0; if (key instanceof P11Key) { keySize = ((P11Key) key).length(); diff --git a/src/share/native/sun/java2d/opengl/OGLBufImgOps.c b/src/share/native/sun/java2d/opengl/OGLBufImgOps.c index 046018c81..b7e59341c 100644 --- a/src/share/native/sun/java2d/opengl/OGLBufImgOps.c +++ b/src/share/native/sun/java2d/opengl/OGLBufImgOps.c @@ -636,6 +636,9 @@ OGLBufImgOps_EnableLookupOp(OGLContext *oglc, jlong pSrcOps, "OGLBufImgOps_EnableLookupOp: short=%d num=%d len=%d off=%d", shortData, numBands, bandLength, offset); + for (i = 0; i < 4; i++) { + bands[i] = NULL; + } RETURN_IF_NULL(oglc); RETURN_IF_NULL(srcOps); RESET_PREVIOUS_OP(); diff --git a/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c b/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c index 517f14495..0a5712d6a 100644 --- a/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c +++ b/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c @@ -600,7 +600,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_releaseCred(JNIEnv *env, */ void inquireCred(JNIEnv *env, jobject jobj, gss_cred_id_t pCred, jint type, void *result) { - OM_uint32 minor, major=0; + OM_uint32 minor=0, major=0; OM_uint32 routineErr; gss_cred_id_t credHdl; diff --git a/src/share/native/sun/security/krb5/nativeccache.c b/src/share/native/sun/security/krb5/nativeccache.c index 0b9fbfa87..beb5bf026 100644 --- a/src/share/native/sun/security/krb5/nativeccache.c +++ b/src/share/native/sun/security/krb5/nativeccache.c @@ -141,7 +141,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) #endif /* DEBUG */ ticketConstructor = (*env)->GetMethodID(env, ticketClass, "<init>", "(Lsun/security/util/DerValue;)V"); - if (derValueConstructor == 0) { + if (ticketConstructor == 0) { printf("Couldn't find Ticket constructor\n"); return JNI_ERR; } @@ -272,6 +272,7 @@ int isIn(krb5_enctype e, int n, jint* etypes) } return 0; } + /* * Class: sun_security_krb5_Credentials * Method: acquireDefaultNativeCreds @@ -309,7 +310,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ netypes = (*env)->GetArrayLength(env, jetypes); etypes = (jint *) (*env)->GetIntArrayElements(env, jetypes, NULL); - if (!err) { + if (etypes != NULL && !err) { while ((err = krb5_cc_next_cred (kcontext, ccache, &cursor, &creds)) == 0) { char *serverName = NULL; @@ -319,8 +320,16 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ } if (!err) { - if (strncmp (serverName, "krbtgt", sizeof("krbtgt")-1) == 0 && - isIn(creds.keyblock.enctype, netypes, etypes)) { + char* slash = strchr(serverName, '/'); + char* at = strchr(serverName, '@'); + // Make sure the server's name is krbtgt/REALM@REALM, the etype + // is supported, and the ticket has not expired + if (slash && at && + strncmp (serverName, "krbtgt", slash-serverName) == 0 && + // the ablove line shows at must be after slash + strncmp (slash+1, at+1, at-slash-1) == 0 && + isIn (creds.keyblock.enctype, netypes, etypes) && + creds.times.endtime > time(0)) { jobject ticket, clientPrincipal, targetPrincipal, encryptionKey; jobject ticketFlags, startTime, endTime; jobject authTime, renewTillTime, hostAddresses; @@ -399,8 +408,12 @@ cleanup: if (endTime) (*env)->DeleteLocalRef(env, endTime); if (renewTillTime) (*env)->DeleteLocalRef(env, renewTillTime); if (hostAddresses) (*env)->DeleteLocalRef(env, hostAddresses); - } + // Stop if there is an exception or we already found the initial TGT + if ((*env)->ExceptionCheck(env) || krbCreds) { + break; + } + } } if (serverName != NULL) { krb5_free_unparsed_name (kcontext, serverName); } @@ -410,7 +423,6 @@ cleanup: if (err == KRB5_CC_END) { err = 0; } printiferr (err, "while retrieving a ticket"); - } if (!err) { @@ -445,25 +457,25 @@ jobject BuildTicket(JNIEnv *env, krb5_data *encodedTicket) jbyteArray ary; ary = (*env)->NewByteArray(env, encodedTicket->length); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return (jobject) NULL; } (*env)->SetByteArrayRegion(env, ary, (jsize) 0, encodedTicket->length, (jbyte *)encodedTicket->data); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { (*env)->DeleteLocalRef(env, ary); return (jobject) NULL; } derValue = (*env)->NewObject(env, derValueClass, derValueConstructor, ary); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { (*env)->DeleteLocalRef(env, ary); return (jobject) NULL; } (*env)->DeleteLocalRef(env, ary); ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, derValue); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { (*env)->DeleteLocalRef(env, derValue); return (jobject) NULL; } @@ -480,6 +492,10 @@ jobject BuildClientPrincipal(JNIEnv *env, krb5_context kcontext, krb5_principal if (!err) { // Make a PrincipalName from the full string and the type. Let the PrincipalName class parse it out. jstring principalStringObj = (*env)->NewStringUTF(env, principalString); + if (principalStringObj == NULL) { + if (principalString != NULL) { krb5_free_unparsed_name (kcontext, principalString); } + return (jobject) NULL; + } principal = (*env)->NewObject(env, principalNameClass, principalNameConstructor, principalStringObj, principalName->type); if (principalString != NULL) { krb5_free_unparsed_name (kcontext, principalString); } (*env)->DeleteLocalRef(env, principalStringObj); @@ -494,8 +510,13 @@ jobject BuildEncryptionKey(JNIEnv *env, krb5_keyblock *cryptoKey) { jobject encryptionKey = NULL; ary = (*env)->NewByteArray(env,cryptoKey->length); + + if (ary == NULL) { + return (jobject) NULL; + } + (*env)->SetByteArrayRegion(env, ary, (jsize) 0, cryptoKey->length, (jbyte *)cryptoKey->contents); - if (!(*env)->ExceptionOccurred(env)) { + if (!(*env)->ExceptionCheck(env)) { encryptionKey = (*env)->NewObject(env, encryptionKeyClass, encryptionKeyConstructor, cryptoKey->enctype, ary); } @@ -514,9 +535,14 @@ jobject BuildTicketFlags(JNIEnv *env, krb5_flags flags) { unsigned long nlflags = htonl(flags); ary = (*env)->NewByteArray(env, sizeof(flags)); + + if (ary == NULL) { + return (jobject) NULL; + } + (*env)->SetByteArrayRegion(env, ary, (jsize) 0, sizeof(flags), (jbyte *)&nlflags); - if (!(*env)->ExceptionOccurred(env)) { + if (!(*env)->ExceptionCheck(env)) { ticketFlags = (*env)->NewObject(env, ticketFlagsClass, ticketFlagsConstructor, sizeof(flags)*8, ary); } @@ -550,6 +576,10 @@ jobject BuildAddressList(JNIEnv *env, krb5_address **addresses) { jobject address_list = (*env)->NewObjectArray(env, addressCount, hostAddressClass, NULL); + if (address_list == NULL) { + return (jobject) NULL; + } + // Create a new HostAddress object for each address block. // First, reset the iterator. p = addresses; @@ -567,9 +597,16 @@ jobject BuildAddressList(JNIEnv *env, krb5_address **addresses) { (*env)->DeleteLocalRef(env, ary); + if (address == NULL) { + return (jobject) NULL; + } // Add the HostAddress to the arrray. (*env)->SetObjectArrayElement(env, address_list, index, address); + if ((*env)->ExceptionCheck(env)) { + return (jobject) NULL; + } + index++; p++; } diff --git a/src/solaris/classes/sun/awt/windows/ThemeReader.java b/src/solaris/classes/sun/awt/windows/ThemeReader.java index 7445cc2f5..5bd2f7ec0 100644 --- a/src/solaris/classes/sun/awt/windows/ThemeReader.java +++ b/src/solaris/classes/sun/awt/windows/ThemeReader.java @@ -45,6 +45,10 @@ public final class ThemeReader { return false; } + public static boolean isXPStyleEnabled() { + return false; + } + public static void paintBackground(int[] buffer, String widget, int part, int state, int x, int y, int w, int h, int stride) { } diff --git a/src/solaris/classes/sun/print/CUPSPrinter.java b/src/solaris/classes/sun/print/CUPSPrinter.java index a54316e09..c8f902090 100644 --- a/src/solaris/classes/sun/print/CUPSPrinter.java +++ b/src/solaris/classes/sun/print/CUPSPrinter.java @@ -140,6 +140,9 @@ public class CUPSPrinter { return cupsCustomMediaSNames; } + public int getDefaultMediaIndex() { + return ((pageSizes.length >1) ? (int)(pageSizes[pageSizes.length -1]) : 0); + } /** * Returns array of MediaPrintableArea derived from PPD. @@ -201,8 +204,15 @@ public class CUPSPrinter { // add this new custom msn to MediaSize array if ((width > 0.0) && (length > 0.0)) { + try { new MediaSize(width, length, Size2DSyntax.INCH, msn); + } catch (IllegalArgumentException e) { + /* PDF printer in Linux for Ledger paper causes + "IllegalArgumentException: X dimension > Y dimension". + We rotate based on IPP spec. */ + new MediaSize(length, width, Size2DSyntax.INCH, msn); + } } } diff --git a/src/solaris/classes/sun/print/IPPPrintService.java b/src/solaris/classes/sun/print/IPPPrintService.java index 28d6e1c0c..1be02c950 100644 --- a/src/solaris/classes/sun/print/IPPPrintService.java +++ b/src/solaris/classes/sun/print/IPPPrintService.java @@ -414,6 +414,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { mediaSizeNames = cps.getMediaSizeNames(); mediaTrays = cps.getMediaTrays(); customMediaSizeNames = cps.getCustomMediaSizeNames(); + defaultMediaIndex = cps.getDefaultMediaIndex(); urlConnection.disconnect(); init = true; return; @@ -1432,7 +1433,9 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { return JobSheets.STANDARD; } } else if (category == Media.class) { - defaultMediaIndex = 0; + if (defaultMediaIndex == -1) { + defaultMediaIndex = 0; + } if (mediaSizeNames.length == 0) { String defaultCountry = Locale.getDefault().getCountry(); if (defaultCountry != null && @@ -1448,17 +1451,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { if (attribClass != null) { String name = attribClass.getStringValue(); if (isCupsPrinter) { - for (int i=0; i< customMediaSizeNames.length; i++) { - //REMIND: get default from PPD. In native _getMedia, - // move default (ppd_option_t->defchoice) to index 0. - // In the meantime, use indexOf because PPD name - // may be different from the IPP attribute name. - if (customMediaSizeNames[i].toString().indexOf(name) - != -1) { - defaultMediaIndex = i; - return mediaSizeNames[defaultMediaIndex]; - } - } + return mediaSizeNames[defaultMediaIndex]; } else { for (int i=0; i< mediaSizeNames.length; i++) { if (mediaSizeNames[i].toString().indexOf(name) != -1) { diff --git a/src/solaris/native/sun/awt/CUPSfuncs.c b/src/solaris/native/sun/awt/CUPSfuncs.c index 653428b84..d7d989629 100644 --- a/src/solaris/native/sun/awt/CUPSfuncs.c +++ b/src/solaris/native/sun/awt/CUPSfuncs.c @@ -349,7 +349,8 @@ Java_sun_print_CUPSPrinter_getPageSizes(JNIEnv *env, // create array of dimensions - (num_choices * 6) //to cover length & height DPRINTF( "CUPSfuncs::option->num_choices %d\n", option->num_choices) - sizeArray = (*env)->NewFloatArray(env, option->num_choices*6); + // +1 is for storing the default media index + sizeArray = (*env)->NewFloatArray(env, option->num_choices*6+1); if (sizeArray == NULL) { unlink(filename); j2d_ppdClose(ppd); @@ -369,6 +370,10 @@ Java_sun_print_CUPSPrinter_getPageSizes(JNIEnv *env, } for (i = 0; i<option->num_choices; i++) { choice = (option->choices)+i; + // get the index of the default page + if (!strcmp(choice->choice, option->defchoice)) { + dims[option->num_choices*6] = (float)i; + } size = j2d_ppdPageSize(ppd, choice->choice); if (size != NULL) { // paper width and height diff --git a/src/solaris/native/sun/awt/gtk2_interface.c b/src/solaris/native/sun/awt/gtk2_interface.c index 0b6cbd63a..f61fee0b0 100644 --- a/src/solaris/native/sun/awt/gtk2_interface.c +++ b/src/solaris/native/sun/awt/gtk2_interface.c @@ -783,6 +783,8 @@ gboolean gtk2_load(JNIEnv *env) fp_gtk_widget_show = dl_symbol("gtk_widget_show"); fp_gtk_main = dl_symbol("gtk_main"); + fp_g_path_get_dirname = dl_symbol("g_path_get_dirname"); + /** * GLib thread system */ diff --git a/src/solaris/native/sun/awt/gtk2_interface.h b/src/solaris/native/sun/awt/gtk2_interface.h index 1523f7464..3498e3808 100644 --- a/src/solaris/native/sun/awt/gtk2_interface.h +++ b/src/solaris/native/sun/awt/gtk2_interface.h @@ -817,7 +817,7 @@ gulong (*fp_g_signal_connect_data)(gpointer instance, void (*fp_gtk_widget_show)(GtkWidget *widget); void (*fp_gtk_main)(void); guint (*fp_gtk_main_level)(void); - +gchar* (*fp_g_path_get_dirname) (const gchar *file_name); /** * This function is available for GLIB > 2.20, so it MUST be diff --git a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c index 9d9678172..5eb6fe52d 100644 --- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c +++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c @@ -59,7 +59,6 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gpointer obj) { JNIEnv *env; - jclass cx; jstring filename; env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); @@ -158,62 +157,55 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds fp_gdk_threads_leave(); } -/** - * Convert a GSList to an array of filenames (without the parent folder) +/* + * baseDir should be freed by user. */ -static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list) -{ - jstring str; - jclass stringCls; - GSList *iterator; - jobjectArray array; - int i; - char* entry; +static gboolean isFromSameDirectory(GSList* list, gchar** baseDir) { - if (NULL == list) { - return NULL; - } + GSList *it = list; + gchar* prevDir = NULL; + gboolean isAllDirsSame = TRUE; - stringCls = (*env)->FindClass(env, "java/lang/String"); - if (stringCls == NULL) { - (*env)->ExceptionClear(env); - JNU_ThrowInternalError(env, "Could not get java.lang.String class"); - return NULL; - } + while (it) { + gchar* dir = fp_g_path_get_dirname((gchar*) it->data); - array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, NULL); - if (array == NULL) { - (*env)->ExceptionClear(env); - JNU_ThrowInternalError(env, "Could not instantiate array files array"); - return NULL; - } + if (prevDir && strcmp(prevDir, dir) != 0) { + isAllDirsSame = FALSE; + fp_g_free(dir); + break; + } - i = 0; - for (iterator = list; iterator; iterator = iterator->next) { - entry = (char*) iterator->data; - entry = strrchr(entry, '/') + 1; - str = (*env)->NewStringUTF(env, entry); - if (str && !(*env)->ExceptionCheck(env)) { - (*env)->SetObjectArrayElement(env, array, i, str); + if (!prevDir) { + prevDir = strdup(dir); } - i++; + fp_g_free(dir); + + it = it->next; } - return array; + if (isAllDirsSame) { + *baseDir = prevDir; + } else { + free(prevDir); + *baseDir = strdup("/"); + } + + return isAllDirsSame; } /** - * Convert a GSList to an array of filenames (with the parent folder) + * Convert a GSList to an array of filenames */ -static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list) +static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list, jstring* jcurrent_folder) { jstring str; jclass stringCls; GSList *iterator; jobjectArray array; int i; - char* entry; - + gchar* entry; + gchar * baseDir; + gboolean isFromSameDir; if (list == NULL) { return NULL; @@ -233,12 +225,23 @@ static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list) return NULL; } - i = 0; - for (iterator = list; iterator; iterator = iterator->next) { - entry = (char*) iterator->data; + isFromSameDir = isFromSameDirectory(list, &baseDir); - //check for leading slash. - if (entry[0] == '/') { + *jcurrent_folder = (*env)->NewStringUTF(env, baseDir); + if (*jcurrent_folder == NULL) { + free(baseDir); + return NULL; + } + + for (iterator = list, i=0; + iterator; + iterator = iterator->next, i++) { + + entry = (gchar*) iterator->data; + + if (isFromSameDir) { + entry = strrchr(entry, '/') + 1; + } else if (entry[0] == '/') { entry++; } @@ -246,48 +249,33 @@ static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list) if (str && !(*env)->ExceptionCheck(env)) { (*env)->SetObjectArrayElement(env, array, i, str); } - i++; } + free(baseDir); return array; } static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj) { JNIEnv *env; - char *current_folder; GSList *filenames; - jclass cx; - jstring jcurrent_folder; + jstring jcurrent_folder = NULL; jobjectArray jfilenames; env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); - current_folder = NULL; filenames = NULL; - gboolean full_path_names = FALSE; if (responseId == GTK_RESPONSE_ACCEPT) { - current_folder = fp_gtk_file_chooser_get_current_folder( - GTK_FILE_CHOOSER(aDialog)); - if (current_folder == NULL) { - full_path_names = TRUE; - } filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog)); } - if (full_path_names) { - //This is a hack for use with "Recent Folders" in gtk where each - //file could have its own directory. - jfilenames = toPathAndFilenamesArray(env, filenames); - jcurrent_folder = (*env)->NewStringUTF(env, "/"); - } else { - jfilenames = toFilenamesArray(env, filenames); - jcurrent_folder = (*env)->NewStringUTF(env, current_folder); - } + + jfilenames = toFilenamesArray(env, filenames, &jcurrent_folder); + if (!(*env)->ExceptionCheck(env)) { (*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder, jfilenames); } - fp_g_free(current_folder); + quit(env, (jobject)obj, TRUE); } diff --git a/src/windows/classes/sun/awt/windows/ThemeReader.java b/src/windows/classes/sun/awt/windows/ThemeReader.java index 3bd048a05..26751e953 100644 --- a/src/windows/classes/sun/awt/windows/ThemeReader.java +++ b/src/windows/classes/sun/awt/windows/ThemeReader.java @@ -62,14 +62,20 @@ public final class ThemeReader { private static final Lock writeLock = readWriteLock.writeLock(); private static volatile boolean valid = false; + static volatile boolean xpStyleEnabled; + static void flush() { - // Could be called on Toolkit thread, so do not try to aquire locks + // Could be called on Toolkit thread, so do not try to acquire locks // to avoid deadlock with theme initialization valid = false; } public static native boolean isThemed(); + public static boolean isXPStyleEnabled() { + return xpStyleEnabled; + } + // this should be called only with writeLock held private static Long getThemeImpl(String widget) { Long theme = widgetToTheme.get(widget); diff --git a/src/windows/classes/sun/awt/windows/WToolkit.java b/src/windows/classes/sun/awt/windows/WToolkit.java index 5a72c9d87..81abb14e0 100644 --- a/src/windows/classes/sun/awt/windows/WToolkit.java +++ b/src/windows/classes/sun/awt/windows/WToolkit.java @@ -36,9 +36,9 @@ import java.awt.TrayIcon; import java.beans.PropertyChangeListener; import java.security.AccessController; import java.security.PrivilegedAction; +import sun.awt.AppContext; import sun.awt.AWTAutoShutdown; import sun.awt.LightweightFrame; -import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.misc.ThreadGroupUtils; import sun.awt.Win32GraphicsDevice; @@ -73,6 +73,9 @@ public final class WToolkit extends SunToolkit implements Runnable { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit"); + // Desktop property which specifies whether XP visual styles are in effect + public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive"; + static GraphicsConfiguration config; // System clipboard. @@ -580,6 +583,7 @@ public final class WToolkit extends SunToolkit implements Runnable { /** * Returns <code>true</code> if this frame state is supported. */ + @Override public boolean isFrameStateSupported(int state) { switch (state) { case Frame.NORMAL: @@ -894,7 +898,7 @@ public final class WToolkit extends SunToolkit implements Runnable { private synchronized void lazilyInitWProps() { if (wprops == null) { wprops = new WDesktopProperties(this); - updateProperties(); + updateProperties(wprops.getProperties()); } } @@ -929,25 +933,36 @@ public final class WToolkit extends SunToolkit implements Runnable { * Windows doesn't always send WM_SETTINGCHANGE when it should. */ private void windowsSettingChange() { + // JDK-8039383: Have to update the value of XPSTYLE_THEME_ACTIVE property + // as soon as possible to prevent NPE and other errors because theme data + // has become unavailable. + final Map<String, Object> props = getWProps(); + if (props == null) { + // props has not been initialized, so we have nothing to update + return; + } + + updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); + if (AppContext.getAppContext() == null) { // We cannot post the update to any EventQueue. Listeners will // be called on EDTs by DesktopPropertyChangeSupport - updateProperties(); + updateProperties(props); } else { // Cannot update on Toolkit thread. // DesktopPropertyChangeSupport will call listeners on Toolkit // thread if it has AppContext (standalone mode) - EventQueue.invokeLater(this::updateProperties); + EventQueue.invokeLater(() -> updateProperties(props)); } } - private synchronized void updateProperties() { - if (null == wprops) { - // wprops has not been initialized, so we have nothing to update + private synchronized void updateProperties(final Map<String, Object> props) { + if (null == props) { return; } - Map<String, Object> props = wprops.getProperties(); + updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); + for (String propName : props.keySet()) { Object val = props.get(propName); if (log.isLoggable(PlatformLogger.Level.FINER)) { @@ -957,6 +972,14 @@ public final class WToolkit extends SunToolkit implements Runnable { } } + private synchronized Map<String, Object> getWProps() { + return (wprops != null) ? wprops.getProperties() : null; + } + + private void updateXPStyleEnabled(final Object dskProp) { + ThemeReader.xpStyleEnabled = Boolean.TRUE.equals(dskProp); + } + @Override public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { if (name == null) { @@ -978,6 +1001,7 @@ public final class WToolkit extends SunToolkit implements Runnable { * initialize only static props here and do not try to initialize props which depends on wprops, * this should be done in lazilyLoadDesktopProperty() only. */ + @Override protected synchronized void initializeDesktopProperties() { desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50)); diff --git a/src/windows/native/sun/java2d/d3d/D3DBufImgOps.cpp b/src/windows/native/sun/java2d/d3d/D3DBufImgOps.cpp index 5cf484279..b8b1ec892 100644 --- a/src/windows/native/sun/java2d/d3d/D3DBufImgOps.cpp +++ b/src/windows/native/sun/java2d/d3d/D3DBufImgOps.cpp @@ -201,6 +201,9 @@ D3DBufImgOps_EnableLookupOp(D3DContext *d3dc, int i; jint flags = 0; + for (i = 0; i < 4; i++) { + bands[i] = NULL; + } J2dTraceLn4(J2D_TRACE_INFO, "D3DBufImgOps_EnableLookupOp: short=%d num=%d len=%d off=%d", shortData, numBands, bandLength, offset); diff --git a/src/windows/native/sun/security/krb5/NativeCreds.c b/src/windows/native/sun/security/krb5/NativeCreds.c index 7431333dc..ab0ee036e 100644 --- a/src/windows/native/sun/security/krb5/NativeCreds.c +++ b/src/windows/native/sun/security/krb5/NativeCreds.c @@ -463,6 +463,10 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ netypes = (*env)->GetArrayLength(env, jetypes); etypes = (jint *) (*env)->GetIntArrayElements(env, jetypes, NULL); + if (etypes == NULL) { + break; + } + // check TGT validity if (native_debug) { printf("LSA: TICKET SessionKey KeyType is %d\n", msticket->SessionKey.KeyType); @@ -952,8 +956,7 @@ jobject BuildPrincipal(JNIEnv *env, PKERB_EXTERNAL_NAME principalName, if (native_debug) { printf("LSA: Can't allocate String array for Principal\n"); } - LocalFree(realm); - return principal; + goto cleanup; } for (i=0; i<nameCount; i++) { @@ -963,18 +966,32 @@ jobject BuildPrincipal(JNIEnv *env, PKERB_EXTERNAL_NAME principalName, // OK, got a Char array, so construct a String tempString = (*env)->NewString(env, (const jchar*)scanner->Buffer, scanner->Length/sizeof(WCHAR)); + + if (tempString == NULL) { + goto cleanup; + } + // Set the String into the StringArray (*env)->SetObjectArrayElement(env, stringArray, i, tempString); + if ((*env)->ExceptionCheck(env)) { + goto cleanup; + } + // Do I have to worry about storage reclamation here? } // now set the realm in the principal realmLen = (ULONG)wcslen((PWCHAR)realm); realmStr = (*env)->NewString(env, (PWCHAR)realm, (USHORT)realmLen); + if (realmStr == NULL) { + goto cleanup; + } + principal = (*env)->NewObject(env, principalNameClass, principalNameConstructor, stringArray, realmStr); +cleanup: // free local resources LocalFree(realm); diff --git a/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c b/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c index 8d7f753aa..d239f0214 100644 --- a/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c +++ b/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,11 +59,16 @@ JNIEXPORT jboolean JNICALL Java_sun_security_provider_NativeSeedGenerator_native numBytes = (*env)->GetArrayLength(env, randArray); randBytes = (*env)->GetByteArrayElements(env, randArray, NULL); + if (randBytes == NULL) { + goto cleanup; + } + if (CryptGenRandom(hCryptProv, numBytes, randBytes)) { result = JNI_TRUE; } (*env)->ReleaseByteArrayElements(env, randArray, randBytes, 0); +cleanup: CryptReleaseContext(hCryptProv, 0); return result; diff --git a/src/windows/native/sun/windows/awt_Component.cpp b/src/windows/native/sun/windows/awt_Component.cpp index bb8015be4..5ab74c7e8 100644 --- a/src/windows/native/sun/windows/awt_Component.cpp +++ b/src/windows/native/sun/windows/awt_Component.cpp @@ -492,7 +492,12 @@ AwtComponent::CreateHWnd(JNIEnv *env, LPCWSTR title, * member is referred in the GetClassName method of AwtLabel class. * So m_peerObject member must be set here. */ - m_peerObject = env->NewGlobalRef(peer); + if (m_peerObject == NULL) { + m_peerObject = env->NewGlobalRef(peer); + } else { + assert(env->IsSameObject(m_peerObject, peer)); + } + RegisterClass(); jobject target = env->GetObjectField(peer, AwtObject::targetID); @@ -6930,9 +6935,9 @@ Java_sun_awt_windows_WComponentPeer_nativeHandlesWheelScrolling (JNIEnv* env, { TRY; - return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall( + return (jboolean)AwtToolkit::GetInstance().SyncCall( (void *(*)(void *))AwtComponent::_NativeHandlesWheelScrolling, - env->NewGlobalRef(self))); + env->NewGlobalRef(self)); // global ref is deleted in _NativeHandlesWheelScrolling CATCH_BAD_ALLOC_RET(NULL); @@ -6951,9 +6956,9 @@ Java_sun_awt_windows_WComponentPeer_isObscured(JNIEnv* env, jobject selfGlobalRef = env->NewGlobalRef(self); - return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall( + return (jboolean)AwtToolkit::GetInstance().SyncCall( (void*(*)(void*))AwtComponent::_IsObscured, - (void *)selfGlobalRef)); + (void *)selfGlobalRef); // selfGlobalRef is deleted in _IsObscured CATCH_BAD_ALLOC_RET(NULL); diff --git a/src/windows/native/sun/windows/awt_List.cpp b/src/windows/native/sun/windows/awt_List.cpp index c6cec8fe0..5188c8598 100644 --- a/src/windows/native/sun/windows/awt_List.cpp +++ b/src/windows/native/sun/windows/awt_List.cpp @@ -1018,8 +1018,8 @@ Java_sun_awt_windows_WListPeer_isSelected(JNIEnv *env, jobject self, ses->list = env->NewGlobalRef(self); ses->index = index; - return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall( - (void *(*)(void *))AwtList::_IsSelected, ses)); + return (jboolean)AwtToolkit::GetInstance().SyncCall( + (void *(*)(void *))AwtList::_IsSelected, ses); // global ref and ses are deleted in _IsSelected CATCH_BAD_ALLOC_RET(FALSE); |