changeset 9542:4edaec5f08c0 jdk8u20-b13

Merge
author lana
date Thu, 01 May 2014 00:00:08 -0700
parents 6be37bafb11a (current diff) 715bb30f208a (diff)
children bf4acb74e4a8 5dfe489600e2
files src/share/classes/javax/swing/text/html/ResourceLoader.java src/share/classes/javax/swing/text/html/parser/ResourceLoader.java
diffstat 74 files changed, 3016 insertions(+), 1107 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/beans/util/Cache.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/com/sun/beans/util/Cache.java	Thu May 01 00:00:08 2014 -0700
@@ -119,13 +119,13 @@
         synchronized (this.queue) {
             // synchronized search improves stability
             // we must create and add new value if there are no needed entry
-            int index = index(hash, this.table);
-            current = getEntryValue(key, hash, this.table[index]);
+            current = getEntryValue(key, hash, this.table[index(hash, this.table)]);
             if (current != null) {
                 return current;
             }
             V value = create(key);
             Objects.requireNonNull(value, "value");
+            int index = index(hash, this.table);
             this.table[index] = new CacheEntry<>(hash, key, value, this.table[index]);
             if (++this.size >= this.threshold) {
                 if (this.table.length == MAXIMUM_CAPACITY) {
--- a/src/share/classes/com/sun/jarsigner/ContentSignerParameters.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/com/sun/jarsigner/ContentSignerParameters.java	Thu May 01 00:00:08 2014 -0700
@@ -35,7 +35,7 @@
  * @since 1.5
  * @author Vincent Ryan
  */
-
+@jdk.Exported
 public interface ContentSignerParameters {
 
     /**
@@ -64,7 +64,9 @@
      *
      * @return The TSAPolicyID. May be null.
      */
-    public String getTSAPolicyID();
+    public default String getTSAPolicyID() {
+        return null;
+    }
 
     /**
      * Retrieves the JAR file's signature.
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java	Thu May 01 00:00:08 2014 -0700
@@ -51,6 +51,8 @@
 public class WindowsScrollBarUI extends BasicScrollBarUI {
     private Grid thumbGrid;
     private Grid highlightGrid;
+    private Dimension horizontalThumbSize;
+    private Dimension verticalThumbSize;
 
     /**
      * Creates a UI for a JScrollBar.
@@ -65,11 +67,32 @@
     protected void installDefaults() {
         super.installDefaults();
 
-        if (XPStyle.getXP() != null) {
+        XPStyle xp = XPStyle.getXP();
+        if (xp != null) {
             scrollbar.setBorder(null);
+            horizontalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNHORZ);
+            verticalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNVERT);
+        } else {
+            horizontalThumbSize = null;
+            verticalThumbSize = null;
         }
     }
 
+    private static Dimension getSize(Component component, XPStyle xp, Part part) {
+        Skin skin = xp.getSkin(component, part);
+        return new Dimension(skin.getWidth(), skin.getHeight());
+    }
+
+    @Override
+    protected Dimension getMinimumThumbSize() {
+        if ((horizontalThumbSize == null) || (verticalThumbSize == null)) {
+            return super.getMinimumThumbSize();
+        }
+        return JScrollBar.HORIZONTAL == scrollbar.getOrientation()
+                ? horizontalThumbSize
+                : verticalThumbSize;
+    }
+
     public void uninstallUI(JComponent c) {
         super.uninstallUI(c);
         thumbGrid = highlightGrid = null;
--- a/src/share/classes/java/beans/MethodDescriptor.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/beans/MethodDescriptor.java	Thu May 01 00:00:08 2014 -0700
@@ -162,6 +162,16 @@
                 : null;
     }
 
+    private static Method resolve(Method oldMethod, Method newMethod) {
+        if (oldMethod == null) {
+            return newMethod;
+        }
+        if (newMethod == null) {
+            return oldMethod;
+        }
+        return !oldMethod.isSynthetic() && newMethod.isSynthetic() ? oldMethod : newMethod;
+    }
+
     /*
      * Package-private constructor
      * Merge two method descriptors.  Where they conflict, give the
@@ -173,8 +183,7 @@
     MethodDescriptor(MethodDescriptor x, MethodDescriptor y) {
         super(x, y);
 
-        Method method = y.methodRef.get();
-        this.methodRef.set(null != method ? method : x.methodRef.get());
+        this.methodRef.set(resolve(x.methodRef.get(), y.methodRef.get()));
         params = x.params;
         if (y.params != null) {
             params = y.params;
--- a/src/share/classes/java/io/ObjectOutputStream.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/io/ObjectOutputStream.java	Thu May 01 00:00:08 2014 -0700
@@ -1255,7 +1255,7 @@
         }
 
         bout.setBlockDataMode(true);
-        if (isCustomSubclass()) {
+        if (cl != null && isCustomSubclass()) {
             ReflectUtil.checkPackageAccess(cl);
         }
         annotateProxyClass(cl);
@@ -1284,7 +1284,7 @@
 
         Class<?> cl = desc.forClass();
         bout.setBlockDataMode(true);
-        if (isCustomSubclass()) {
+        if (cl != null && isCustomSubclass()) {
             ReflectUtil.checkPackageAccess(cl);
         }
         annotateClass(cl);
--- a/src/share/classes/java/time/format/DateTimeFormatter.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/time/format/DateTimeFormatter.java	Thu May 01 00:00:08 2014 -0700
@@ -1934,8 +1934,8 @@
      */
     private TemporalAccessor parseResolved0(final CharSequence text, final ParsePosition position) {
         ParsePosition pos = (position != null ? position : new ParsePosition(0));
-        Parsed unresolved = parseUnresolved0(text, pos);
-        if (unresolved == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) {
+        DateTimeParseContext context = parseUnresolved0(text, pos);
+        if (context == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) {
             String abbr;
             if (text.length() > 64) {
                 abbr = text.subSequence(0, 64).toString() + "...";
@@ -1950,7 +1950,7 @@
                         pos.getIndex(), text, pos.getIndex());
             }
         }
-        return unresolved.resolve(resolverStyle, resolverFields);
+        return context.toResolved(resolverStyle, resolverFields);
     }
 
     /**
@@ -1993,10 +1993,14 @@
      * @throws IndexOutOfBoundsException if the position is invalid
      */
     public TemporalAccessor parseUnresolved(CharSequence text, ParsePosition position) {
-        return parseUnresolved0(text, position);
+        DateTimeParseContext context = parseUnresolved0(text, position);
+        if (context == null) {
+            return null;
+        }
+        return context.toUnresolved();
     }
 
-    private Parsed parseUnresolved0(CharSequence text, ParsePosition position) {
+    private DateTimeParseContext parseUnresolved0(CharSequence text, ParsePosition position) {
         Objects.requireNonNull(text, "text");
         Objects.requireNonNull(position, "position");
         DateTimeParseContext context = new DateTimeParseContext(this);
@@ -2007,7 +2011,7 @@
             return null;
         }
         position.setIndex(pos);  // errorIndex not updated from input
-        return context.toParsed();
+        return context;
     }
 
     //-----------------------------------------------------------------------
@@ -2128,23 +2132,23 @@
         @Override
         public Object parseObject(String text, ParsePosition pos) {
             Objects.requireNonNull(text, "text");
-            Parsed unresolved;
+            DateTimeParseContext context;
             try {
-                unresolved = formatter.parseUnresolved0(text, pos);
+                context = formatter.parseUnresolved0(text, pos);
             } catch (IndexOutOfBoundsException ex) {
                 if (pos.getErrorIndex() < 0) {
                     pos.setErrorIndex(0);
                 }
                 return null;
             }
-            if (unresolved == null) {
+            if (context == null) {
                 if (pos.getErrorIndex() < 0) {
                     pos.setErrorIndex(0);
                 }
                 return null;
             }
             try {
-                TemporalAccessor resolved = unresolved.resolve(formatter.resolverStyle, formatter.resolverFields);
+                TemporalAccessor resolved = context.toResolved(formatter.resolverStyle, formatter.resolverFields);
                 if (parseType == null) {
                     return resolved;
                 }
--- a/src/share/classes/java/time/format/DateTimeParseContext.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/time/format/DateTimeParseContext.java	Thu May 01 00:00:08 2014 -0700
@@ -64,10 +64,12 @@
 import java.time.ZoneId;
 import java.time.chrono.Chronology;
 import java.time.chrono.IsoChronology;
+import java.time.temporal.TemporalAccessor;
 import java.time.temporal.TemporalField;
 import java.util.ArrayList;
 import java.util.Locale;
 import java.util.Objects;
+import java.util.Set;
 import java.util.function.Consumer;
 
 /**
@@ -77,8 +79,8 @@
  * It has the ability to store and retrieve the parsed values and manage optional segments.
  * It also provides key information to the parsing methods.
  * <p>
- * Once parsing is complete, the {@link #toParsed()} is used to obtain the data.
- * It contains a method to resolve  the separate parsed fields into meaningful values.
+ * Once parsing is complete, the {@link #toUnresolved()} is used to obtain the unresolved
+ * result data. The {@link #toResolved()} is used to obtain the resolved result.
  *
  * @implSpec
  * This class is a mutable context intended for use from a single thread.
@@ -309,16 +311,27 @@
     }
 
     /**
-     * Gets the result of the parse.
+     * Gets the unresolved result of the parse.
      *
      * @return the result of the parse, not null
      */
-    Parsed toParsed() {
+    Parsed toUnresolved() {
+        return currentParsed();
+    }
+
+    /**
+     * Gets the resolved result of the parse.
+     *
+     * @return the result of the parse, not null
+     */
+    TemporalAccessor toResolved(ResolverStyle resolverStyle, Set<TemporalField> resolverFields) {
         Parsed parsed = currentParsed();
-        parsed.effectiveChrono = getEffectiveChronology();
-        return parsed;
+        parsed.chrono = getEffectiveChronology();
+        parsed.zone = (parsed.zone != null ? parsed.zone : formatter.getZone());
+        return parsed.resolve(resolverStyle, resolverFields);
     }
 
+
     //-----------------------------------------------------------------------
     /**
      * Gets the first value that was parsed for the specified field.
--- a/src/share/classes/java/time/format/Parsed.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/time/format/Parsed.java	Thu May 01 00:00:08 2014 -0700
@@ -136,10 +136,6 @@
      */
     boolean leapSecond;
     /**
-     * The effective chronology.
-     */
-    Chronology effectiveChrono;
-    /**
      * The resolver style to use.
      */
     private ResolverStyle resolverStyle;
@@ -241,7 +237,6 @@
             fieldValues.keySet().retainAll(resolverFields);
         }
         this.resolverStyle = resolverStyle;
-        chrono = effectiveChrono;
         resolveFields();
         resolveTimeLenient();
         crossCheck();
@@ -266,14 +261,16 @@
                     TemporalAccessor resolvedObject = targetField.resolve(fieldValues, this, resolverStyle);
                     if (resolvedObject != null) {
                         if (resolvedObject instanceof ChronoZonedDateTime) {
-                            ChronoZonedDateTime<?> czdt = (ChronoZonedDateTime) resolvedObject;
-                            if (zone.equals(czdt.getZone()) == false) {
+                            ChronoZonedDateTime<?> czdt = (ChronoZonedDateTime<?>) resolvedObject;
+                            if (zone == null) {
+                                zone = czdt.getZone();
+                            } else if (zone.equals(czdt.getZone()) == false) {
                                 throw new DateTimeException("ChronoZonedDateTime must use the effective parsed zone: " + zone);
                             }
                             resolvedObject = czdt.toLocalDateTime();
                         }
                         if (resolvedObject instanceof ChronoLocalDateTime) {
-                            ChronoLocalDateTime<?> cldt = (ChronoLocalDateTime) resolvedObject;
+                            ChronoLocalDateTime<?> cldt = (ChronoLocalDateTime<?>) resolvedObject;
                             updateCheckConflict(cldt.toLocalTime(), Period.ZERO);
                             updateCheckConflict(cldt.toLocalDate());
                             changedCount++;
--- a/src/share/classes/java/util/ArrayList.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/util/ArrayList.java	Thu May 01 00:00:08 2014 -0700
@@ -119,10 +119,17 @@
     private static final Object[] EMPTY_ELEMENTDATA = {};
 
     /**
+     * Shared empty array instance used for default sized empty instances. We
+     * distinguish this from EMPTY_ELEMENTDATA to know how much to inflate when
+     * first element is added.
+     */
+    private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = {};
+
+    /**
      * The array buffer into which the elements of the ArrayList are stored.
      * The capacity of the ArrayList is the length of this array buffer. Any
-     * empty ArrayList with elementData == EMPTY_ELEMENTDATA will be expanded to
-     * DEFAULT_CAPACITY when the first element is added.
+     * empty ArrayList with elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA
+     * will be expanded to DEFAULT_CAPACITY when the first element is added.
      */
     transient Object[] elementData; // non-private to simplify nested class access
 
@@ -141,19 +148,21 @@
      *         is negative
      */
     public ArrayList(int initialCapacity) {
-        super();
-        if (initialCapacity < 0)
+        if (initialCapacity > 0) {
+            this.elementData = new Object[initialCapacity];
+        } else if (initialCapacity == 0) {
+            this.elementData = EMPTY_ELEMENTDATA;
+        } else {
             throw new IllegalArgumentException("Illegal Capacity: "+
                                                initialCapacity);
-        this.elementData = new Object[initialCapacity];
+        }
     }
 
     /**
      * Constructs an empty list with an initial capacity of ten.
      */
     public ArrayList() {
-        super();
-        this.elementData = EMPTY_ELEMENTDATA;
+        this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;
     }
 
     /**
@@ -166,10 +175,14 @@
      */
     public ArrayList(Collection<? extends E> c) {
         elementData = c.toArray();
-        size = elementData.length;
-        // c.toArray might (incorrectly) not return Object[] (see 6260652)
-        if (elementData.getClass() != Object[].class)
-            elementData = Arrays.copyOf(elementData, size, Object[].class);
+        if ((size = elementData.length) != 0) {
+            // c.toArray might (incorrectly) not return Object[] (see 6260652)
+            if (elementData.getClass() != Object[].class)
+                elementData = Arrays.copyOf(elementData, size, Object[].class);
+        } else {
+            // replace with empty array.
+            this.elementData = EMPTY_ELEMENTDATA;
+        }
     }
 
     /**
@@ -180,7 +193,9 @@
     public void trimToSize() {
         modCount++;
         if (size < elementData.length) {
-            elementData = Arrays.copyOf(elementData, size);
+            elementData = (size == 0)
+              ? EMPTY_ELEMENTDATA
+              : Arrays.copyOf(elementData, size);
         }
     }
 
@@ -192,11 +207,11 @@
      * @param   minCapacity   the desired minimum capacity
      */
     public void ensureCapacity(int minCapacity) {
-        int minExpand = (elementData != EMPTY_ELEMENTDATA)
-            // any size if real element table
+        int minExpand = (elementData != DEFAULTCAPACITY_EMPTY_ELEMENTDATA)
+            // any size if not default element table
             ? 0
-            // larger than default for empty table. It's already supposed to be
-            // at default size.
+            // larger than default for default empty table. It's already
+            // supposed to be at default size.
             : DEFAULT_CAPACITY;
 
         if (minCapacity > minExpand) {
@@ -205,7 +220,7 @@
     }
 
     private void ensureCapacityInternal(int minCapacity) {
-        if (elementData == EMPTY_ELEMENTDATA) {
+        if (elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA) {
             minCapacity = Math.max(DEFAULT_CAPACITY, minCapacity);
         }
 
--- a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu May 01 00:00:08 2014 -0700
@@ -1400,7 +1400,7 @@
             lock.lock();
             try {
                 checkForComodification();
-                if (fromIndex < 0 || toIndex > size)
+                if (fromIndex < 0 || toIndex > size || fromIndex > toIndex)
                     throw new IndexOutOfBoundsException();
                 return new COWSubList<E>(l, fromIndex + offset,
                                          toIndex + offset);
--- a/src/share/classes/java/util/zip/ZipFile.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/java/util/zip/ZipFile.java	Thu May 01 00:00:08 2014 -0700
@@ -700,24 +700,26 @@
         }
 
         public int read(byte b[], int off, int len) throws IOException {
-            if (rem == 0) {
-                return -1;
-            }
-            if (len <= 0) {
-                return 0;
-            }
-            if (len > rem) {
-                len = (int) rem;
-            }
             synchronized (ZipFile.this) {
+                long rem = this.rem;
+                long pos = this.pos;
+                if (rem == 0) {
+                    return -1;
+                }
+                if (len <= 0) {
+                    return 0;
+                }
+                if (len > rem) {
+                    len = (int) rem;
+                }
+
                 ensureOpenOrZipException();
-
                 len = ZipFile.read(ZipFile.this.jzfile, jzentry, pos, b,
                                    off, len);
-            }
-            if (len > 0) {
-                pos += len;
-                rem -= len;
+                if (len > 0) {
+                    this.pos = (pos + len);
+                    this.rem = (rem - len);
+                }
             }
             if (rem == 0) {
                 close();
--- a/src/share/classes/javax/accessibility/AccessibleContext.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/accessibility/AccessibleContext.java	Thu May 01 00:00:08 2014 -0700
@@ -25,6 +25,9 @@
 
 package javax.accessibility;
 
+import sun.awt.AWTAccessor;
+import sun.awt.AppContext;
+
 import java.util.Locale;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
@@ -79,6 +82,26 @@
  */
 public abstract class AccessibleContext {
 
+    /**
+     * The AppContext that should be used to dispatch events for this
+     * AccessibleContext
+     */
+    private volatile AppContext targetAppContext;
+
+    static {
+        AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() {
+            @Override
+            public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) {
+                accessibleContext.targetAppContext = appContext;
+            }
+
+            @Override
+            public AppContext getAppContext(AccessibleContext accessibleContext) {
+                return accessibleContext.targetAppContext;
+            }
+        });
+    }
+
    /**
     * Constant used to determine when the accessibleName property has
     * changed.  The old value in the PropertyChangeEvent will be the old
--- a/src/share/classes/javax/swing/JTable.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/swing/JTable.java	Thu May 01 00:00:08 2014 -0700
@@ -34,7 +34,6 @@
 
 import java.beans.*;
 
-import java.io.Serializable;
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
 import java.io.IOException;
@@ -58,7 +57,6 @@
 import sun.swing.SwingUtilities2.Section;
 import static sun.swing.SwingUtilities2.Section.*;
 import sun.swing.PrintingStatus;
-import sun.swing.SwingLazyValue;
 
 /**
  * The <code>JTable</code> is used to display and edit regular two-dimensional tables
@@ -5307,14 +5305,6 @@
         return retValue;
     }
 
-    private void setLazyValue(Hashtable h, Class c, String s) {
-        h.put(c, new SwingLazyValue(s));
-    }
-
-    private void setLazyRenderer(Class c, String s) {
-        setLazyValue(defaultRenderersByColumnClass, c, s);
-    }
-
     /**
      * Creates default cell renderers for objects, numbers, doubles, dates,
      * booleans, and icons.
@@ -5325,24 +5315,24 @@
         defaultRenderersByColumnClass = new UIDefaults(8, 0.75f);
 
         // Objects
-        setLazyRenderer(Object.class, "javax.swing.table.DefaultTableCellRenderer$UIResource");
+        defaultRenderersByColumnClass.put(Object.class, (UIDefaults.LazyValue) t -> new DefaultTableCellRenderer.UIResource());
 
         // Numbers
-        setLazyRenderer(Number.class, "javax.swing.JTable$NumberRenderer");
+        defaultRenderersByColumnClass.put(Number.class, (UIDefaults.LazyValue) t -> new NumberRenderer());
 
         // Doubles and Floats
-        setLazyRenderer(Float.class, "javax.swing.JTable$DoubleRenderer");
-        setLazyRenderer(Double.class, "javax.swing.JTable$DoubleRenderer");
+        defaultRenderersByColumnClass.put(Float.class, (UIDefaults.LazyValue) t -> new DoubleRenderer());
+        defaultRenderersByColumnClass.put(Double.class, (UIDefaults.LazyValue) t -> new DoubleRenderer());
 
         // Dates
-        setLazyRenderer(Date.class, "javax.swing.JTable$DateRenderer");
+        defaultRenderersByColumnClass.put(Date.class, (UIDefaults.LazyValue) t -> new DateRenderer());
 
         // Icons and ImageIcons
-        setLazyRenderer(Icon.class, "javax.swing.JTable$IconRenderer");
-        setLazyRenderer(ImageIcon.class, "javax.swing.JTable$IconRenderer");
+        defaultRenderersByColumnClass.put(Icon.class, (UIDefaults.LazyValue) t -> new IconRenderer());
+        defaultRenderersByColumnClass.put(ImageIcon.class, (UIDefaults.LazyValue) t -> new IconRenderer());
 
         // Booleans
-        setLazyRenderer(Boolean.class, "javax.swing.JTable$BooleanRenderer");
+        defaultRenderersByColumnClass.put(Boolean.class, (UIDefaults.LazyValue) t -> new BooleanRenderer());
     }
 
     /**
@@ -5420,10 +5410,6 @@
         }
     }
 
-    private void setLazyEditor(Class c, String s) {
-        setLazyValue(defaultEditorsByColumnClass, c, s);
-    }
-
     /**
      * Creates default cell editors for objects, numbers, and boolean values.
      * @see DefaultCellEditor
@@ -5432,13 +5418,13 @@
         defaultEditorsByColumnClass = new UIDefaults(3, 0.75f);
 
         // Objects
-        setLazyEditor(Object.class, "javax.swing.JTable$GenericEditor");
+        defaultEditorsByColumnClass.put(Object.class, (UIDefaults.LazyValue) t -> new GenericEditor());
 
         // Numbers
-        setLazyEditor(Number.class, "javax.swing.JTable$NumberEditor");
+        defaultEditorsByColumnClass.put(Number.class, (UIDefaults.LazyValue) t -> new NumberEditor());
 
         // Booleans
-        setLazyEditor(Boolean.class, "javax.swing.JTable$BooleanEditor");
+        defaultEditorsByColumnClass.put(Boolean.class, (UIDefaults.LazyValue) t -> new BooleanEditor());
     }
 
     /**
@@ -6588,8 +6574,8 @@
     TableColumnModelListener, CellEditorListener, PropertyChangeListener,
     AccessibleExtendedTable {
 
-        int lastSelectedRow;
-        int lastSelectedCol;
+        int previousFocusedRow;
+        int previousFocusedCol;
 
         /**
          * AccessibleJTable constructor
@@ -6604,8 +6590,10 @@
             tcm.addColumnModelListener(this);
             tcm.getSelectionModel().addListSelectionListener(this);
             JTable.this.getModel().addTableModelListener(this);
-            lastSelectedRow = JTable.this.getSelectedRow();
-            lastSelectedCol = JTable.this.getSelectedColumn();
+            previousFocusedRow = JTable.this.getSelectionModel().
+                                        getLeadSelectionIndex();
+            previousFocusedCol = JTable.this.getColumnModel().
+                                        getSelectionModel().getLeadSelectionIndex();
         }
 
     // Listeners to track model, etc. changes to as to re-place the other
@@ -6933,18 +6921,21 @@
             firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
                                Boolean.valueOf(false), Boolean.valueOf(true));
 
-            int selectedRow = JTable.this.getSelectedRow();
-            int selectedCol = JTable.this.getSelectedColumn();
-            if (selectedRow != lastSelectedRow ||
-                selectedCol != lastSelectedCol) {
-                Accessible oldA = getAccessibleAt(lastSelectedRow,
-                                                  lastSelectedCol);
-                Accessible newA = getAccessibleAt(selectedRow, selectedCol);
+            // Using lead selection index to cover both cases: node selected and node
+            // is focused but not selected (Ctrl+up/down)
+            int focusedRow = JTable.this.getSelectionModel().getLeadSelectionIndex();
+            int focusedCol = JTable.this.getColumnModel().getSelectionModel().
+                                                            getLeadSelectionIndex();
+
+            if (focusedRow != previousFocusedRow ||
+                focusedCol != previousFocusedCol) {
+                Accessible oldA = getAccessibleAt(previousFocusedRow, previousFocusedCol);
+                Accessible newA = getAccessibleAt(focusedRow, focusedCol);
                 firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
-                                   oldA, newA);
-                 lastSelectedRow = selectedRow;
-                 lastSelectedCol = selectedCol;
-             }
+                                    oldA, newA);
+                previousFocusedRow = focusedRow;
+                previousFocusedCol = focusedCol;
+            }
         }
 
 
--- a/src/share/classes/javax/swing/JTree.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/swing/JTree.java	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -1664,6 +1664,11 @@
 
         leadPath = newPath;
         firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, newPath);
+
+        if (accessibleContext != null){
+            ((AccessibleJTree)accessibleContext).
+                fireActiveDescendantPropertyChange(oldValue, newPath);
+        }
     }
 
     /**
@@ -4129,23 +4134,6 @@
          *
          */
         public void valueChanged(TreeSelectionEvent e) {
-            // Fixes 4546503 - JTree is sending incorrect active
-            // descendant events
-            TreePath oldLeadSelectionPath = e.getOldLeadSelectionPath();
-            leadSelectionPath = e.getNewLeadSelectionPath();
-
-            if (oldLeadSelectionPath != leadSelectionPath) {
-                // Set parent to null so AccessibleJTreeNode computes
-                // its parent.
-                Accessible oldLSA = leadSelectionAccessible;
-                leadSelectionAccessible = (leadSelectionPath != null)
-                        ? new AccessibleJTreeNode(JTree.this,
-                                                  leadSelectionPath,
-                                                  null) // parent
-                        : null;
-                firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
-                                   oldLSA, leadSelectionAccessible);
-            }
             firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
                                Boolean.valueOf(false), Boolean.valueOf(true));
         }
@@ -4249,6 +4237,34 @@
             }
         }
 
+        /**
+        *  Fire an active descendant property change notification.
+        *  The active descendant is used for objects such as list,
+        *  tree, and table, which may have transient children.
+        *  It notifies screen readers the active child of the component
+        *  has been changed so user can be notified from there.
+        *
+        * @param oldPath - lead path of previous active child
+        * @param newPath - lead path of current active child
+        *
+        */
+        void fireActiveDescendantPropertyChange(TreePath oldPath, TreePath newPath){
+            if(oldPath != newPath){
+                Accessible oldLSA = (oldPath != null)
+                                    ? new AccessibleJTreeNode(JTree.this,
+                                                              oldPath,
+                                                              null)
+                                    : null;
+
+                Accessible newLSA = (newPath != null)
+                                    ? new AccessibleJTreeNode(JTree.this,
+                                                              newPath,
+                                                              null)
+                                    : null;
+                firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
+                                                                oldLSA, newLSA);
+            }
+        }
 
         private AccessibleContext getCurrentAccessibleContext() {
             Component c = getCurrentComponent();
--- a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Thu May 01 00:00:08 2014 -0700
@@ -32,15 +32,13 @@
 import javax.swing.*;
 import javax.swing.plaf.basic.*;
 import javax.swing.text.DefaultEditorKit;
+import javax.swing.UIDefaults.LazyValue;
 
 import java.awt.Color;
-import java.awt.event.KeyEvent;
-import java.lang.reflect.*;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
 
 import java.security.AccessController;
-import java.security.PrivilegedAction;
 
 import sun.awt.*;
 import sun.security.action.GetPropertyAction;
@@ -460,11 +458,9 @@
             new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
                                           "getTextFieldBorder");
 
-        Object dialogBorder = new MetalLazyValue(
-                          "javax.swing.plaf.metal.MetalBorders$DialogBorder");
+        LazyValue dialogBorder = t -> new MetalBorders.DialogBorder();
 
-        Object questionDialogBorder = new MetalLazyValue(
-                  "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        LazyValue questionDialogBorder = t -> new MetalBorders.QuestionDialogBorder();
 
         Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
                            "ctrl C", DefaultEditorKit.copyAction,
@@ -1494,12 +1490,8 @@
             "ToolBar.floatingBackground", menuBackground,
             "ToolBar.dockingForeground", primaryControlDarkShadow,
             "ToolBar.floatingForeground", primaryControl,
-            "ToolBar.rolloverBorder", new MetalLazyValue(
-                         "javax.swing.plaf.metal.MetalBorders",
-                         "getToolBarRolloverBorder"),
-            "ToolBar.nonrolloverBorder", new MetalLazyValue(
-                         "javax.swing.plaf.metal.MetalBorders",
-                         "getToolBarNonrolloverBorder"),
+            "ToolBar.rolloverBorder", (LazyValue) t -> MetalBorders.getToolBarRolloverBorder(),
+            "ToolBar.nonrolloverBorder", (LazyValue) t -> MetalBorders.getToolBarNonrolloverBorder(),
             "ToolBar.ancestorInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
                         "UP", "navigateUp",
@@ -1513,17 +1505,14 @@
                  }),
 
             // RootPane
-            "RootPane.frameBorder", new MetalLazyValue(
-                      "javax.swing.plaf.metal.MetalBorders$FrameBorder"),
+            "RootPane.frameBorder", (LazyValue) t -> new MetalBorders.FrameBorder(),
             "RootPane.plainDialogBorder", dialogBorder,
             "RootPane.informationDialogBorder", dialogBorder,
-            "RootPane.errorDialogBorder", new MetalLazyValue(
-                      "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"),
+            "RootPane.errorDialogBorder", (LazyValue) t -> new MetalBorders.ErrorDialogBorder(),
             "RootPane.colorChooserDialogBorder", questionDialogBorder,
             "RootPane.fileChooserDialogBorder", questionDialogBorder,
             "RootPane.questionDialogBorder", questionDialogBorder,
-            "RootPane.warningDialogBorder", new MetalLazyValue(
-                    "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"),
+            "RootPane.warningDialogBorder", (LazyValue) t -> new MetalBorders.WarningDialogBorder(),
             // These bindings are only enabled when there is a default
             // button set on the rootpane.
             "RootPane.defaultButtonWindowKeyBindings", new Object[] {
@@ -2175,61 +2164,6 @@
 
 
     /**
-     * MetalLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>.
-     * The code is duplicate so that it can get at the package private
-     * classes in metal.
-     */
-    private static class MetalLazyValue implements UIDefaults.LazyValue {
-        /**
-         * Name of the class to create.
-         */
-        private String className;
-        private String methodName;
-
-        MetalLazyValue(String name) {
-            this.className = name;
-        }
-
-        MetalLazyValue(String name, String methodName) {
-            this(name);
-            this.methodName = methodName;
-        }
-
-        public Object createValue(UIDefaults table) {
-            try {
-                final Class c = Class.forName(className);
-
-                if (methodName == null) {
-                    return c.newInstance();
-                }
-                Method method = AccessController.doPrivileged(
-                    new PrivilegedAction<Method>() {
-                    public Method run() {
-                        Method[] methods = c.getDeclaredMethods();
-                        for (int counter = methods.length - 1; counter >= 0;
-                             counter--) {
-                            if (methods[counter].getName().equals(methodName)){
-                                methods[counter].setAccessible(true);
-                                return methods[counter];
-                            }
-                        }
-                        return null;
-                    }
-                });
-                if (method != null) {
-                    return method.invoke(null, (Object[])null);
-                }
-            } catch (ClassNotFoundException cnfe) {
-            } catch (InstantiationException ie) {
-            } catch (IllegalAccessException iae) {
-            } catch (InvocationTargetException ite) {
-            }
-            return null;
-        }
-    }
-
-
-    /**
      * FontActiveValue redirects to the appropriate metal theme method.
      */
     private static class FontActiveValue implements UIDefaults.ActiveValue {
--- a/src/share/classes/javax/swing/text/JTextComponent.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/swing/text/JTextComponent.java	Thu May 01 00:00:08 2014 -0700
@@ -24,18 +24,16 @@
  */
 package javax.swing.text;
 
-import java.lang.reflect.Method;
+import com.sun.beans.util.Cache;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import java.beans.Transient;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Enumeration;
 import java.util.Vector;
-import java.util.Map;
 
 import java.util.concurrent.*;
 
@@ -1192,47 +1190,6 @@
     }
 
     /**
-     * Returns true if <code>klass</code> is NOT a JTextComponent and it or
-     * one of its superclasses (stoping at JTextComponent) overrides
-     * <code>processInputMethodEvent</code>. It is assumed this will be
-     * invoked from within a <code>doPrivileged</code>, and it is also
-     * assumed <code>klass</code> extends <code>JTextComponent</code>.
-     */
-    private static Boolean isProcessInputMethodEventOverridden(Class<?> klass) {
-        if (klass == JTextComponent.class) {
-            return Boolean.FALSE;
-        }
-        Boolean retValue = overrideMap.get(klass.getName());
-
-        if (retValue != null) {
-            return retValue;
-        }
-        Boolean sOverriden = isProcessInputMethodEventOverridden(
-                                       klass.getSuperclass());
-
-        if (sOverriden.booleanValue()) {
-            // If our superclass has overriden it, then by definition klass
-            // overrides it.
-            overrideMap.put(klass.getName(), sOverriden);
-            return sOverriden;
-        }
-        // klass's superclass didn't override it, check for an override in
-        // klass.
-        try {
-            Class[] classes = new Class[1];
-            classes[0] = InputMethodEvent.class;
-
-            Method m = klass.getDeclaredMethod("processInputMethodEvent",
-                                               classes);
-            retValue = Boolean.TRUE;
-        } catch (NoSuchMethodException nsme) {
-            retValue = Boolean.FALSE;
-        }
-        overrideMap.put(klass.getName(), retValue);
-        return retValue;
-    }
-
-    /**
      * Fetches the current color used to render the
      * caret.
      *
@@ -3913,7 +3870,33 @@
      * Maps from class name to Boolean indicating if
      * <code>processInputMethodEvent</code> has been overriden.
      */
-    private static Map<String, Boolean> overrideMap;
+    private static Cache<Class<?>,Boolean> METHOD_OVERRIDDEN
+            = new Cache<Class<?>,Boolean>(Cache.Kind.WEAK, Cache.Kind.STRONG) {
+        /**
+         * Returns {@code true} if the specified {@code type} extends {@link JTextComponent}
+         * and the {@link JTextComponent#processInputMethodEvent} method is overridden.
+         */
+        @Override
+        public Boolean create(final Class<?> type) {
+            if (JTextComponent.class == type) {
+                return Boolean.FALSE;
+            }
+            if (get(type.getSuperclass())) {
+                return Boolean.TRUE;
+            }
+            return AccessController.doPrivileged(
+                    new PrivilegedAction<Boolean>() {
+                        public Boolean run() {
+                            try {
+                                type.getDeclaredMethod("processInputMethodEvent", InputMethodEvent.class);
+                                return Boolean.TRUE;
+                            } catch (NoSuchMethodException exception) {
+                                return Boolean.FALSE;
+                            }
+                        }
+                    });
+        }
+    };
 
     /**
      * Returns a string representation of this <code>JTextComponent</code>.
@@ -4938,39 +4921,16 @@
      */
     private boolean shouldSynthensizeKeyEvents() {
         if (!checkedInputOverride) {
+            // Checks whether the client code overrides processInputMethodEvent.
+            // If it is overridden, need not to generate KeyTyped events for committed text.
+            // If it's not, behave as an passive input method client.
+            needToSendKeyTypedEvent = !METHOD_OVERRIDDEN.get(getClass());
             checkedInputOverride = true;
-            needToSendKeyTypedEvent =
-                             !isProcessInputMethodEventOverridden();
         }
         return needToSendKeyTypedEvent;
     }
 
     //
-    // Checks whether the client code overrides processInputMethodEvent.  If it is overridden,
-    // need not to generate KeyTyped events for committed text. If it's not, behave as an
-    // passive input method client.
-    //
-    private boolean isProcessInputMethodEventOverridden() {
-        if (overrideMap == null) {
-            overrideMap = Collections.synchronizedMap(new HashMap<String, Boolean>());
-        }
-        Boolean retValue = overrideMap.get(getClass().getName());
-
-        if (retValue != null) {
-            return retValue.booleanValue();
-        }
-        Boolean ret = AccessController.doPrivileged(new
-                       PrivilegedAction<Boolean>() {
-            public Boolean run() {
-                return isProcessInputMethodEventOverridden(
-                                JTextComponent.this.getClass());
-            }
-        });
-
-        return ret.booleanValue();
-    }
-
-    //
     // Checks whether a composed text in this text component
     //
     boolean composedTextExists() {
--- a/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Thu May 01 00:00:08 2014 -0700
@@ -26,7 +26,6 @@
 
 import sun.awt.AppContext;
 
-import java.lang.reflect.Method;
 import java.awt.*;
 import java.awt.event.*;
 import java.io.*;
@@ -34,12 +33,13 @@
 import java.net.URL;
 import javax.swing.text.*;
 import javax.swing.*;
-import javax.swing.border.*;
 import javax.swing.event.*;
 import javax.swing.plaf.TextUI;
 import java.util.*;
 import javax.accessibility.*;
 import java.lang.ref.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
  * The Swing JEditorPane text component supports different kinds
@@ -414,14 +414,13 @@
      *  HTMLEditorKit class
      * @return a stream representing the resource
      */
-    static InputStream getResourceAsStream(String name) {
-        try {
-            return ResourceLoader.getResourceAsStream(name);
-        } catch (Throwable e) {
-            // If the class doesn't exist or we have some other
-            // problem we just try to call getResourceAsStream directly.
-            return HTMLEditorKit.class.getResourceAsStream(name);
-        }
+    static InputStream getResourceAsStream(final String name) {
+        return AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
+                        return HTMLEditorKit.class.getResourceAsStream(name);
+                    }
+                });
     }
 
     /**
--- a/src/share/classes/javax/swing/text/html/ResourceLoader.java	Wed Apr 30 11:16:49 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1999, 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 javax.swing.text.html;
-
-import java.io.InputStream;
-
-/**
- * Simple class to load resources using the 1.2
- * security model.  Since the html support is loaded
- * lazily, it's resources are potentially fetched with
- * applet code in the call stack.  By providing this
- * functionality in a class that is only built on 1.2,
- * reflection can be used from the code that is also
- * built on 1.1 to call this functionality (and avoid
- * the evils of preprocessing).  This functionality
- * is called from HTMLEditorKit.getResourceAsStream.
- *
- * @author  Timothy Prinzing
- */
-class ResourceLoader implements java.security.PrivilegedAction {
-
-    ResourceLoader(String name) {
-        this.name = name;
-    }
-
-    public Object run() {
-        Object o = HTMLEditorKit.class.getResourceAsStream(name);
-        return o;
-    }
-
-    public static InputStream getResourceAsStream(String name) {
-        java.security.PrivilegedAction a = new ResourceLoader(name);
-        return (InputStream) java.security.AccessController.doPrivileged(a);
-    }
-
-    private String name;
-}
--- a/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java	Thu May 01 00:00:08 2014 -0700
@@ -22,7 +22,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package javax.swing.text.html.parser;
 
 import sun.awt.AppContext;
@@ -35,6 +34,8 @@
 import java.io.ObjectInputStream;
 import java.io.Reader;
 import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
  * Responsible for starting up a new DocumentParser
@@ -111,14 +112,13 @@
      *  ParserDelegator class.
      * @returns a stream representing the resource
      */
-    static InputStream getResourceAsStream(String name) {
-        try {
-            return ResourceLoader.getResourceAsStream(name);
-        } catch (Throwable e) {
-            // If the class doesn't exist or we have some other
-            // problem we just try to call getResourceAsStream directly.
-            return ParserDelegator.class.getResourceAsStream(name);
-        }
+    static InputStream getResourceAsStream(final String name) {
+        return AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
+                        return ParserDelegator.class.getResourceAsStream(name);
+                    }
+                });
     }
 
     private void readObject(ObjectInputStream s)
--- a/src/share/classes/javax/swing/text/html/parser/ResourceLoader.java	Wed Apr 30 11:16:49 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1999, 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 javax.swing.text.html.parser;
-
-import java.io.InputStream;
-
-/**
- * Simple class to load resources using the 1.2
- * security model.  Since the html support is loaded
- * lazily, it's resources are potentially fetched with
- * applet code in the call stack.  By providing this
- * functionality in a class that is only built on 1.2,
- * reflection can be used from the code that is also
- * built on 1.1 to call this functionality (and avoid
- * the evils of preprocessing).  This functionality
- * is called from ParserDelegator.getResourceAsStream.
- *
- * @author  Timothy Prinzing
- */
-class ResourceLoader implements java.security.PrivilegedAction {
-
-    ResourceLoader(String name) {
-        this.name = name;
-    }
-
-    public Object run() {
-        Object o = ParserDelegator.class.getResourceAsStream(name);
-        return o;
-    }
-
-    public static InputStream getResourceAsStream(String name) {
-        java.security.PrivilegedAction a = new ResourceLoader(name);
-        return (InputStream) java.security.AccessController.doPrivileged(a);
-    }
-
-    private String name;
-}
--- a/src/share/classes/javax/swing/text/rtf/RTFReader.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/javax/swing/text/rtf/RTFReader.java	Thu May 01 00:00:08 2014 -0700
@@ -27,9 +27,9 @@
 import java.lang.*;
 import java.util.*;
 import java.io.*;
-import java.awt.Font;
 import java.awt.Color;
-
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import javax.swing.text.*;
 
 /**
@@ -558,16 +558,14 @@
 {
     char[] set = characterSets.get(name);
     if (set == null) {
-      InputStream charsetStream;
-      charsetStream = java.security.AccessController.
-              doPrivileged(new java.security.PrivilegedAction<InputStream>() {
-          public InputStream run() {
-              return RTFReader.class.getResourceAsStream
-                                     ("charsets/" + name + ".txt");
-          }
-      });
-      set = readCharset(charsetStream);
-      defineCharacterSet(name, set);
+        InputStream charsetStream = AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
+                        return RTFReader.class.getResourceAsStream("charsets/" + name + ".txt");
+                    }
+                });
+        set = readCharset(charsetStream);
+        defineCharacterSet(name, set);
     }
     return set;
 }
--- a/src/share/classes/sun/awt/AWTAccessor.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Thu May 01 00:00:08 2014 -0700
@@ -27,6 +27,7 @@
 
 import sun.misc.Unsafe;
 
+import javax.accessibility.AccessibleContext;
 import java.awt.*;
 import java.awt.KeyboardFocusManager;
 import java.awt.DefaultKeyboardFocusManager;
@@ -736,6 +737,14 @@
     }
 
     /*
+     * An accessor object for the AccessibleContext class
+     */
+    public interface AccessibleContextAccessor {
+        void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
+        AppContext getAppContext(AccessibleContext accessibleContext);
+    }
+
+    /*
      * Accessor instances are initialized in the static initializers of
      * corresponding AWT classes by using setters defined below.
      */
@@ -765,6 +774,7 @@
     private static ToolkitAccessor toolkitAccessor;
     private static InvocationEventAccessor invocationEventAccessor;
     private static SystemColorAccessor systemColorAccessor;
+    private static AccessibleContextAccessor accessibleContextAccessor;
 
     /*
      * Set an accessor object for the java.awt.Component class.
@@ -1208,4 +1218,21 @@
      public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
          AWTAccessor.systemColorAccessor = systemColorAccessor;
      }
+
+    /*
+     * Get the accessor object for the javax.accessibility.AccessibleContext class.
+     */
+    public static AccessibleContextAccessor getAccessibleContextAccessor() {
+        if (accessibleContextAccessor == null) {
+            unsafe.ensureClassInitialized(AccessibleContext.class);
+        }
+        return accessibleContextAccessor;
+    }
+
+   /*
+    * Set the accessor object for the javax.accessibility.AccessibleContext class.
+    */
+    public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
+        AWTAccessor.accessibleContextAccessor = accessor;
+    }
 }
--- a/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java	Thu May 01 00:00:08 2014 -0700
@@ -239,6 +239,13 @@
 
         if (localTransferable != null) {
             return localTransferable.getTransferData(df);
+        } else if (df.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
+            // Workaround to JDK-8024061: Exception thrown when drag and drop
+            //      between two components is executed quickly.
+            // It is expected localTransferable is not null if javaJVMLocalObjectMimeType
+            // is used. Executing further results in ClassCastException, so null is
+            // returned here as no transfer data is available in this case.
+            return null;
         }
 
         if (dropStatus != STATUS_ACCEPT || dropComplete) {
--- a/src/share/classes/sun/net/www/http/HttpClient.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/classes/sun/net/www/http/HttpClient.java	Thu May 01 00:00:08 2014 -0700
@@ -665,7 +665,9 @@
                     // try once more
                     openServer();
                     if (needsTunneling()) {
+                        MessageHeader origRequests = requests;
                         httpuc.doTunneling();
+                        requests = origRequests;
                     }
                     afterConnect();
                     writeRequests(requests, poster);
@@ -776,7 +778,9 @@
                         cachedHttpClient = false;
                         openServer();
                         if (needsTunneling()) {
+                            MessageHeader origRequests = requests;
                             httpuc.doTunneling();
+                            requests = origRequests;
                         }
                         afterConnect();
                         writeRequests(requests, poster);
--- a/src/share/native/sun/awt/image/BufImgSurfaceData.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/BufImgSurfaceData.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -69,17 +69,14 @@
     }
 
     clsICMCD = (*env)->NewWeakGlobalRef(env, cd);
-    initICMCDmID = (*env)->GetMethodID(env, cd, "<init>", "(J)V");
-    pDataID = (*env)->GetFieldID(env, cd, "pData", "J");
-
-    rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I");
-    allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z");
-    mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I");
-    colorDataID = (*env)->GetFieldID(env, icm, "colorData",
-        "Lsun/awt/image/BufImgSurfaceData$ICMColorData;");
-    if (allGrayID == 0 || rgbID == 0 || mapSizeID == 0 || pDataID == 0|| colorDataID == 0 || initICMCDmID == 0) {
-        JNU_ThrowInternalError(env, "Could not get field IDs");
-    }
+    JNU_CHECK_EXCEPTION(env);
+    CHECK_NULL(initICMCDmID = (*env)->GetMethodID(env, cd, "<init>", "(J)V"));
+    CHECK_NULL(pDataID = (*env)->GetFieldID(env, cd, "pData", "J"));
+    CHECK_NULL(rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I"));
+    CHECK_NULL(allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z"));
+    CHECK_NULL(mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I"));
+    CHECK_NULL(colorDataID = (*env)->GetFieldID(env, icm, "colorData",
+                                           "Lsun/awt/image/BufImgSurfaceData$ICMColorData;"));
 }
 
 /*
@@ -120,6 +117,7 @@
     bisdo->sdOps.Unlock = NULL;
     bisdo->sdOps.Dispose = BufImg_Dispose;
     bisdo->array = (*env)->NewWeakGlobalRef(env, array);
+    JNU_CHECK_EXCEPTION(env);
     bisdo->offset = offset;
     bisdo->bitoffset = bitoffset;
     bisdo->scanStr = scanStr;
@@ -131,6 +129,7 @@
     } else {
         jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
         bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);
+        JNU_CHECK_EXCEPTION(env);
         bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
         bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);
     }
@@ -174,8 +173,8 @@
     {
         bipriv->cData = BufImg_SetupICM(env, bisdo);
         if (bipriv->cData == NULL) {
-            JNU_ThrowNullPointerException(env, "Could not initialize "
-                                          "inverse tables");
+            (*env)->ExceptionClear(env);
+            JNU_ThrowNullPointerException(env, "Could not initialize inverse tables");
             return SD_FAILURE;
         }
     } else {
@@ -201,6 +200,7 @@
     if ((bipriv->lockFlags & (SD_LOCK_RD_WR)) != 0) {
         bipriv->base =
             (*env)->GetPrimitiveArrayCritical(env, bisdo->array, NULL);
+        CHECK_NULL(bipriv->base);
     }
     if ((bipriv->lockFlags & (SD_LOCK_LUT)) != 0) {
         bipriv->lutbase =
@@ -291,6 +291,7 @@
             = (*env)->GetBooleanField(env, bisdo->icm, allGrayID);
         int *pRgb = (int *)
             ((*env)->GetPrimitiveArrayCritical(env, bisdo->lutarray, NULL));
+        CHECK_NULL_RETURN(pRgb, (ColorData*)NULL);
         cData->img_clr_tbl = initCubemap(pRgb, bisdo->lutsize, 32);
         if (allGray == JNI_TRUE) {
             initInverseGrayLut(pRgb, bisdo->lutsize, cData);
@@ -303,6 +304,7 @@
         if (JNU_IsNull(env, colorData)) {
             jlong pData = ptr_to_jlong(cData);
             colorData = (*env)->NewObjectA(env, clsICMCD, initICMCDmID, (jvalue *)&pData);
+            JNU_CHECK_EXCEPTION_RETURN(env, (ColorData*)NULL);
             (*env)->SetObjectField(env, bisdo->icm, colorDataID, colorData);
         }
     }
--- a/src/share/native/sun/awt/image/DataBufferNative.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/DataBufferNative.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, 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
@@ -74,6 +74,7 @@
     SurfaceDataOps *ops;
 
     ops = SurfaceData_GetOps(env, sd);
+    JNU_CHECK_EXCEPTION_RETURN(env, -1);
 
     if (!(pixelPtr = DBN_GetPixelPointer(env, x, y, &lockInfo,
                                          ops, SD_LOCK_READ)))
@@ -115,6 +116,7 @@
 
 
     ops = SurfaceData_GetOps(env, sd);
+    JNU_CHECK_EXCEPTION(env);
 
     if (!(pixelPtr = DBN_GetPixelPointer(env, x, y, &lockInfo,
                                          ops, SD_LOCK_WRITE)))
--- a/src/share/native/sun/awt/image/awt_ImageRep.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/awt_ImageRep.c	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -97,9 +97,9 @@
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_ImageRepresentation_initIDs(JNIEnv *env, jclass cls) {
-    s_JnumSrcLUTID = (*env)->GetFieldID(env, cls, "numSrcLUT", "I");
-    s_JsrcLUTtransIndexID = (*env)->GetFieldID(env, cls, "srcLUTtransIndex",
-                                               "I");
+    CHECK_NULL(s_JnumSrcLUTID = (*env)->GetFieldID(env, cls, "numSrcLUT", "I"));
+    CHECK_NULL(s_JsrcLUTtransIndexID = (*env)->GetFieldID(env, cls,
+                                                          "srcLUTtransIndex", "I"));
 }
 
 /*
@@ -166,6 +166,7 @@
 
     cOffs = (int *) (*env)->GetPrimitiveArrayCritical(env, joffs, NULL);
     if (cOffs == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null channel offset array");
         return JNI_FALSE;
     }
@@ -190,6 +191,7 @@
 
     srcLUT = (int *) (*env)->GetPrimitiveArrayCritical(env, jlut, NULL);
     if (srcLUT == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null IndexColorModel LUT");
         return JNI_FALSE;
     }
@@ -198,6 +200,7 @@
                                                                   NULL);
     if (srcData == NULL) {
         (*env)->ReleasePrimitiveArrayCritical(env, jlut, srcLUT, JNI_ABORT);
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null data array");
         return JNI_FALSE;
     }
@@ -206,6 +209,7 @@
     if (dstData == NULL) {
         (*env)->ReleasePrimitiveArrayCritical(env, jlut, srcLUT, JNI_ABORT);
         (*env)->ReleasePrimitiveArrayCritical(env, jpix, srcData, JNI_ABORT);
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null tile data array");
         return JNI_FALSE;
     }
--- a/src/share/native/sun/awt/image/awt_parseImage.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/awt_parseImage.c	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -182,6 +182,11 @@
 int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP) {
     jobject joffs = NULL;
     /* int status;*/
+    jclass singlePixelPackedSampleModelClass = NULL;
+    jclass integerComponentRasterClass = NULL;
+    jclass byteComponentRasterClass = NULL;
+    jclass shortComponentRasterClass = NULL;
+    jclass bytePackedRasterClass = NULL;
 
     if (JNU_IsNull(env, jraster)) {
         JNU_ThrowNullPointerException(env, "null Raster object");
@@ -226,8 +231,11 @@
 
     rasterP->sppsm.isUsed = 0;
 
+    singlePixelPackedSampleModelClass = (*env)->FindClass(env,
+                            "java/awt/image/SinglePixelPackedSampleModel");
+    CHECK_NULL_RETURN(singlePixelPackedSampleModelClass, -1);
     if ((*env)->IsInstanceOf(env, rasterP->jsampleModel,
-       (*env)->FindClass(env,"java/awt/image/SinglePixelPackedSampleModel"))) {
+                             singlePixelPackedSampleModelClass)) {
         jobject jmask, joffs, jnbits;
 
         rasterP->sppsm.isUsed = 1;
@@ -261,8 +269,15 @@
                                                     rasterP->jsampleModel,
                                                     g_SMHeightID);
 
-    if ((*env)->IsInstanceOf(env, jraster,
-         (*env)->FindClass(env, "sun/awt/image/IntegerComponentRaster"))){
+    integerComponentRasterClass = (*env)->FindClass(env, "sun/awt/image/IntegerComponentRaster");
+    CHECK_NULL_RETURN(integerComponentRasterClass, -1);
+    byteComponentRasterClass = (*env)->FindClass(env, "sun/awt/image/ByteComponentRaster");
+    CHECK_NULL_RETURN(byteComponentRasterClass, -1);
+    shortComponentRasterClass = (*env)->FindClass(env,"sun/awt/image/ShortComponentRaster");
+    CHECK_NULL_RETURN(shortComponentRasterClass, -1);
+    bytePackedRasterClass = (*env)->FindClass(env, "sun/awt/image/BytePackedRaster");
+    CHECK_NULL_RETURN(bytePackedRasterClass, -1);
+    if ((*env)->IsInstanceOf(env, jraster, integerComponentRasterClass)){
         rasterP->jdata = (*env)->GetObjectField(env, jraster, g_ICRdataID);
         rasterP->dataType = INT_DATA_TYPE;
         rasterP->dataSize = 4;
@@ -273,8 +288,7 @@
         rasterP->pixelStride = (*env)->GetIntField(env, jraster, g_ICRpixstrID);
         joffs = (*env)->GetObjectField(env, jraster, g_ICRdataOffsetsID);
     }
-    else if ((*env)->IsInstanceOf(env, jraster,
-            (*env)->FindClass(env, "sun/awt/image/ByteComponentRaster"))){
+    else if ((*env)->IsInstanceOf(env, jraster, byteComponentRasterClass)){
         rasterP->jdata = (*env)->GetObjectField(env, jraster, g_BCRdataID);
         rasterP->dataType = BYTE_DATA_TYPE;
         rasterP->dataSize = 1;
@@ -285,8 +299,7 @@
         rasterP->pixelStride = (*env)->GetIntField(env, jraster, g_BCRpixstrID);
         joffs = (*env)->GetObjectField(env, jraster, g_BCRdataOffsetsID);
     }
-    else if ((*env)->IsInstanceOf(env, jraster,
-            (*env)->FindClass(env, "sun/awt/image/ShortComponentRaster"))){
+    else if ((*env)->IsInstanceOf(env, jraster, shortComponentRasterClass)){
         rasterP->jdata = (*env)->GetObjectField(env, jraster, g_SCRdataID);
         rasterP->dataType = SHORT_DATA_TYPE;
         rasterP->dataSize = 2;
@@ -297,8 +310,7 @@
         rasterP->pixelStride = (*env)->GetIntField(env, jraster, g_SCRpixstrID);
         joffs = (*env)->GetObjectField(env, jraster, g_SCRdataOffsetsID);
     }
-    else if ((*env)->IsInstanceOf(env, jraster,
-            (*env)->FindClass(env, "sun/awt/image/BytePackedRaster"))){
+    else if ((*env)->IsInstanceOf(env, jraster, bytePackedRasterClass)){
         rasterP->rasterType = PACKED_RASTER_TYPE;
         rasterP->dataType = BYTE_DATA_TYPE;
         rasterP->dataSize = 1;
@@ -397,30 +409,41 @@
 }
 
 static int getColorModelType(JNIEnv *env, jobject jcmodel) {
-    int type = UNKNOWN_CM_TYPE;
+    jclass colorModelClass;
 
-    if ((*env)->IsInstanceOf(env, jcmodel,
-                 (*env)->FindClass(env, "java/awt/image/IndexColorModel")))
+    colorModelClass = (*env)->FindClass(env,
+                                        "java/awt/image/IndexColorModel");
+    CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+
+    if ((*env)->IsInstanceOf(env, jcmodel, colorModelClass))
     {
-        type = INDEX_CM_TYPE;
-    } else if ((*env)->IsInstanceOf(env, jcmodel,
-                 (*env)->FindClass(env, "java/awt/image/PackedColorModel")))
+        return INDEX_CM_TYPE;
+    }
+
+    colorModelClass = (*env)->FindClass(env,
+                                        "java/awt/image/PackedColorModel");
+    CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+    if ((*env)->IsInstanceOf(env, jcmodel, colorModelClass))
     {
-        if  ((*env)->IsInstanceOf(env, jcmodel,
-                (*env)->FindClass(env, "java/awt/image/DirectColorModel"))) {
-            type = DIRECT_CM_TYPE;
+        colorModelClass = (*env)->FindClass(env,
+                                            "java/awt/image/DirectColorModel");
+        CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+        if  ((*env)->IsInstanceOf(env, jcmodel, colorModelClass)) {
+            return DIRECT_CM_TYPE;
         }
         else {
-            type = PACKED_CM_TYPE;
+            return PACKED_CM_TYPE;
         }
     }
-    else if ((*env)->IsInstanceOf(env, jcmodel,
-                 (*env)->FindClass(env, "java/awt/image/ComponentColorModel")))
+    colorModelClass = (*env)->FindClass(env,
+                                        "java/awt/image/ComponentColorModel");
+    CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+    if ((*env)->IsInstanceOf(env, jcmodel, colorModelClass))
     {
-        type = COMPONENT_CM_TYPE;
+        return COMPONENT_CM_TYPE;
     }
 
-    return type;
+    return UNKNOWN_CM_TYPE;
 }
 
 int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType,
@@ -506,12 +529,13 @@
         if (s_jdefCM == NULL) {
             jobject defCM;
             jclass jcm = (*env)->FindClass(env, "java/awt/image/ColorModel");
+            CHECK_NULL_RETURN(jcm, -1);
             defCM = (*env)->CallStaticObjectMethod(env, jcm,
                                                    g_CMgetRGBdefaultMID, NULL);
             s_jdefCM = (*env)->NewGlobalRef(env, defCM);
             if (defCM == NULL || s_jdefCM == NULL) {
-                JNU_ThrowNullPointerException(env,
-                                              "Unable to find default CM");
+                (*env)->ExceptionClear(env);
+                JNU_ThrowNullPointerException(env, "Unable to find default CM");
                 return -1;
             }
         }
@@ -931,6 +955,7 @@
 
     jdata = (*env)->NewIntArray(env, maxSamples);
     if (JNU_IsNull(env, jdata)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
@@ -1028,6 +1053,7 @@
 
     jdata = (*env)->NewIntArray(env, maxSamples);
     if (JNU_IsNull(env, jdata)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
--- a/src/share/native/sun/awt/image/gif/gifdecoder.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/gif/gifdecoder.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -104,12 +104,12 @@
 JNIEXPORT void JNICALL
 Java_sun_awt_image_GifImageDecoder_initIDs(JNIEnv *env, jclass this)
 {
-    readID = (*env)->GetMethodID(env, this, "readBytes", "([BII)I");
-    sendID = (*env)->GetMethodID(env, this, "sendPixels",
-                                 "(IIII[BLjava/awt/image/ColorModel;)I");
-    prefixID = (*env)->GetFieldID(env, this, "prefix", "[S");
-    suffixID = (*env)->GetFieldID(env, this, "suffix", "[B");
-    outCodeID = (*env)->GetFieldID(env, this, "outCode", "[B");
+    CHECK_NULL(readID = (*env)->GetMethodID(env, this, "readBytes", "([BII)I"));
+    CHECK_NULL(sendID = (*env)->GetMethodID(env, this, "sendPixels",
+                                 "(IIII[BLjava/awt/image/ColorModel;)I"));
+    CHECK_NULL(prefixID = (*env)->GetFieldID(env, this, "prefix", "[S"));
+    CHECK_NULL(suffixID = (*env)->GetFieldID(env, this, "suffix", "[B"));
+    CHECK_NULL(outCodeID = (*env)->GetFieldID(env, this, "outCode", "[B"));
 }
 
 JNIEXPORT jboolean JNICALL
@@ -292,8 +292,10 @@
              * reads the immediately subsequent code as uncompressed data.
              */
             if (verbose) {
+                RELEASE_ARRAYS();
                 fprintf(stdout, ".");
                 fflush(stdout);
+                GET_ARRAYS();
             }
 
             /* Note that freeCode is one less than it is supposed to be,
@@ -319,10 +321,10 @@
             /* make sure we read the whole block of pixels. */
         flushit:
             while (!blockEnd) {
+                RELEASE_ARRAYS();
                 if (verbose) {
                     fprintf(stdout, "flushing %d bytes\n", blockLength);
                 }
-                RELEASE_ARRAYS();
                 if ((*env)->CallIntMethod(env, this, readID,
                                           blockh, 0, blockLength + 1) != 0
                     || (*env)->ExceptionOccurred(env))
--- a/src/share/native/sun/awt/image/imageInitIDs.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/imageInitIDs.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1998, 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
@@ -29,211 +29,139 @@
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_BufferedImage_initIDs(JNIEnv *env, jclass cls) {
-    g_BImgRasterID     = (*env)->GetFieldID(env, cls, "raster",
-                                            "Ljava/awt/image/WritableRaster;");
-    g_BImgTypeID = (*env)->GetFieldID(env, cls, "imageType", "I");
-    g_BImgCMID = (*env)->GetFieldID(env, cls, "colorModel",
-                                    "Ljava/awt/image/ColorModel;");
-    g_BImgGetRGBMID = (*env)->GetMethodID(env, cls, "getRGB",
-                                          "(IIII[III)[I");
-    g_BImgSetRGBMID = (*env)->GetMethodID(env, cls, "setRGB",
-                                          "(IIII[III)V");
-    if (g_BImgRasterID == NULL || g_BImgTypeID == NULL || g_BImgCMID == NULL
-        || g_BImgGetRGBMID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_BImgRasterID = (*env)->GetFieldID(env, cls, "raster",
+                                        "Ljava/awt/image/WritableRaster;"));
+    CHECK_NULL(g_BImgTypeID = (*env)->GetFieldID(env, cls, "imageType", "I"));
+    CHECK_NULL(g_BImgCMID = (*env)->GetFieldID(env, cls, "colorModel",
+                                        "Ljava/awt/image/ColorModel;"));
+    CHECK_NULL(g_BImgGetRGBMID = (*env)->GetMethodID(env, cls, "getRGB",
+                                        "(IIII[III)[I"));
+    CHECK_NULL(g_BImgSetRGBMID = (*env)->GetMethodID(env, cls, "setRGB",
+                                        "(IIII[III)V"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_Raster_initIDs(JNIEnv *env, jclass cls) {
-    g_RasterWidthID    = (*env)->GetFieldID(env, cls, "width", "I");
-    g_RasterHeightID   = (*env)->GetFieldID(env, cls, "height", "I");
-    g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I");
-    g_RasterGetDataMID = (*env)->GetMethodID(env, cls, "getDataElements",
-                              "(IIIILjava/lang/Object;)Ljava/lang/Object;");
-    g_RasterMinXID  = (*env)->GetFieldID(env, cls, "minX", "I");
-    g_RasterMinYID  = (*env)->GetFieldID(env, cls, "minY", "I");
-    g_RasterBaseOriginXID  = (*env)->GetFieldID(env, cls,
-                                 "sampleModelTranslateX", "I");
-    g_RasterBaseOriginYID  = (*env)->GetFieldID(env, cls,
-                                 "sampleModelTranslateY", "I");
-    g_RasterSampleModelID = (*env)->GetFieldID(env, cls,
-                                 "sampleModel","Ljava/awt/image/SampleModel;");
-    g_RasterNumDataElementsID = (*env)->GetFieldID(env, cls, "numDataElements",
-                                                   "I");
-    g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I");
-    g_RasterDataBufferID = (*env)->GetFieldID(env, cls, "dataBuffer",
-                                              "Ljava/awt/image/DataBuffer;");
-    if (g_RasterWidthID == NULL || g_RasterHeightID == NULL
-        || g_RasterNumBandsID == NULL || g_RasterGetDataMID == NULL
-        || g_RasterMinXID == NULL || g_RasterMinYID == NULL
-        || g_RasterBaseOriginXID == NULL || g_RasterBaseOriginYID == NULL
-        || g_RasterSampleModelID == NULL || g_RasterNumDataElementsID == NULL
-        || g_RasterNumBandsID == NULL || g_RasterDataBufferID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_RasterWidthID    = (*env)->GetFieldID(env, cls, "width", "I"));
+    CHECK_NULL(g_RasterHeightID   = (*env)->GetFieldID(env, cls, "height", "I"));
+    CHECK_NULL(g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I"));
+    CHECK_NULL(g_RasterGetDataMID = (*env)->GetMethodID(env, cls, "getDataElements",
+                                        "(IIIILjava/lang/Object;)Ljava/lang/Object;"));
+    CHECK_NULL(g_RasterMinXID  = (*env)->GetFieldID(env, cls, "minX", "I"));
+    CHECK_NULL(g_RasterMinYID  = (*env)->GetFieldID(env, cls, "minY", "I"));
+    CHECK_NULL(g_RasterBaseOriginXID  = (*env)->GetFieldID(env, cls,
+                                        "sampleModelTranslateX", "I"));
+    CHECK_NULL(g_RasterBaseOriginYID  = (*env)->GetFieldID(env, cls,
+                                        "sampleModelTranslateY", "I"));
+    CHECK_NULL(g_RasterSampleModelID = (*env)->GetFieldID(env, cls,
+                                        "sampleModel","Ljava/awt/image/SampleModel;"));
+    CHECK_NULL(g_RasterNumDataElementsID = (*env)->GetFieldID(env, cls,
+                                        "numDataElements", "I"));
+    CHECK_NULL(g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I"));
+    CHECK_NULL(g_RasterDataBufferID = (*env)->GetFieldID(env, cls, "dataBuffer",
+                                        "Ljava/awt/image/DataBuffer;"));
 }
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_ByteComponentRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_BCRdataID = (*env)->GetFieldID(env, cls, "data", "[B");
-    g_BCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_BCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_BCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
-    g_BCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
-    g_BCRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    if (g_BCRdataID == NULL || g_BCRscanstrID == NULL ||
-        g_BCRpixstrID == NULL || g_BCRbandoffsID == NULL ||
-        g_BCRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_BCRdataID = (*env)->GetFieldID(env, cls, "data", "[B"));
+    CHECK_NULL(g_BCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_BCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_BCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I"));
+    CHECK_NULL(g_BCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I"));
+    CHECK_NULL(g_BCRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_BytePackedRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_BPRdataID = (*env)->GetFieldID(env, cls, "data", "[B");
-    g_BPRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_BPRpixstrID = (*env)->GetFieldID(env, cls, "pixelBitStride", "I");
-    g_BPRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    g_BPRdataBitOffsetID = (*env)->GetFieldID(env, cls, "dataBitOffset", "I");
-    if (g_BPRdataID == NULL || g_BPRscanstrID == NULL ||
-        g_BPRpixstrID == NULL ||  g_BPRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_BPRdataID = (*env)->GetFieldID(env, cls, "data", "[B"));
+    CHECK_NULL(g_BPRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_BPRpixstrID = (*env)->GetFieldID(env, cls, "pixelBitStride", "I"));
+    CHECK_NULL(g_BPRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
+    CHECK_NULL(g_BPRdataBitOffsetID = (*env)->GetFieldID(env, cls, "dataBitOffset", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_ShortComponentRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_SCRdataID = (*env)->GetFieldID(env, cls, "data", "[S");
-    g_SCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_SCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_SCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
-    g_SCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
-    g_SCRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    if (g_SCRdataID == NULL || g_SCRscanstrID == NULL ||
-        g_SCRpixstrID == NULL || g_SCRbandoffsID == NULL ||
-        g_SCRdataOffsetsID == NULL || g_SCRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_SCRdataID = (*env)->GetFieldID(env, cls, "data", "[S"));
+    CHECK_NULL(g_SCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_SCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_SCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I"));
+    CHECK_NULL(g_SCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I"));
+    CHECK_NULL(g_SCRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
 }
 JNIEXPORT void JNICALL
 Java_sun_awt_image_IntegerComponentRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_ICRdataID = (*env)->GetFieldID(env, cls, "data", "[I");
-    g_ICRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_ICRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_ICRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
-    g_ICRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
-    g_ICRputDataMID  = (*env)->GetMethodID(env, cls, "setDataElements",
-                                     "(IIIILjava/lang/Object;)V");
-    g_ICRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    if (g_ICRdataID == NULL || g_ICRscanstrID == NULL
-        || g_ICRpixstrID == NULL || g_ICRbandoffsID == NULL
-        || g_ICRputDataMID == NULL || g_ICRdataOffsetsID == NULL || g_ICRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_ICRdataID = (*env)->GetFieldID(env, cls, "data", "[I"));
+    CHECK_NULL(g_ICRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_ICRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_ICRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I"));
+    CHECK_NULL(g_ICRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I"));
+    CHECK_NULL(g_ICRputDataMID  = (*env)->GetMethodID(env, cls, "setDataElements",
+                                     "(IIIILjava/lang/Object;)V"));
+    CHECK_NULL(g_ICRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
 }
 
 JNIEXPORT void JNICALL
-Java_java_awt_image_SinglePixelPackedSampleModel_initIDs(JNIEnv *env,
-                                                         jclass cls) {
-    g_SPPSMmaskArrID = (*env)->GetFieldID(env, cls, "bitMasks", "[I");
-    g_SPPSMmaskOffID = (*env)->GetFieldID(env, cls, "bitOffsets", "[I");
-    g_SPPSMnBitsID   = (*env)->GetFieldID(env, cls, "bitSizes", "[I");
-    g_SPPSMmaxBitID  = (*env)->GetFieldID(env, cls, "maxBitSize", "I");
-
-    if (g_SPPSMmaskArrID == NULL || g_SPPSMmaskOffID == NULL ||
-        g_SPPSMnBitsID == NULL || g_SPPSMmaxBitID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+Java_java_awt_image_SinglePixelPackedSampleModel_initIDs(JNIEnv *env, jclass cls) {
+    CHECK_NULL(g_SPPSMmaskArrID = (*env)->GetFieldID(env, cls, "bitMasks", "[I"));
+    CHECK_NULL(g_SPPSMmaskOffID = (*env)->GetFieldID(env, cls, "bitOffsets", "[I"));
+    CHECK_NULL(g_SPPSMnBitsID   = (*env)->GetFieldID(env, cls, "bitSizes", "[I"));
+    CHECK_NULL(g_SPPSMmaxBitID  = (*env)->GetFieldID(env, cls, "maxBitSize", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_ColorModel_initIDs(JNIEnv *env, jclass cls) {
-    g_CMpDataID = (*env)->GetFieldID (env, cls, "pData", "J");
-    g_CMnBitsID  = (*env)->GetFieldID(env, cls, "nBits", "[I");
-    g_CMcspaceID = (*env)->GetFieldID(env, cls, "colorSpace",
-                                    "Ljava/awt/color/ColorSpace;");
-    g_CMnumComponentsID = (*env)->GetFieldID(env, cls, "numComponents", "I");
-    g_CMsuppAlphaID  = (*env)->GetFieldID(env, cls, "supportsAlpha", "Z");
-    g_CMisAlphaPreID = (*env)->GetFieldID(env, cls, "isAlphaPremultiplied",
-                                          "Z");
-    g_CMtransparencyID = (*env)->GetFieldID(env, cls, "transparency", "I");
-    g_CMgetRGBMID      = (*env)->GetMethodID(env, cls, "getRGB",
-                                             "(Ljava/lang/Object;)I");
-    g_CMcsTypeID       = (*env)->GetFieldID(env, cls, "colorSpaceType", "I");
-    g_CMis_sRGBID      = (*env)->GetFieldID(env, cls, "is_sRGB", "Z");
-    g_CMgetRGBdefaultMID   = (*env)->GetStaticMethodID(env, cls,
+    CHECK_NULL(g_CMpDataID = (*env)->GetFieldID (env, cls, "pData", "J"));
+    CHECK_NULL(g_CMnBitsID  = (*env)->GetFieldID(env, cls, "nBits", "[I"));
+    CHECK_NULL(g_CMcspaceID = (*env)->GetFieldID(env, cls, "colorSpace",
+                                    "Ljava/awt/color/ColorSpace;"));
+    CHECK_NULL(g_CMnumComponentsID = (*env)->GetFieldID(env, cls, "numComponents", "I"));
+    CHECK_NULL(g_CMsuppAlphaID  = (*env)->GetFieldID(env, cls, "supportsAlpha", "Z"));
+    CHECK_NULL(g_CMisAlphaPreID = (*env)->GetFieldID(env, cls, "isAlphaPremultiplied",
+                                          "Z"));
+    CHECK_NULL(g_CMtransparencyID = (*env)->GetFieldID(env, cls, "transparency", "I"));
+    CHECK_NULL(g_CMgetRGBMID      = (*env)->GetMethodID(env, cls, "getRGB",
+                                             "(Ljava/lang/Object;)I"));
+    CHECK_NULL(g_CMcsTypeID       = (*env)->GetFieldID(env, cls, "colorSpaceType", "I"));
+    CHECK_NULL(g_CMis_sRGBID      = (*env)->GetFieldID(env, cls, "is_sRGB", "Z"));
+    CHECK_NULL(g_CMgetRGBdefaultMID   = (*env)->GetStaticMethodID(env, cls,
                                                        "getRGBdefault",
-                                             "()Ljava/awt/image/ColorModel;");
-    if (g_CMnBitsID == NULL || g_CMcspaceID == NULL
-        || g_CMnumComponentsID == NULL || g_CMsuppAlphaID == NULL
-        || g_CMisAlphaPreID == NULL || g_CMtransparencyID == NULL
-        || g_CMgetRGBMID == NULL || g_CMgetRGBMID == NULL
-        || g_CMis_sRGBID == NULL || g_CMgetRGBdefaultMID == NULL
-        || g_CMpDataID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+                                             "()Ljava/awt/image/ColorModel;"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_IndexColorModel_initIDs(JNIEnv *env, jclass cls) {
-    g_ICMtransIdxID = (*env)->GetFieldID(env, cls, "transparent_index", "I");
-    g_ICMmapSizeID  = (*env)->GetFieldID(env, cls, "map_size", "I");
-    g_ICMrgbID      = (*env)->GetFieldID(env, cls, "rgb", "[I");
-    if (g_ICMtransIdxID == NULL || g_ICMmapSizeID == NULL
-        || g_ICMrgbID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_ICMtransIdxID = (*env)->GetFieldID(env, cls, "transparent_index", "I"));
+    CHECK_NULL(g_ICMmapSizeID  = (*env)->GetFieldID(env, cls, "map_size", "I"));
+    CHECK_NULL(g_ICMrgbID      = (*env)->GetFieldID(env, cls, "rgb", "[I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_SampleModel_initIDs(JNIEnv *env, jclass cls) {
-    g_SMWidthID = (*env)->GetFieldID(env, cls, "width","I");
-    g_SMHeightID = (*env)->GetFieldID(env, cls, "height","I");
-    g_SMGetPixelsMID = (*env)->GetMethodID(env, cls, "getPixels",
-                                      "(IIII[ILjava/awt/image/DataBuffer;)[I");
-    g_SMSetPixelsMID = (*env)->GetMethodID(env, cls, "setPixels",
-                                      "(IIII[ILjava/awt/image/DataBuffer;)V");
-    if (g_SMWidthID == NULL || g_SMHeightID == NULL || g_SMGetPixelsMID == NULL
-        || g_SMSetPixelsMID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_SMWidthID = (*env)->GetFieldID(env, cls, "width","I"));
+    CHECK_NULL(g_SMHeightID = (*env)->GetFieldID(env, cls, "height","I"));
+    CHECK_NULL(g_SMGetPixelsMID = (*env)->GetMethodID(env, cls, "getPixels",
+                                      "(IIII[ILjava/awt/image/DataBuffer;)[I"));
+    CHECK_NULL(g_SMSetPixelsMID = (*env)->GetMethodID(env, cls, "setPixels",
+                                      "(IIII[ILjava/awt/image/DataBuffer;)V"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_ComponentSampleModel_initIDs(JNIEnv *env, jclass cls) {
-    g_CSMPixStrideID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_CSMScanStrideID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_CSMBandOffsetsID = (*env)->GetFieldID(env, cls, "bandOffsets", "[I");
-    if (g_CSMPixStrideID == NULL || g_CSMScanStrideID == NULL ||
-        g_CSMBandOffsetsID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_CSMPixStrideID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_CSMScanStrideID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_CSMBandOffsetsID = (*env)->GetFieldID(env, cls, "bandOffsets", "[I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_Kernel_initIDs(JNIEnv *env, jclass cls) {
-    g_KernelWidthID   = (*env)->GetFieldID(env, cls, "width", "I");
-    g_KernelHeightID  = (*env)->GetFieldID(env, cls, "height", "I");
-    g_KernelDataID    = (*env)->GetFieldID(env, cls, "data", "[F");
-    if (g_KernelWidthID == NULL || g_KernelHeightID == NULL
-        || g_KernelDataID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_KernelWidthID   = (*env)->GetFieldID(env, cls, "width", "I"));
+    CHECK_NULL(g_KernelHeightID  = (*env)->GetFieldID(env, cls, "height", "I"));
+    CHECK_NULL(g_KernelDataID    = (*env)->GetFieldID(env, cls, "data", "[F"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_DataBufferInt_initIDs(JNIEnv *env, jclass cls) {
-    g_DataBufferIntPdataID = (*env)->GetFieldID(env, cls, "pData", "J");
-    if (g_DataBufferIntPdataID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab DataBufferInt.pData");
-        return;
-    }
+    CHECK_NULL(g_DataBufferIntPdataID = (*env)->GetFieldID(env, cls, "pData", "J"));
 }
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -153,6 +153,7 @@
     /* Initialize a new buffer */
     jbyteArray hInputBuffer = (*env)->NewByteArray(env, STREAMBUF_SIZE);
     if (hInputBuffer == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Reader");
@@ -557,6 +558,7 @@
 
   // Create a new java string from the message
   string = (*env)->NewStringUTF(env, buffer);
+  CHECK_NULL(string);
 
   theObject = data->imageIOobj;
 
@@ -591,12 +593,7 @@
     /* Now we need a new weak global reference for the I/O provider */
     if (io != NULL) { // Fix for 4411955
         sb->ioRef = (*env)->NewWeakGlobalRef(env, io);
-        if (sb->ioRef == NULL) {
-            JNU_ThrowByName(env,
-                            "java/lang/OutOfMemoryError",
-                            "Setting I/O provider");
-            return;
-        }
+        CHECK_NULL(sb->ioRef);
     }
 
     /* And finally reset state */
@@ -693,6 +690,7 @@
     }
     for (i = 0; i < qlen; i++) {
         table = (*env)->GetObjectArrayElement(env, qtables, i);
+        CHECK_NULL_RETURN(table, 0);
         qdata = (*env)->GetObjectField(env, table, JPEGQTable_tableID);
         qdataBody = (*env)->GetPrimitiveArrayCritical(env, qdata, NULL);
 
@@ -724,7 +722,7 @@
     return qlen;
 }
 
-static void setHuffTable(JNIEnv *env,
+static boolean setHuffTable(JNIEnv *env,
                          JHUFF_TBL *huff_ptr,
                          jobject table) {
 
@@ -742,6 +740,8 @@
     hlensBody = (*env)->GetShortArrayElements(env,
                                               huffLens,
                                               NULL);
+    CHECK_NULL_RETURN(hlensBody, FALSE);
+
     if (hlensLen > 16) {
         /* Ignore extra elements of bits array. Only 16 elements can be
            stored. 0-th element is not used. (see jpeglib.h, line 107)  */
@@ -762,6 +762,7 @@
     hvalsBody = (*env)->GetShortArrayElements(env,
                                               huffValues,
                                               NULL);
+    CHECK_NULL_RETURN(hvalsBody, FALSE);
 
     if (hvalsLen > 256) {
         /* Ignore extra elements of hufval array. Only 256 elements
@@ -775,6 +776,7 @@
                                       huffValues,
                                       hvalsBody,
                                       JNI_ABORT);
+    return TRUE;
 }
 
 static int setHTables(JNIEnv *env,
@@ -810,7 +812,9 @@
             huff_ptr = comp->dc_huff_tbl_ptrs[i];
         }
         table = (*env)->GetObjectArrayElement(env, DCHuffmanTables, i);
-        setHuffTable(env, huff_ptr, table);
+        if (table == NULL || !setHuffTable(env, huff_ptr, table)) {
+            return 0;
+        }
         huff_ptr->sent_table = !write;
     }
     hlen = (*env)->GetArrayLength(env, ACHuffmanTables);
@@ -835,7 +839,9 @@
             huff_ptr = comp->ac_huff_tbl_ptrs[i];
         }
         table = (*env)->GetObjectArrayElement(env, ACHuffmanTables, i);
-        setHuffTable(env, huff_ptr, table);
+        if(table == NULL || !setHuffTable(env, huff_ptr, table)) {
+            return 0;
+        }
         huff_ptr->sent_table = !write;
     }
     return hlen;
@@ -1409,57 +1415,57 @@
      jclass qTableClass,
      jclass huffClass) {
 
-    JPEGImageReader_readInputDataID = (*env)->GetMethodID(env,
+    CHECK_NULL(JPEGImageReader_readInputDataID = (*env)->GetMethodID(env,
                                                   cls,
                                                   "readInputData",
-                                                  "([BII)I");
-    JPEGImageReader_skipInputBytesID = (*env)->GetMethodID(env,
+                                                  "([BII)I"));
+    CHECK_NULL(JPEGImageReader_skipInputBytesID = (*env)->GetMethodID(env,
                                                        cls,
                                                        "skipInputBytes",
-                                                       "(J)J");
-    JPEGImageReader_warningOccurredID = (*env)->GetMethodID(env,
+                                                       "(J)J"));
+    CHECK_NULL(JPEGImageReader_warningOccurredID = (*env)->GetMethodID(env,
                                                             cls,
                                                             "warningOccurred",
-                                                            "(I)V");
-    JPEGImageReader_warningWithMessageID =
+                                                            "(I)V"));
+    CHECK_NULL(JPEGImageReader_warningWithMessageID =
         (*env)->GetMethodID(env,
                             cls,
                             "warningWithMessage",
-                            "(Ljava/lang/String;)V");
-    JPEGImageReader_setImageDataID = (*env)->GetMethodID(env,
+                            "(Ljava/lang/String;)V"));
+    CHECK_NULL(JPEGImageReader_setImageDataID = (*env)->GetMethodID(env,
                                                          cls,
                                                          "setImageData",
-                                                         "(IIIII[B)V");
-    JPEGImageReader_acceptPixelsID = (*env)->GetMethodID(env,
+                                                         "(IIIII[B)V"));
+    CHECK_NULL(JPEGImageReader_acceptPixelsID = (*env)->GetMethodID(env,
                                                          cls,
                                                          "acceptPixels",
-                                                         "(IZ)V");
-    JPEGImageReader_passStartedID = (*env)->GetMethodID(env,
+                                                         "(IZ)V"));
+    CHECK_NULL(JPEGImageReader_passStartedID = (*env)->GetMethodID(env,
                                                         cls,
                                                         "passStarted",
-                                                        "(I)V");
-    JPEGImageReader_passCompleteID = (*env)->GetMethodID(env,
+                                                        "(I)V"));
+    CHECK_NULL(JPEGImageReader_passCompleteID = (*env)->GetMethodID(env,
                                                          cls,
                                                          "passComplete",
-                                                         "()V");
-    JPEGImageReader_pushBackID = (*env)->GetMethodID(env,
+                                                         "()V"));
+    CHECK_NULL(JPEGImageReader_pushBackID = (*env)->GetMethodID(env,
                                                      cls,
                                                      "pushBack",
-                                                     "(I)V");
-    JPEGQTable_tableID = (*env)->GetFieldID(env,
+                                                     "(I)V"));
+    CHECK_NULL(JPEGQTable_tableID = (*env)->GetFieldID(env,
                                             qTableClass,
                                             "qTable",
-                                            "[I");
-
-    JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
+                                            "[I"));
+
+    CHECK_NULL(JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "lengths",
-                                                    "[S");
-
-    JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
+                                                    "[S"));
+
+    CHECK_NULL(JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "values",
-                                                    "[S");
+                                                    "[S"));
 }
 
 JNIEXPORT jlong JNICALL
@@ -1540,9 +1546,9 @@
     /* set up the association to persist for future calls */
     ret = initImageioData(env, (j_common_ptr) cinfo, this);
     if (ret == NULL) {
-        JNU_ThrowByName( env,
-                         "java/lang/OutOfMemoryError",
-                         "Initializing Reader");
+        (*env)->ExceptionClear(env);
+        JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
+                        "Initializing Reader");
         imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
@@ -1637,6 +1643,7 @@
 #endif
 
     if (GET_ARRAYS(env, data, &src->next_input_byte) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -1900,6 +1907,7 @@
 
     body = (*env)->GetIntArrayElements(env, srcBands, NULL);
     if (body == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Read");
@@ -1958,6 +1966,7 @@
     }
 
     if (GET_ARRAYS(env, data, &src->next_input_byte) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -2403,44 +2412,39 @@
      jclass qTableClass,
      jclass huffClass) {
 
-    JPEGImageWriter_writeOutputDataID = (*env)->GetMethodID(env,
+    CHECK_NULL(JPEGImageWriter_writeOutputDataID = (*env)->GetMethodID(env,
                                                     cls,
                                                     "writeOutputData",
-                                                    "([BII)V");
-
-    JPEGImageWriter_warningOccurredID = (*env)->GetMethodID(env,
+                                                    "([BII)V"));
+    CHECK_NULL(JPEGImageWriter_warningOccurredID = (*env)->GetMethodID(env,
                                                             cls,
                                                             "warningOccurred",
-                                                            "(I)V");
-    JPEGImageWriter_warningWithMessageID =
-        (*env)->GetMethodID(env,
-                            cls,
-                            "warningWithMessage",
-                            "(Ljava/lang/String;)V");
-
-    JPEGImageWriter_writeMetadataID = (*env)->GetMethodID(env,
+                                                            "(I)V"));
+    CHECK_NULL(JPEGImageWriter_warningWithMessageID =
+                                        (*env)->GetMethodID(env,
+                                                            cls,
+                                                            "warningWithMessage",
+                                                            "(Ljava/lang/String;)V"));
+    CHECK_NULL(JPEGImageWriter_writeMetadataID = (*env)->GetMethodID(env,
                                                           cls,
                                                           "writeMetadata",
-                                                          "()V");
-    JPEGImageWriter_grabPixelsID = (*env)->GetMethodID(env,
+                                                          "()V"));
+    CHECK_NULL(JPEGImageWriter_grabPixelsID = (*env)->GetMethodID(env,
                                                        cls,
                                                        "grabPixels",
-                                                       "(I)V");
-
-    JPEGQTable_tableID = (*env)->GetFieldID(env,
+                                                       "(I)V"));
+    CHECK_NULL(JPEGQTable_tableID = (*env)->GetFieldID(env,
                                             qTableClass,
                                             "qTable",
-                                            "[I");
-
-    JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
+                                            "[I"));
+    CHECK_NULL(JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "lengths",
-                                                    "[S");
-
-    JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
+                                                    "[S"));
+    CHECK_NULL(JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "values",
-                                                    "[S");
+                                                    "[S"));
 }
 
 JNIEXPORT jlong JNICALL
@@ -2516,6 +2520,7 @@
     /* set up the association to persist for future calls */
     ret = initImageioData(env, (j_common_ptr) cinfo, this);
     if (ret == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Writer");
@@ -2593,6 +2598,7 @@
 
     if (GET_ARRAYS(env, data,
                    (const JOCTET **)(&dest->next_output_byte)) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -2664,6 +2670,7 @@
     imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_compress_ptr cinfo;
     UINT8** scale = NULL;
+    boolean success = TRUE;
 
 
     /* verify the inputs */
@@ -2708,13 +2715,14 @@
     }
 
     bandSize = (*env)->GetIntArrayElements(env, bandSizes, NULL);
+    CHECK_NULL_RETURN(bandSize, JNI_FALSE);
 
     for (i = 0; i < numBands; i++) {
         if (bandSize[i] <= 0 || bandSize[i] > JPEG_BAND_SIZE) {
             (*env)->ReleaseIntArrayElements(env, bandSizes,
                                             bandSize, JNI_ABORT);
             JNU_ThrowByName(env, "javax/imageio/IIOException", "Invalid Image");
-            return JNI_FALSE;;
+            return JNI_FALSE;
         }
     }
 
@@ -2825,30 +2833,30 @@
     vfactors = (*env)->GetIntArrayElements(env, VsamplingFactors, NULL);
     qsels = (*env)->GetIntArrayElements(env, QtableSelectors, NULL);
 
-    if ((ids == NULL) ||
-        (hfactors == NULL) || (vfactors == NULL) ||
-        (qsels == NULL)) {
-        JNU_ThrowByName( env,
-                         "java/lang/OutOfMemoryError",
-                         "Writing JPEG");
-        return JNI_FALSE;
+    if (ids && hfactors && vfactors && qsels) {
+        for (i = 0; i < numBands; i++) {
+            cinfo->comp_info[i].component_id = ids[i];
+            cinfo->comp_info[i].h_samp_factor = hfactors[i];
+            cinfo->comp_info[i].v_samp_factor = vfactors[i];
+            cinfo->comp_info[i].quant_tbl_no = qsels[i];
+        }
+    } else {
+        success = FALSE;
     }
 
-    for (i = 0; i < numBands; i++) {
-        cinfo->comp_info[i].component_id = ids[i];
-        cinfo->comp_info[i].h_samp_factor = hfactors[i];
-        cinfo->comp_info[i].v_samp_factor = vfactors[i];
-        cinfo->comp_info[i].quant_tbl_no = qsels[i];
+    if (ids) {
+        (*env)->ReleaseIntArrayElements(env, componentIds, ids, JNI_ABORT);
+    }
+    if (hfactors) {
+        (*env)->ReleaseIntArrayElements(env, HsamplingFactors, hfactors, JNI_ABORT);
     }
-
-    (*env)->ReleaseIntArrayElements(env, componentIds,
-                                    ids, JNI_ABORT);
-    (*env)->ReleaseIntArrayElements(env, HsamplingFactors,
-                                    hfactors, JNI_ABORT);
-    (*env)->ReleaseIntArrayElements(env, VsamplingFactors,
-                                    vfactors, JNI_ABORT);
-    (*env)->ReleaseIntArrayElements(env, QtableSelectors,
-                                    qsels, JNI_ABORT);
+    if (vfactors) {
+        (*env)->ReleaseIntArrayElements(env, VsamplingFactors, vfactors, JNI_ABORT);
+    }
+    if (qsels) {
+        (*env)->ReleaseIntArrayElements(env, QtableSelectors, qsels, JNI_ABORT);
+    }
+    if (!success) return data->abortFlag;
 
     jpeg_suppress_tables(cinfo, TRUE);  // Disable writing any current
 
@@ -2865,6 +2873,7 @@
 
     if (GET_ARRAYS(env, data,
                    (const JOCTET **)(&dest->next_output_byte)) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -2899,6 +2908,7 @@
             cinfo->scan_info = cinfo->script_space;
             scanptr = (int *) cinfo->script_space;
             scanData = (*env)->GetIntArrayElements(env, scanInfo, NULL);
+            CHECK_NULL_RETURN(scanData, data->abortFlag);
             // number of jints per scan is 9
             // We avoid a memcpy to handle different size ints
             for (i = 0; i < numScans*9; i++) {
--- a/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -465,14 +465,14 @@
 Java_sun_awt_image_JPEGImageDecoder_initIDs(JNIEnv *env, jclass cls,
                                             jclass InputStreamClass)
 {
-    sendHeaderInfoID = (*env)->GetMethodID(env, cls, "sendHeaderInfo",
-                                           "(IIZZZ)Z");
-    sendPixelsByteID = (*env)->GetMethodID(env, cls, "sendPixels", "([BI)Z");
-    sendPixelsIntID = (*env)->GetMethodID(env, cls, "sendPixels", "([II)Z");
-    InputStream_readID = (*env)->GetMethodID(env, InputStreamClass,
-                                             "read", "([BII)I");
-    InputStream_availableID = (*env)->GetMethodID(env, InputStreamClass,
-                                                  "available", "()I");
+    CHECK_NULL(sendHeaderInfoID = (*env)->GetMethodID(env, cls, "sendHeaderInfo",
+                                           "(IIZZZ)Z"));
+    CHECK_NULL(sendPixelsByteID = (*env)->GetMethodID(env, cls, "sendPixels", "([BI)Z"));
+    CHECK_NULL(sendPixelsIntID = (*env)->GetMethodID(env, cls, "sendPixels", "([II)Z"));
+    CHECK_NULL(InputStream_readID = (*env)->GetMethodID(env, InputStreamClass,
+                                             "read", "([BII)I"));
+    CHECK_NULL(InputStream_availableID = (*env)->GetMethodID(env, InputStreamClass,
+                                                  "available", "()I"));
 }
 
 
--- a/src/share/native/sun/awt/medialib/awt_ImagingLib.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/share/native/sun/awt/medialib/awt_ImagingLib.c	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -1151,6 +1151,7 @@
     if (ddata == NULL) {
         /* Need to store it back into the array */
         if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
+            (*env)->ExceptionClear(env); // Could not store the array, try another way
             retStatus = setPixelsFormMlibImage(env, dstRasterP, dst);
         }
     }
@@ -2062,6 +2063,7 @@
 
     jpixels = (*env)->NewIntArray(env, nbytes);
     if (JNU_IsNull(env, jpixels)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
@@ -2127,6 +2129,7 @@
 
     jpixels = (*env)->NewIntArray(env, nbytes);
     if (JNU_IsNull(env, jpixels)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
@@ -2823,21 +2826,14 @@
 
     /* Need to grab the lookup tables.  Right now only bytes */
     rgb = (int *) (*env)->GetPrimitiveArrayCritical(env, cmP->jrgb, NULL);
+    CHECK_NULL_RETURN(rgb, -1);
 
     /* Interleaved with shared data */
     dataP = (void *) (*env)->GetPrimitiveArrayCritical(env,
                                                        rasterP->jdata, NULL);
-    if (rgb == NULL || dataP == NULL) {
+    if (dataP == NULL) {
         /* Release the lookup tables */
-        if (rgb) {
-            (*env)->ReleasePrimitiveArrayCritical(env, cmP->jrgb, rgb,
-                                                  JNI_ABORT);
-        }
-        if (dataP) {
-            (*env)->ReleasePrimitiveArrayCritical(env,
-                                                  rasterP->jdata, dataP,
-                                                  JNI_ABORT);
-        }
+        (*env)->ReleasePrimitiveArrayCritical(env, cmP->jrgb, rgb, JNI_ABORT);
         return -1;
     }
 
--- a/src/solaris/native/sun/awt/CUPSfuncs.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/CUPSfuncs.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, 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
@@ -213,6 +213,8 @@
 
     name = (*env)->GetStringUTFChars(env, printer, NULL);
     if (name == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
         return NULL;
     }
 
@@ -220,12 +222,10 @@
     // unlink() must be caled to remove the file when finished using it.
     filename = j2d_cupsGetPPD(name);
     (*env)->ReleaseStringUTFChars(env, printer, name);
+    CHECK_NULL_RETURN(filename, NULL);
 
     cls = (*env)->FindClass(env, "java/lang/String");
-
-    if (filename == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(cls, NULL);
 
     if ((ppd = j2d_ppdOpenFile(filename)) == NULL) {
         unlink(filename);
@@ -249,6 +249,7 @@
             unlink(filename);
             j2d_ppdClose(ppd);
             DPRINTF("CUPSfuncs::bad alloc new array\n", "")
+            (*env)->ExceptionClear(env);
             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
             return NULL;
         }
@@ -323,6 +324,11 @@
     ppd_size_t *size;
 
     const char *name = (*env)->GetStringUTFChars(env, printer, NULL);
+    if (name == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
+        return NULL;
+    }
     const char *filename;
     int i;
     jobjectArray sizeArray = NULL;
@@ -332,9 +338,7 @@
     // unlink() must be called to remove the file after using it.
     filename = j2d_cupsGetPPD(name);
     (*env)->ReleaseStringUTFChars(env, printer, name);
-    if (filename == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(filename, NULL);
     if ((ppd = j2d_ppdOpenFile(filename)) == NULL) {
         unlink(filename);
         DPRINTF("unable to open PPD  %s\n", filename)
@@ -350,11 +354,19 @@
             unlink(filename);
             j2d_ppdClose(ppd);
             DPRINTF("CUPSfuncs::bad alloc new float array\n", "")
+            (*env)->ExceptionClear(env);
             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
             return NULL;
         }
 
         dims = (*env)->GetFloatArrayElements(env, sizeArray, NULL);
+        if (dims == NULL) {
+            unlink(filename);
+            j2d_ppdClose(ppd);
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
+            return NULL;
+        }
         for (i = 0; i<option->num_choices; i++) {
             choice = (option->choices)+i;
             size = j2d_ppdPageSize(ppd, choice->choice);
--- a/src/solaris/native/sun/awt/X11Color.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/X11Color.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -892,11 +892,10 @@
     jmethodID mid;
 
     clazz = (*env)->FindClass(env,"java/awt/color/ColorSpace");
+    CHECK_NULL_RETURN(clazz, NULL);
     mid = (*env)->GetStaticMethodID(env, clazz, "getInstance",
                                     "(I)Ljava/awt/color/ColorSpace;");
-    if (mid == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(mid, NULL);
 
     /* SECURITY: This is safe, because static methods cannot
      *           be overridden, and this method does not invoke
@@ -919,6 +918,11 @@
         (aData->awt_depth >= 15))
     {
         clazz = (*env)->FindClass(env,"java/awt/image/DirectColorModel");
+        if (clazz == NULL) {
+            (*env)->PopLocalFrame(env, 0);
+            return NULL;
+        }
+
         if (!aData->isTranslucencySupported) {
 
             mid = (*env)->GetMethodID(env,clazz,"<init>","(IIIII)V");
@@ -1005,6 +1009,10 @@
         }
 
         clazz = (*env)->FindClass(env,"java/awt/image/ComponentColorModel");
+        if (clazz == NULL) {
+            (*env)->PopLocalFrame(env, 0);
+            return NULL;
+        }
 
         mid = (*env)->GetMethodID(env,clazz,"<init>",
             "(Ljava/awt/color/ColorSpace;[IZZII)V");
@@ -1253,6 +1261,7 @@
     if (!JNU_IsNull(env,this))
     {
         SYSCLR_class = (*env)->FindClass(env, "java/awt/SystemColor");
+        CHECK_NULL_RETURN(SYSCLR_class, 0);
 
         if ((*env)->IsInstanceOf(env, this, SYSCLR_class)) {
                 /* SECURITY: This is safe, because there is no way
@@ -1264,6 +1273,7 @@
                                           ,this
                                           ,"getRGB"
                                           ,"()I").i;
+                JNU_CHECK_EXCEPTION_RETURN(env, 0);
         } else {
                 col = (int)(*env)->GetIntField(env,this,colorValueID);
         }
@@ -1370,6 +1380,8 @@
             AWT_UNLOCK ();
         }
         sysColors = (*env)->FindClass (env, "java/awt/SystemColor");
+        CHECK_NULL(sysColors);
+
         if (lock) {
             AWT_LOCK ();
         }
@@ -1377,6 +1389,13 @@
                                                    "systemColors",
                                                    "[I");
 
+        if (colorID == NULL) {
+            if (lock) {
+                AWT_UNLOCK();
+            }
+            return;
+        }
+
         colors = (jintArray) (*env)->GetStaticObjectField
                                                 (env, sysColors, colorID);
 
--- a/src/solaris/native/sun/awt/awt.h	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt.h	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -77,8 +77,22 @@
 
 #define AWT_LOCK_IMPL() \
     (*env)->CallStaticVoidMethod(env, tkClass, awtLockMID)
+
 #define AWT_NOFLUSH_UNLOCK_IMPL() \
-    (*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID)
+    do { \
+      jthrowable pendingException; \
+      if ((pendingException = (*env)->ExceptionOccurred(env)) != NULL) { \
+         (*env)->ExceptionClear(env); \
+      } \
+      (*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID); \
+      if (pendingException) { \
+         if ((*env)->ExceptionCheck(env)) { \
+            (*env)->ExceptionDescribe(env); \
+            (*env)->ExceptionClear(env); \
+         } \
+         (*env)->Throw(env, pendingException); \
+      } \
+    } while (0)
 #define AWT_WAIT_IMPL(tm) \
     (*env)->CallStaticVoidMethod(env, tkClass, awtWaitMID, (jlong)(tm))
 #define AWT_NOTIFY_IMPL() \
--- a/src/solaris/native/sun/awt/awt_AWTEvent.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_AWTEvent.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -49,22 +49,22 @@
 JNIEXPORT void JNICALL
 Java_java_awt_AWTEvent_initIDs(JNIEnv *env, jclass cls)
 {
-    awtEventIDs.bdata = (*env)->GetFieldID(env, cls, "bdata", "[B");
-    awtEventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z");
-    awtEventIDs.id = (*env)->GetFieldID(env, cls, "id", "I");
+    CHECK_NULL(awtEventIDs.bdata = (*env)->GetFieldID(env, cls, "bdata", "[B"));
+    CHECK_NULL(awtEventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z"));
+    CHECK_NULL(awtEventIDs.id = (*env)->GetFieldID(env, cls, "id", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_event_InputEvent_initIDs(JNIEnv *env, jclass cls)
 {
-    inputEventIDs.modifiers = (*env)->GetFieldID(env, cls, "modifiers", "I");
+    CHECK_NULL(inputEventIDs.modifiers = (*env)->GetFieldID(env, cls, "modifiers", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_event_KeyEvent_initIDs(JNIEnv *env, jclass cls)
 {
-    keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I");
-    keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C");
+    CHECK_NULL(keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I"));
+    CHECK_NULL(keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C"));
 }
 
 JNIEXPORT void JNICALL
--- a/src/solaris/native/sun/awt/awt_DrawingSurface.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_DrawingSurface.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -78,6 +78,8 @@
 
     /* Make sure the target is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, (jint)JAWT_LOCK_ERROR);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
             fprintf(stderr, "Target is not a component\n");
@@ -126,6 +128,8 @@
 
     /* Make sure the target is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, (int32_t) 0);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
         fprintf(stderr, "DrawingSurface target must be a component\n");
@@ -195,6 +199,8 @@
 
     /* Make sure the target is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, NULL);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
         fprintf(stderr, "DrawingSurface target must be a component\n");
@@ -292,6 +298,8 @@
 
     /* Make sure the target component is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, NULL);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
         fprintf(stderr,
@@ -354,6 +362,10 @@
     if (window != None) {
         peer = JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit",
             "windowToXWindow", "(J)Lsun/awt/X11/XBaseWindow;", (jlong)window).l;
+        if ((*env)->ExceptionCheck(env)) {
+            AWT_UNLOCK();
+            return (jobject)NULL;
+        }
     }
     if ((peer != NULL) &&
         (JNU_IsInstanceOfByName(env, peer, "sun/awt/X11/XWindow") == 1)) {
@@ -361,6 +373,7 @@
     }
 
     if (target == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "NullPointerException");
         AWT_UNLOCK();
         return (jobject)NULL;
--- a/src/solaris/native/sun/awt/awt_Font.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_Font.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -86,14 +86,13 @@
 #ifndef HEADLESS
     /** We call "NoClientCode" methods because they won't invoke client
         code on the privileged toolkit thread **/
-    fontIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
-    fontIDs.style = (*env)->GetFieldID(env, cls, "style", "I");
-    fontIDs.size = (*env)->GetFieldID(env, cls, "size", "I");
-    fontIDs.getPeer = (*env)->GetMethodID(env, cls, "getPeer_NoClientCode",
-                                           "()Ljava/awt/peer/FontPeer;");
-    fontIDs.getFamily =
-      (*env)->GetMethodID(env, cls, "getFamily_NoClientCode",
-                                            "()Ljava/lang/String;");
+    CHECK_NULL(fontIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J"));
+    CHECK_NULL(fontIDs.style = (*env)->GetFieldID(env, cls, "style", "I"));
+    CHECK_NULL(fontIDs.size = (*env)->GetFieldID(env, cls, "size", "I"));
+    CHECK_NULL(fontIDs.getPeer = (*env)->GetMethodID(env, cls, "getPeer_NoClientCode",
+                                                     "()Ljava/awt/peer/FontPeer;"));
+    CHECK_NULL(fontIDs.getFamily = (*env)->GetMethodID(env, cls, "getFamily_NoClientCode",
+                                                       "()Ljava/lang/String;"));
 #endif /* !HEADLESS */
 }
 
@@ -120,12 +119,10 @@
   (JNIEnv *env, jclass cls)
 {
 #ifndef HEADLESS
-    fontDescriptorIDs.nativeName =
-      (*env)->GetFieldID(env, cls, "nativeName",
-                         "Ljava/lang/String;");
-    fontDescriptorIDs.charsetName =
-      (*env)->GetFieldID(env, cls, "charsetName",
-                         "Ljava/lang/String;");
+    CHECK_NULL(fontDescriptorIDs.nativeName =
+               (*env)->GetFieldID(env, cls, "nativeName", "Ljava/lang/String;"));
+    CHECK_NULL(fontDescriptorIDs.charsetName =
+               (*env)->GetFieldID(env, cls, "charsetName", "Ljava/lang/String;"));
 #endif /* !HEADLESS */
 }
 
@@ -144,20 +141,18 @@
   (JNIEnv *env, jclass cls)
 {
 #ifndef HEADLESS
-    platformFontIDs.componentFonts =
-      (*env)->GetFieldID(env, cls, "componentFonts",
-                         "[Lsun/awt/FontDescriptor;");
-    platformFontIDs.fontConfig =
-      (*env)->GetFieldID(env,cls, "fontConfig",
-                         "Lsun/awt/FontConfiguration;");
-
-    platformFontIDs.makeConvertedMultiFontString =
-      (*env)->GetMethodID(env, cls, "makeConvertedMultiFontString",
-                          "(Ljava/lang/String;)[Ljava/lang/Object;");
-
-    platformFontIDs.makeConvertedMultiFontChars =
-      (*env)->GetMethodID(env, cls, "makeConvertedMultiFontChars",
-                          "([CII)[Ljava/lang/Object;");
+    CHECK_NULL(platformFontIDs.componentFonts =
+               (*env)->GetFieldID(env, cls, "componentFonts",
+                                  "[Lsun/awt/FontDescriptor;"));
+    CHECK_NULL(platformFontIDs.fontConfig =
+               (*env)->GetFieldID(env,cls, "fontConfig",
+                                  "Lsun/awt/FontConfiguration;"));
+    CHECK_NULL(platformFontIDs.makeConvertedMultiFontString =
+               (*env)->GetMethodID(env, cls, "makeConvertedMultiFontString",
+                                   "(Ljava/lang/String;)[Ljava/lang/Object;"));
+    CHECK_NULL(platformFontIDs.makeConvertedMultiFontChars =
+               (*env)->GetMethodID(env, cls, "makeConvertedMultiFontChars",
+                                   "([CII)[Ljava/lang/Object;"));
 #endif /* !HEADLESS */
 }
 
@@ -385,6 +380,11 @@
         return 0;
     }
     cname = (char *) JNU_GetStringPlatformChars(env, name, NULL);
+    if (cname == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create font name");
+        return 0;
+    }
 
     /* additional default font names */
     if (strcmp(cname, "serif") == 0) {
@@ -448,6 +448,8 @@
     }
 
     if (!JNU_IsNull(env, font) && awtJNI_IsMultiFont(env, font)) {
+        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
+
         struct FontData *fdata = NULL;
         int32_t i, size;
         char *fontsetname = NULL;
@@ -513,6 +515,11 @@
 
             fdata->flist[i].charset_name = (char *)
                 JNU_GetStringPlatformChars(env, charsetName, NULL);
+            if (fdata->flist[i].charset_name == NULL) {
+                (*env)->ExceptionClear(env);
+                JNU_ThrowOutOfMemoryError(env, "Could not create charset name");
+                return NULL;
+            }
 
             /* We are done with the objects. */
             (*env)->DeleteLocalRef(env, fontDescriptor);
--- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -152,8 +152,11 @@
     x11GraphicsConfigIDs.screen = NULL;
 
     x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J");
+    CHECK_NULL(x11GraphicsConfigIDs.aData);
     x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
+    CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
     x11GraphicsConfigIDs.screen = (*env)->GetFieldID (env, cls, "screen", "Lsun/awt/X11GraphicsDevice;");
+    CHECK_NULL(x11GraphicsConfigIDs.screen);
 
     if (x11GraphicsConfigIDs.aData == NULL ||
             x11GraphicsConfigIDs.bitsPerPixel == NULL ||
@@ -1346,7 +1349,6 @@
 
     /* Make Color Model object for this GraphicsConfiguration */
     colorModel = awtJNI_GetColorModel (env, adata);
-
     AWT_UNLOCK ();
 
     return colorModel;
@@ -1374,6 +1376,7 @@
         JNU_GetLongFieldAsPtr(env, this, x11GraphicsConfigIDs.aData);
 
     clazz = (*env)->FindClass(env, "java/awt/Rectangle");
+    CHECK_NULL_RETURN(clazz, NULL);
     mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
     if (mid != NULL) {
         if (usingXinerama) {
@@ -1543,7 +1546,7 @@
     clazz = (*env)->GetObjectClass(env, this);
     midAddVisual = (*env)->GetMethodID(env, clazz, "addDoubleBufferVisual",
         "(I)V");
-
+    CHECK_NULL(midAddVisual);
     AWT_LOCK();
     rootWindow = RootWindow(awt_display, xinawareScreen);
     visScreenInfo = XdbeGetVisualInfo(awt_display, &rootWindow, &n);
@@ -1739,6 +1742,7 @@
     jint validRefreshRate = refreshRate;
 
     displayModeClass = (*env)->FindClass(env, "java/awt/DisplayMode");
+    CHECK_NULL_RETURN(displayModeClass, NULL);
     if (JNU_IsNull(env, displayModeClass)) {
         JNU_ThrowInternalError(env,
                                "Could not get display mode class");
@@ -1746,6 +1750,7 @@
     }
 
     cid = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
+    CHECK_NULL_RETURN(cid, NULL);
     if (cid == NULL) {
         JNU_ThrowInternalError(env,
                                "Could not get display mode constructor");
@@ -1779,6 +1784,7 @@
         }
         mid = (*env)->GetMethodID(env, arrayListClass, "add",
                                   "(Ljava/lang/Object;)Z");
+        CHECK_NULL(mid);
         if (mid == NULL) {
             JNU_ThrowInternalError(env,
                 "Could not get method java.util.ArrayList.add()");
@@ -1955,6 +1961,9 @@
                                          size.height,
                                          BIT_DEPTH_MULTI,
                                          rates[j]);
+                    if ((*env)->ExceptionCheck(env)) {
+                        break;
+                    }
                 }
             }
         }
--- a/src/solaris/native/sun/awt/awt_InputMethod.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_InputMethod.c	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -319,6 +319,7 @@
         JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
                              "flushText",
                              "()V");
+        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
         /* IMPORTANT:
            The order of the following calls is critical since "imInstance" may
            point to the global reference itself, if "freeX11InputMethodData" is called
@@ -1120,6 +1121,9 @@
         if (text->string.multi_byte != NULL) {
             if (pre_draw->text->encoding_is_wchar == False) {
                 javastr = JNU_NewStringPlatform(env, (const char *)text->string.multi_byte);
+                if (javastr == NULL) {
+                    goto finally;
+                }
             } else {
                 char *mbstr = wcstombsdmp(text->string.wide_char, text->length);
                 if (mbstr == NULL) {
@@ -1127,6 +1131,9 @@
                 }
                 javastr = JNU_NewStringPlatform(env, (const char *)mbstr);
                 free(mbstr);
+                if (javastr == NULL) {
+                    goto finally;
+                }
             }
         }
         if (text->feedback != NULL) {
@@ -1135,6 +1142,7 @@
 
             style = (*env)->NewIntArray(env, text->length);
             if (JNU_IsNull(env, style)) {
+                (*env)->ExceptionClear(env);
                 THROW_OUT_OF_MEMORY_ERROR();
                 goto finally;
             }
@@ -1395,14 +1403,17 @@
     pX11IMData->lookup_buf = 0;
     pX11IMData->lookup_buf_len = 0;
 
-    if (createXIC(env, pX11IMData, (Window)window)
-        == False) {
+    if (createXIC(env, pX11IMData, (Window)window) == False) {
         destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
         pX11IMData = (X11InputMethodData *) NULL;
+        if ((*env)->ExceptionCheck(env)) {
+            goto finally;
+        }
     }
 
     setX11InputMethodData(env, this, pX11IMData);
 
+finally:
     AWT_UNLOCK();
     return (pX11IMData != NULL);
 }
--- a/src/solaris/native/sun/awt/awt_Insets.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_Insets.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -34,8 +34,8 @@
 JNIEXPORT void JNICALL
 Java_java_awt_Insets_initIDs(JNIEnv *env, jclass cls)
 {
-    insetsIDs.top = (*env)->GetFieldID(env, cls, "top", "I");
-    insetsIDs.bottom = (*env)->GetFieldID(env, cls, "bottom", "I");
-    insetsIDs.left = (*env)->GetFieldID(env, cls, "left", "I");
-    insetsIDs.right = (*env)->GetFieldID(env, cls, "right", "I");
+    CHECK_NULL(insetsIDs.top = (*env)->GetFieldID(env, cls, "top", "I"));
+    CHECK_NULL(insetsIDs.bottom = (*env)->GetFieldID(env, cls, "bottom", "I"));
+    CHECK_NULL(insetsIDs.left = (*env)->GetFieldID(env, cls, "left", "I"));
+    CHECK_NULL(insetsIDs.right = (*env)->GetFieldID(env, cls, "right", "I"));
 }
--- a/src/solaris/native/sun/awt/awt_LoadLibrary.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_LoadLibrary.c	Thu May 01 00:00:08 2014 -0700
@@ -77,11 +77,16 @@
     return isHeadless;
 }
 
+#define CHECK_EXCEPTION_FATAL(env, message) \
+    if ((*env)->ExceptionCheck(env)) { \
+        (*env)->ExceptionClear(env); \
+        (*env)->FatalError(env, message); \
+    }
+
 /*
  * Pathnames to the various awt toolkits
  */
 
-
 #ifdef MACOSX
   #define LWAWT_PATH "/libawt_lwawt.dylib"
   #define DEFAULT_PATH LWAWT_PATH
@@ -125,6 +130,8 @@
      */
 
     fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
+    CHECK_EXCEPTION_FATAL(env, "Could not allocate font manager property");
+
 #ifdef MACOSX
         fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
         tk = LWAWT_PATH;
@@ -132,10 +139,13 @@
         fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
         tk = XAWT_PATH;
 #endif
+    CHECK_EXCEPTION_FATAL(env, "Could not allocate font manager name");
+
     if (fmanager && fmProp) {
         JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "setProperty",
                                    "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
                                    fmProp, fmanager);
+        CHECK_EXCEPTION_FATAL(env, "Could not allocate set properties");
     }
 
 #ifndef MACOSX
@@ -154,9 +164,11 @@
         (*env)->DeleteLocalRef(env, fmanager);
     }
 
+    jstring jbuf = JNU_NewStringPlatform(env, buf);
+    CHECK_EXCEPTION_FATAL(env, "Could not allocate library name");
     JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
                                "(Ljava/lang/String;)V",
-                               JNU_NewStringPlatform(env, buf));
+                               jbuf);
 
     awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
 
--- a/src/solaris/native/sun/awt/awt_Robot.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_Robot.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -175,10 +175,13 @@
 
     num_buttons = numberOfButtons;
     tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE);
+    CHECK_NULL(tmp);
+
     masks = (jint *)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), num_buttons);
     if (masks == (jint *) NULL) {
+        (*env)->ExceptionClear(env);
+        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
         JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
-        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
         return;
     }
     for (i = 0; i < num_buttons; i++) {
--- a/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2013, 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
@@ -98,6 +98,7 @@
                                           (*env)->GetObjectClass(env, this));
         icon_upcall_method = (*env)->GetMethodID(env, this_class,
                                  "loadIconCallback", "([BIIIIIZ)V");
+        CHECK_NULL_RETURN(icon_upcall_method, JNI_FALSE);
     }
 
     if (pixbuf != NULL)
@@ -112,6 +113,8 @@
 
         /* Copy the data array into a Java structure so we can pass it back. */
         jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
+        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
+
         (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
                                    (jbyte *)pixbuf_data);
 
--- a/src/solaris/native/sun/awt/awt_util.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_util.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -76,6 +76,7 @@
         Boolean err = FALSE;
         if (threadClass == NULL) {
             jclass tc = (*env)->FindClass(env, "java/lang/Thread");
+            CHECK_NULL(tc);
             threadClass = (*env)->NewGlobalRef(env, tc);
             (*env)->DeleteLocalRef(env, tc);
             if (threadClass != NULL) {
--- a/src/solaris/native/sun/awt/fontpath.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/fontpath.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -161,17 +161,22 @@
 
     if (! isLocalSet) {
       jclass geCls = (*env)->FindClass(env, "java/awt/GraphicsEnvironment");
+      CHECK_NULL_RETURN(geCls, JNI_FALSE);
       jmethodID getLocalGE = (*env)->GetStaticMethodID(env, geCls,
                                                  "getLocalGraphicsEnvironment",
                                            "()Ljava/awt/GraphicsEnvironment;");
+      CHECK_NULL_RETURN(getLocalGE, JNI_FALSE);
       jobject ge = (*env)->CallStaticObjectMethod(env, geCls, getLocalGE);
+      JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
 
       jclass sgeCls = (*env)->FindClass(env,
                                         "sun/java2d/SunGraphicsEnvironment");
+      CHECK_NULL_RETURN(sgeCls, JNI_FALSE);
       if ((*env)->IsInstanceOf(env, ge, sgeCls)) {
         jmethodID isDisplayLocal = (*env)->GetMethodID(env, sgeCls,
                                                        "isDisplayLocal",
                                                        "()Z");
+        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
         isLocal = (*env)->CallBooleanMethod(env, ge, isDisplayLocal);
       } else {
         isLocal = True;
@@ -1005,50 +1010,38 @@
     jmethodID fcFontCons;
     char* debugMinGlyphsStr = getenv("J2D_DEBUG_MIN_GLYPHS");
 
+    CHECK_NULL(fcInfoObj);
+    CHECK_NULL(fcCompFontArray);
+
     jclass fcInfoClass =
         (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigInfo");
+    CHECK_NULL(fcInfoClass);
     jclass fcCompFontClass =
         (*env)->FindClass(env, "sun/font/FontConfigManager$FcCompFont");
+    CHECK_NULL(fcCompFontClass);
     jclass fcFontClass =
          (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigFont");
-
-    if (fcInfoObj == NULL || fcCompFontArray == NULL || fcInfoClass == NULL ||
-        fcCompFontClass == NULL || fcFontClass == NULL) {
-        return;
-    }
-
-    fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I");
+    CHECK_NULL(fcFontClass);
 
-    fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs",
-                                       "[Ljava/lang/String;");
-
-    fcNameID = (*env)->GetFieldID(env, fcCompFontClass,
-                                  "fcName", "Ljava/lang/String;");
-    fcFirstFontID =
-        (*env)->GetFieldID(env, fcCompFontClass, "firstFont",
-                           "Lsun/font/FontConfigManager$FontConfigFont;");
 
-    fcAllFontsID =
-        (*env)->GetFieldID(env, fcCompFontClass, "allFonts",
-                           "[Lsun/font/FontConfigManager$FontConfigFont;");
-
-    fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V");
-
-    familyNameID = (*env)->GetFieldID(env, fcFontClass,
-                                      "familyName", "Ljava/lang/String;");
-    styleNameID = (*env)->GetFieldID(env, fcFontClass,
-                                    "styleStr", "Ljava/lang/String;");
-    fullNameID = (*env)->GetFieldID(env, fcFontClass,
-                                    "fullName", "Ljava/lang/String;");
-    fontFileID = (*env)->GetFieldID(env, fcFontClass,
-                                    "fontFile", "Ljava/lang/String;");
-
-    if (fcVersionID == NULL || fcCacheDirsID == NULL || fcNameID == NULL ||
-        fcFirstFontID == NULL || fcAllFontsID == NULL || fcFontCons == NULL ||
-        familyNameID == NULL || styleNameID == NULL || fullNameID == NULL ||
-        fontFileID == NULL) {
-        return;
-    }
+    CHECK_NULL(fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I"));
+    CHECK_NULL(fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs",
+                                                  "[Ljava/lang/String;"));
+    CHECK_NULL(fcNameID = (*env)->GetFieldID(env, fcCompFontClass,
+                                             "fcName", "Ljava/lang/String;"));
+    CHECK_NULL(fcFirstFontID = (*env)->GetFieldID(env, fcCompFontClass, "firstFont",
+                                        "Lsun/font/FontConfigManager$FontConfigFont;"));
+    CHECK_NULL(fcAllFontsID = (*env)->GetFieldID(env, fcCompFontClass, "allFonts",
+                                        "[Lsun/font/FontConfigManager$FontConfigFont;"));
+    CHECK_NULL(fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V"));
+    CHECK_NULL(familyNameID = (*env)->GetFieldID(env, fcFontClass,
+                                      "familyName", "Ljava/lang/String;"));
+    CHECK_NULL(styleNameID = (*env)->GetFieldID(env, fcFontClass,
+                                    "styleStr", "Ljava/lang/String;"));
+    CHECK_NULL(fullNameID = (*env)->GetFieldID(env, fcFontClass,
+                                    "fullName", "Ljava/lang/String;"));
+    CHECK_NULL(fontFileID = (*env)->GetFieldID(env, fcFontClass,
+                                    "fontFile", "Ljava/lang/String;"));
 
     if ((libfontconfig = openFontConfig()) == NULL) {
         return;
@@ -1129,6 +1122,8 @@
         if (cacheDirs != NULL) {
             while ((cnt < max) && (cacheDir = (*FcStrListNext)(cacheDirs))) {
                 jstr = (*env)->NewStringUTF(env, (const char*)cacheDir);
+                JNU_CHECK_EXCEPTION(env);
+
                 (*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
             }
             (*FcStrListDone)(cacheDirs);
@@ -1136,6 +1131,11 @@
     }
 
     locale = (*env)->GetStringUTFChars(env, localeStr, 0);
+    if (locale == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create locale");
+        return;
+    }
 
     arrlen = (*env)->GetArrayLength(env, fcCompFontArray);
     for (i=0; i<arrlen; i++) {
--- a/src/solaris/native/sun/awt/initIDs.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/initIDs.c	Thu May 01 00:00:08 2014 -0700
@@ -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
@@ -47,9 +47,6 @@
   (JNIEnv *env, jclass clazz)
 {
     colorValueID = (*env)->GetFieldID(env, clazz, "value", "I");
-
-    if(colorValueID == NULL)
-        JNU_ThrowNullPointerException (env, "Can't get java/awt/Color.value fieldID");
 }
 
 JNIEXPORT void JNICALL
--- a/src/solaris/native/sun/awt/multi_font.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/multi_font.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -74,7 +74,7 @@
     jobject temp = NULL;
     jboolean validRet = JNI_FALSE;
 
-    if ((*env)->EnsureLocalCapacity(env, 2) < 0)
+    if ((*env)->EnsureLocalCapacity(env, 2) < 0 || (*env)->ExceptionCheck(env))
         goto done;
 
     peer = (*env)->CallObjectMethod(env,font,fontIDs.getPeer);
@@ -162,7 +162,7 @@
 
     font = JNU_CallMethodByName(env, NULL, this, "getFont_NoClientCode",
                                 "()Ljava/awt/Font;").l;
-    if (JNU_IsNull(env, font)) {
+    if (JNU_IsNull(env, font) || (*env)->ExceptionCheck(env)) {
         return JNI_FALSE;
     }
 
@@ -318,6 +318,10 @@
     }
 
     fdata = awtJNI_GetFontData(env, font, &err);
+    if ((*env)->ExceptionCheck(env)) {
+        (*env)->DeleteLocalRef(env, dataArray);
+        return 0;
+    }
 
     stringCount = (*env)->GetArrayLength(env, dataArray);
 
@@ -336,6 +340,11 @@
         }
 
         j = awtJNI_GetFontDescriptorNumber(env, font, fontDescriptor);
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->DeleteLocalRef(env, fontDescriptor);
+            (*env)->DeleteLocalRef(env, data);
+            break;
+        }
 
         if (fdata->flist[j].load == 0) {
             xf = loadFont(awt_display,
@@ -356,6 +365,14 @@
 
         stringData =
             (unsigned char *)(*env)->GetPrimitiveArrayCritical(env, data,NULL);
+        if (stringData == NULL) {
+            (*env)->DeleteLocalRef(env, fontDescriptor);
+            (*env)->DeleteLocalRef(env, data);
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not get string data");
+            break;
+        }
+
         length = (stringData[0] << 24) | (stringData[1] << 16) |
             (stringData[2] << 8) | stringData[3];
         offsetStringData = (char *)(stringData + (4 * sizeof(char)));
--- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -45,10 +45,12 @@
     filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
             "filenameFilterCallback", "(Ljava/lang/String;)Z");
     DASSERT(filenameFilterCallbackMethodID != NULL);
+    CHECK_NULL(filenameFilterCallbackMethodID);
 
     setFileInternalMethodID = (*env)->GetMethodID(env, cx,
             "setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
     DASSERT(setFileInternalMethodID != NULL);
+    CHECK_NULL(setFileInternalMethodID);
 
     widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J");
     DASSERT(widgetFieldID != NULL);
@@ -63,6 +65,7 @@
     env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
     filename = (*env)->NewStringUTF(env, filter_info->filename);
+    JNU_CHECK_EXCEPTION_RETURN(env, FALSE);
 
     return (*env)->CallBooleanMethod(env, obj, filenameFilterCallbackMethodID,
             filename);
@@ -173,13 +176,14 @@
 
     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;
     }
 
-    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
-            NULL);
+    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;
     }
@@ -189,7 +193,9 @@
         entry = (char*) iterator->data;
         entry = strrchr(entry, '/') + 1;
         str = (*env)->NewStringUTF(env, entry);
-        (*env)->SetObjectArrayElement(env, array, i, str);
+        if (str && !(*env)->ExceptionCheck(env)) {
+            (*env)->SetObjectArrayElement(env, array, i, str);
+        }
         i++;
     }
 
@@ -215,13 +221,14 @@
 
     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;
     }
 
-    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
-            NULL);
+    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;
     }
@@ -236,7 +243,9 @@
         }
 
         str = (*env)->NewStringUTF(env, entry);
-        (*env)->SetObjectArrayElement(env, array, i, str);
+        if (str && !(*env)->ExceptionCheck(env)) {
+            (*env)->SetObjectArrayElement(env, array, i, str);
+        }
         i++;
     }
 
@@ -268,16 +277,17 @@
     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, "/");
-        jfilenames = toPathAndFilenamesArray(env, filenames);
     } else {
-        jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
         jfilenames = toFilenamesArray(env, filenames);
+        jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
     }
-    (*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
-            jfilenames);
+    if (!(*env)->ExceptionCheck(env)) {
+        (*env)->CallVoidMethod(env, obj, setFileInternalMethodID,
+                               jcurrent_folder, jfilenames);
+    }
     fp_g_free(current_folder);
-
     quit(env, (jobject)obj, TRUE);
 }
 
@@ -296,11 +306,17 @@
 
     if (jvm == NULL) {
         (*env)->GetJavaVM(env, &jvm);
+        JNU_CHECK_EXCEPTION(env);
     }
 
     fp_gdk_threads_enter();
 
     const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
+    if (title == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not get title");
+        return;
+    }
 
     if (mode == java_awt_FileDialog_SAVE) {
         /* Save action */
@@ -328,6 +344,11 @@
     /* Set the directory */
     if (jdir != NULL) {
         const char *dir = (*env)->GetStringUTFChars(env, jdir, 0);
+        if (dir == NULL) {
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not get dir");
+            return;
+        }
         fp_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
         (*env)->ReleaseStringUTFChars(env, jdir, dir);
     }
@@ -335,6 +356,11 @@
     /* Set the filename */
     if (jfile != NULL) {
         const char *filename = (*env)->GetStringUTFChars(env, jfile, 0);
+        if (filename == NULL) {
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not get filename");
+            return;
+        }
         if (mode == java_awt_FileDialog_SAVE) {
             fp_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
         } else {
--- a/src/windows/native/sun/java2d/windows/GDIRenderer.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/java2d/windows/GDIRenderer.cpp	Thu May 01 00:00:08 2014 -0700
@@ -23,6 +23,7 @@
  * questions.
  */
 
+#include "jni_util.h"
 #include "awt.h"
 #include "sun_java2d_windows_GDIRenderer.h"
 #include "java_awt_geom_PathIterator.h"
@@ -387,13 +388,20 @@
         return;
     }
 
-    POINT tmpPts[POLYTEMPSIZE], *pPoints;
+    POINT tmpPts[POLYTEMPSIZE], *pPoints = NULL;
+
     jint *xpoints = (jint *) env->GetPrimitiveArrayCritical(xpointsarray, NULL);
-    jint *ypoints = (jint *) env->GetPrimitiveArrayCritical(ypointsarray, NULL);
-    pPoints = TransformPoly(xpoints, ypoints, transx, transy,
-                            tmpPts, &npoints, isclosed, TRUE);
-    env->ReleasePrimitiveArrayCritical(xpointsarray, xpoints, JNI_ABORT);
-    env->ReleasePrimitiveArrayCritical(ypointsarray, ypoints, JNI_ABORT);
+
+    if (xpoints != NULL) {
+        jint *ypoints = (jint *) env->GetPrimitiveArrayCritical(ypointsarray, NULL);
+        if (ypoints != NULL) {
+            pPoints = TransformPoly(xpoints, ypoints, transx, transy,
+                                    tmpPts, &npoints, isclosed, TRUE);
+            env->ReleasePrimitiveArrayCritical(ypointsarray, ypoints, JNI_ABORT);
+        }
+        env->ReleasePrimitiveArrayCritical(xpointsarray, xpoints, JNI_ABORT);
+    }
+
     if (pPoints == NULL) {
         return;
     }
@@ -654,13 +662,19 @@
         return;
     }
 
-    POINT tmpPts[POLYTEMPSIZE], *pPoints;
+    POINT tmpPts[POLYTEMPSIZE], *pPoints = NULL;
+
     jint *xpoints = (jint *) env->GetPrimitiveArrayCritical(xpointsarray, NULL);
-    jint *ypoints = (jint *) env->GetPrimitiveArrayCritical(ypointsarray, NULL);
-    pPoints = TransformPoly(xpoints, ypoints, transx, transy,
-                            tmpPts, &npoints, FALSE, FALSE);
-    env->ReleasePrimitiveArrayCritical(xpointsarray, xpoints, JNI_ABORT);
-    env->ReleasePrimitiveArrayCritical(ypointsarray, ypoints, JNI_ABORT);
+    if (xpoints != NULL) {
+        jint *ypoints = (jint *) env->GetPrimitiveArrayCritical(ypointsarray, NULL);
+        if (ypoints != NULL) {
+            pPoints = TransformPoly(xpoints, ypoints, transx, transy,
+                                tmpPts, &npoints, FALSE, FALSE);
+            env->ReleasePrimitiveArrayCritical(ypointsarray, xpoints, JNI_ABORT);
+        }
+        env->ReleasePrimitiveArrayCritical(xpointsarray, xpoints, JNI_ABORT);
+    }
+
     if (pPoints == NULL) {
         return;
     }
@@ -720,13 +734,26 @@
     if (hdc == NULL) {
         return;
     }
+
+    jbyte *types = (jbyte *) env->GetPrimitiveArrayCritical(typesarray,
+                                                            NULL);
+    if (types == NULL) {
+        wsdo->ReleaseDC(env, wsdo, hdc);
+        return;
+    }
+
+    jfloat *coords = (jfloat *) env->GetPrimitiveArrayCritical(coordsarray,
+                                                               NULL);
+    if (coords == NULL) {
+        env->ReleasePrimitiveArrayCritical(typesarray, types, JNI_ABORT);
+        wsdo->ReleaseDC(env, wsdo, hdc);
+        return;
+    }
+
     ::SetPolyFillMode(hdc, (rule == java_awt_geom_PathIterator_WIND_NON_ZERO
                             ? WINDING : ALTERNATE));
     ::BeginPath(hdc);
-    jbyte *types = (jbyte *) env->GetPrimitiveArrayCritical(typesarray,
-                                                            NULL);
-    jfloat *coords = (jfloat *) env->GetPrimitiveArrayCritical(coordsarray,
-                                                               NULL);
+
     int index = 0;
     BOOL ok = TRUE;
     BOOL isempty = TRUE;
--- a/src/windows/native/sun/java2d/windows/WindowsFlags.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/java2d/windows/WindowsFlags.cpp	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, 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
@@ -47,12 +47,15 @@
 {
     wFlagsClassID = (jclass)env->NewGlobalRef(wFlagsClass);
     d3dEnabledID = env->GetStaticFieldID(wFlagsClass, "d3dEnabled", "Z");
+    CHECK_NULL(d3dEnabledID);
     d3dSetID = env->GetStaticFieldID(wFlagsClass, "d3dSet", "Z");
+    CHECK_NULL(d3dSetID);
 }
 
 BOOL GetStaticBoolean(JNIEnv *env, jclass wfClass, const char *fieldName)
 {
     jfieldID fieldID = env->GetStaticFieldID(wfClass, fieldName, "Z");
+    CHECK_NULL_RETURN(fieldID, FALSE);
     return env->GetStaticBooleanField(wfClass, fieldID);
 }
 
@@ -60,6 +63,7 @@
                         const char *signature)
 {
     jfieldID fieldID = env->GetStaticFieldID(wfClass, fieldName, signature);
+    CHECK_NULL_RETURN(fieldID, NULL);
     return env->GetStaticObjectField(wfClass, fieldID);
 }
 
@@ -90,15 +94,17 @@
     forceD3DUsage = d3dSet;
     g_offscreenSharing = GetStaticBoolean(env, wFlagsClass,
                                           "offscreenSharingEnabled");
+    JNU_CHECK_EXCEPTION(env);
     accelReset = GetStaticBoolean(env, wFlagsClass, "accelReset");
+    JNU_CHECK_EXCEPTION(env);
     checkRegistry = GetStaticBoolean(env, wFlagsClass, "checkRegistry");
+    JNU_CHECK_EXCEPTION(env);
     disableRegistry = GetStaticBoolean(env, wFlagsClass, "disableRegistry");
-    jstring javaVersionString = (jstring)GetStaticObject(env, wFlagsClass,
-                                                         "javaVersion",
-                                                         "Ljava/lang/String;");
+    JNU_CHECK_EXCEPTION(env);
 
     setHighDPIAware =
         (IS_WINVISTA && GetStaticBoolean(env, wFlagsClass, "setHighDPIAware"));
+    JNU_CHECK_EXCEPTION(env);
 
     J2dTraceLn(J2D_TRACE_INFO, "WindowsFlags (native):");
     J2dTraceLn1(J2D_TRACE_INFO, "  d3dEnabled = %s",
@@ -166,6 +172,7 @@
                                                      jclass wFlagsClass)
 {
     SetIDs(env, wFlagsClass);
+    JNU_CHECK_EXCEPTION(env);
     GetFlagValues(env, wFlagsClass);
 }
 
--- a/src/windows/native/sun/windows/awt_Canvas.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Canvas.cpp	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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,10 @@
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
     jobject target = NULL;
+    jobject graphicsConfig = NULL;
+    jclass canvasClass = NULL;
+    jclass win32cls = NULL;
+
     AwtCanvas *canvas = NULL;
 
     try {
@@ -100,16 +104,24 @@
         // Set the pixel format of the HWND if a GraphicsConfiguration
         // was provided to the Canvas constructor.
 
-        jclass canvasClass = env->FindClass("java/awt/Canvas");
+        canvasClass = env->FindClass("java/awt/Canvas");
+        DASSERT(canvasClass != NULL);
+        if (!canvasClass) {
+            throw std::bad_alloc();
+        }
+
         if ( env->IsInstanceOf( target, canvasClass ) ) {
 
             // Get GraphicsConfig from our target
-            jobject graphicsConfig = env->GetObjectField(target,
+            graphicsConfig = env->GetObjectField(target,
                 AwtComponent::graphicsConfigID);
             if (graphicsConfig != NULL) {
 
-                jclass win32cls = env->FindClass("sun/awt/Win32GraphicsConfig");
+                win32cls = env->FindClass("sun/awt/Win32GraphicsConfig");
                 DASSERT (win32cls != NULL);
+                if (!win32cls) {
+                    throw std::bad_alloc();
+                }
 
                 if ( env->IsInstanceOf( graphicsConfig, win32cls ) ) {
                     // Get the visual ID member from our GC
@@ -131,8 +143,7 @@
                             env->ExceptionClear();
                             env->ThrowNew(excCls,
                              "\nUnable to set Pixel format on Canvas");
-                            env->DeleteLocalRef(target);
-                            return canvas;
+                            env->DeleteLocalRef(excCls);
                         }
                     }
                 }
@@ -141,11 +152,20 @@
     }
     } catch (...) {
         env->DeleteLocalRef(target);
+        env->DeleteLocalRef(graphicsConfig);
+        env->DeleteLocalRef(canvasClass);
+        env->DeleteLocalRef(win32cls);
+
+        env->DeleteGlobalRef(self);
+        env->DeleteGlobalRef(hParent);
         throw;
     }
 
 done:
     env->DeleteLocalRef(target);
+    env->DeleteLocalRef(graphicsConfig);
+    env->DeleteLocalRef(canvasClass);
+    env->DeleteLocalRef(win32cls);
     return canvas;
     CATCH_BAD_ALLOC_RET(0);
 }
--- a/src/windows/native/sun/windows/awt_Choice.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Choice.cpp	Thu May 01 00:00:08 2014 -0700
@@ -157,6 +157,7 @@
                                                      "preferredSize",
                                                      "()Ljava/awt/Dimension;").l;
             DASSERT(!safe_ExceptionOccurred(env));
+            if (env->ExceptionCheck()) goto done;
 
             if (dimension != NULL && width == 0) {
                 width = env->GetIntField(dimension, AwtDimension::widthID);
@@ -337,9 +338,8 @@
                                              "preferredSize",
                                              "()Ljava/awt/Dimension;").l;
     DASSERT(!safe_ExceptionOccurred(env));
-    if (dimension == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(dimension, NULL);
+
     /* This size is window size of choice and it's too big for each
      * drop down item height.
      */
@@ -605,7 +605,8 @@
            for (i = 0; i < itemCount; i++)
            {
                jstring item = (jstring)env->GetObjectArrayElement(items, i);
-               JNI_CHECK_NULL_GOTO(item, "null item", next_elem);
+               if (env->ExceptionCheck()) goto done;
+               if (item == NULL) goto next_elem;
                c->SendMessage(CB_INSERTSTRING, index + i, JavaStringBuffer(env, item));
                env->DeleteLocalRef(item);
 next_elem:
--- a/src/windows/native/sun/windows/awt_Desktop.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Desktop.cpp	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -23,6 +23,7 @@
  * questions.
  */
 
+#include "jni_util.h"
 #include "awt.h"
 #include <jni.h>
 #include <shellapi.h>
@@ -41,7 +42,12 @@
   (JNIEnv *env, jclass cls, jstring fileOrUri_j, jstring verb_j)
 {
     LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, JNI_FALSE);
+    CHECK_NULL_RETURN(fileOrUri_c, NULL);
     LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE);
+    if (verb_c == NULL) {
+        JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
+        return NULL;
+    }
 
     // 6457572: ShellExecute possibly changes FPU control word - saving it here
     unsigned oldcontrol87 = _control87(0, 0);
--- a/src/windows/native/sun/windows/awt_Dialog.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Dialog.cpp	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -23,6 +23,7 @@
  * questions.
  */
 
+#include "jni_util.h"
 #include "awt_Toolkit.h"
 #include "awt_Dialog.h"
 #include "awt_Window.h"
@@ -457,18 +458,25 @@
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
-    jclass wwindowPeerCls = env->FindClass("sun/awt/windows/WWindowPeer");
-    jmethodID getActiveWindowsMID = env->GetStaticMethodID(wwindowPeerCls,
-                                                           "getActiveWindowHandles", "()[J");
-    DASSERT(getActiveWindowsMID != NULL);
-    jlongArray windows = (jlongArray)(env->CallStaticObjectMethod(wwindowPeerCls,
-                                                                  getActiveWindowsMID));
+    jboolean exc;
+    jlongArray windows = (jlongArray) JNU_CallStaticMethodByName
+                                            (env,
+                                             &exc,
+                                             "sun/awt/windows/WWindowPeer",
+                                             "getActiveWindowHandles",
+                                             "()[J").l;
+    if (exc == JNI_TRUE) {
+        throw std::bad_alloc();
+    }
     if (windows == NULL) {
         return;
     }
 
     jboolean isCopy;
     jlong *ws = env->GetLongArrayElements(windows, &isCopy);
+    if (ws == NULL) {
+        throw std::bad_alloc();
+    }
     int windowsCount = env->GetArrayLength(windows);
     for (int i = windowsCount - 1; i >= 0; i--) {
         HWND w = (HWND)ws[i];
@@ -744,11 +752,13 @@
     /* java.awt.Dialog fields and methods */
     AwtDialog::titleID
         = env->GetFieldID(cls, "title", "Ljava/lang/String;");
+    DASSERT(AwtDialog::titleID != NULL);
+    CHECK_NULL(AwtDialog::titleID);
+
     AwtDialog::undecoratedID
         = env->GetFieldID(cls,"undecorated","Z");
-
     DASSERT(AwtDialog::undecoratedID != NULL);
-    DASSERT(AwtDialog::titleID != NULL);
+    CHECK_NULL(AwtDialog::undecoratedID);
 
     CATCH_BAD_ALLOC;
 }
--- a/src/windows/native/sun/windows/awt_List.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_List.cpp	Thu May 01 00:00:08 2014 -0700
@@ -614,7 +614,8 @@
             {
                 LPTSTR itemPtr = NULL;
                 jstring item = (jstring)env->GetObjectArrayElement(items, i);
-                JNI_CHECK_NULL_GOTO(item, "null item", next_item);
+                if (env->ExceptionCheck()) goto ret;
+                if (item == NULL) goto next_item;
                 itemPtr = (LPTSTR)JNU_GetStringPlatformChars(env, item, 0);
                 if (itemPtr == NULL)
                 {
@@ -1017,8 +1018,8 @@
     ses->list = env->NewGlobalRef(self);
     ses->index = index;
 
-    return (jboolean)AwtToolkit::GetInstance().SyncCall(
-        (void *(*)(void *))AwtList::_IsSelected, ses);
+    return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall(
+                       (void *(*)(void *))AwtList::_IsSelected, ses));
     // global ref and ses are deleted in _IsSelected
 
     CATCH_BAD_ALLOC_RET(FALSE);
--- a/src/windows/native/sun/windows/awt_MenuBar.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_MenuBar.cpp	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -268,9 +268,11 @@
     TRY;
 
     AwtMenuBar::getMenuCountMID = env->GetMethodID(cls, "getMenuCountImpl", "()I");
+    DASSERT(AwtMenuBar::getMenuCountMID != NULL);
+    CHECK_NULL(AwtMenuBar::getMenuCountMID);
+
     AwtMenuBar::getMenuMID = env->GetMethodID(cls, "getMenuImpl",
                                               "(I)Ljava/awt/Menu;");
-    DASSERT(AwtMenuBar::getMenuCountMID != NULL);
     DASSERT(AwtMenuBar::getMenuMID != NULL);
 
     CATCH_BAD_ALLOC;
--- a/src/windows/native/sun/windows/awt_Robot.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Robot.cpp	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -35,6 +35,7 @@
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
     m_peerObject = env->NewWeakGlobalRef(peer);
+    JNU_CHECK_EXCEPTION(env);
     JNI_SET_PDATA(peer, this);
 }
 
--- a/src/windows/native/sun/windows/awt_Scrollbar.cpp	Wed Apr 30 11:16:49 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Scrollbar.cpp	Thu May 01 00:00:08 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -488,11 +488,14 @@
     TRY;
 
     AwtScrollbar::lineIncrementID = env->GetFieldID(cls, "lineIncrement", "I");
-    AwtScrollbar::pageIncrementID = env->GetFieldID(cls, "pageIncrement", "I");
-    AwtScrollbar::orientationID = env->GetFieldID(cls, "orientation", "I");
+    DASSERT(AwtScrollbar::lineIncrementID != NULL);
+    CHECK_NULL(AwtScrollbar::lineIncrementID);
 
-    DASSERT(AwtScrollbar::lineIncrementID != NULL);
+    AwtScrollbar::pageIncrementID = env->GetFieldID(cls, "pageIncrement", "I");
     DASSERT(AwtScrollbar::pageIncrementID != NULL);
+    CHECK_NULL(AwtScrollbar::pageIncrementID);
+
+    AwtScrollbar::orientationID = env->GetFieldID(cls, "orientation", "I");
     DASSERT(AwtScrollbar::orientationID != NULL);
 
     CATCH_BAD_ALLOC;
--- a/test/ProblemList.txt	Wed Apr 30 11:16:49 2014 -0700
+++ b/test/ProblemList.txt	Thu May 01 00:00:08 2014 -0700
@@ -1,6 +1,6 @@
 ###########################################################################
 #
-# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 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
@@ -120,9 +120,6 @@
 
 # jdk_lang
 
-# 8029415
-java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java generic-all
-
 ############################################################################
 
 # jdk_management
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/jarsigner/DefaultMethod.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8039358
+ * @summary com.sun.jarsigner.ContentSignerParameters.getTSAPolicyID() should be default
+ * @compile DefaultMethod.java
+ */
+
+import com.sun.jarsigner.ContentSignerParameters;
+
+import java.net.URI;
+import java.security.cert.X509Certificate;
+import java.util.zip.ZipFile;
+
+public class DefaultMethod implements ContentSignerParameters {
+
+    @Override
+    public String[] getCommandLine() {
+        return new String[0];
+    }
+
+    @Override
+    public URI getTimestampingAuthority() {
+        return null;
+    }
+
+    @Override
+    public X509Certificate getTimestampingAuthorityCertificate() {
+        return null;
+    }
+
+    @Override
+    public byte[] getSignature() {
+        return new byte[0];
+    }
+
+    @Override
+    public String getSignatureAlgorithm() {
+        return null;
+    }
+
+    @Override
+    public X509Certificate[] getSignerCertificateChain() {
+        return new X509Certificate[0];
+    }
+
+    @Override
+    public byte[] getContent() {
+        return new byte[0];
+    }
+
+    @Override
+    public ZipFile getSource() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test8040656.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,311 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.beans.Introspector;
+import java.beans.MethodDescriptor;
+
+/*
+ * @test
+ * @bug 8040656
+ * @summary Tests that a normal method is preferred to a synthetic one
+ * @author Sergey Malenkov
+ */
+
+public class Test8040656 {
+    public static void main(String[] args) throws Exception {
+        test(String.class, C.class);
+        test(String.class, C1.class);
+        test(String.class, C2.class);
+        test(String.class, C3.class);
+        test(String.class, C4.class);
+        test(String.class, C5.class);
+        test(String.class, C6.class);
+        test(String.class, C7.class);
+        test(String.class, C8.class);
+        test(String.class, C9.class);
+    }
+
+    private static void test(Class<?> type, Class<?> bean) throws Exception {
+        for (MethodDescriptor md : Introspector.getBeanInfo(bean).getMethodDescriptors()) {
+            if (md.getName().equals("getFoo")) {
+                if (type != md.getMethod().getReturnType()) {
+                    throw new Error("unexpected type");
+                }
+            }
+        }
+    }
+
+    public interface A {
+        public Object getFoo();
+    }
+
+    public class C implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+    }
+
+    public class C1 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+    }
+
+    public class C2 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+    }
+
+    public class C3 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+
+        public String getFoo3() {
+            return null;
+        }
+    }
+
+    public class C4 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+
+        public String getFoo3() {
+            return null;
+        }
+
+        public String getFoo4() {
+            return null;
+        }
+    }
+
+    public class C5 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+
+        public String getFoo3() {
+            return null;
+        }
+
+        public String getFoo4() {
+            return null;
+        }
+
+        public String getFoo5() {
+            return null;
+        }
+    }
+
+    public class C6 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+
+        public String getFoo3() {
+            return null;
+        }
+
+        public String getFoo4() {
+            return null;
+        }
+
+        public String getFoo5() {
+            return null;
+        }
+
+        public String getFoo6() {
+            return null;
+        }
+    }
+
+    public class C7 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+
+        public String getFoo3() {
+            return null;
+        }
+
+        public String getFoo4() {
+            return null;
+        }
+
+        public String getFoo5() {
+            return null;
+        }
+
+        public String getFoo6() {
+            return null;
+        }
+
+        public String getFoo7() {
+            return null;
+        }
+    }
+
+    public class C8 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+
+        public String getFoo3() {
+            return null;
+        }
+
+        public String getFoo4() {
+            return null;
+        }
+
+        public String getFoo5() {
+            return null;
+        }
+
+        public String getFoo6() {
+            return null;
+        }
+
+        public String getFoo7() {
+            return null;
+        }
+
+        public String getFoo8() {
+            return null;
+        }
+    }
+
+    public class C9 implements A {
+        @Override
+        public String getFoo() {
+            return null;
+        }
+
+        public String getFoo1() {
+            return null;
+        }
+
+        public String getFoo2() {
+            return null;
+        }
+
+        public String getFoo3() {
+            return null;
+        }
+
+        public String getFoo4() {
+            return null;
+        }
+
+        public String getFoo5() {
+            return null;
+        }
+
+        public String getFoo6() {
+            return null;
+        }
+
+        public String getFoo7() {
+            return null;
+        }
+
+        public String getFoo8() {
+            return null;
+        }
+
+        public String getFoo9() {
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/TestCacheRecursion.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import com.sun.beans.util.Cache;
+
+/*
+ * @test
+ * @bug 8039137
+ * @summary Tests Cache recursion
+ * @author Sergey Malenkov
+ * @compile -XDignore.symbol.file TestCacheRecursion.java
+ * @run main TestCacheRecursion
+ */
+
+public class TestCacheRecursion {
+    private static boolean ERROR;
+    private static final Cache<Class<?>,Boolean> CACHE
+            = new Cache<Class<?>,Boolean>(Cache.Kind.WEAK, Cache.Kind.STRONG) {
+        @Override
+        public Boolean create(Class<?> type) {
+            if (ERROR) {
+                throw new Error("not initialized");
+            }
+            type = type.getSuperclass();
+            return (type != null) && get(type);
+        }
+    };
+
+    public static void main(String[] args) {
+        CACHE.get(Z.class);
+        ERROR = true;
+        for (Class<?> type = Z.class; type != null; type = type.getSuperclass()) {
+            CACHE.get(type);
+        }
+    }
+
+    private class A {}
+    private class B extends A {}
+    private class C extends B {}
+    private class D extends C {}
+    private class E extends D {}
+    private class F extends E {}
+    private class G extends F {}
+    private class H extends G {}
+    private class I extends H {}
+    private class J extends I {}
+    private class K extends J {}
+    private class L extends K {}
+    private class M extends L {}
+    private class N extends M {}
+    private class O extends N {}
+    private class P extends O {}
+    private class Q extends P {}
+    private class R extends Q {}
+    private class S extends R {}
+    private class T extends S {}
+    private class U extends T {}
+    private class V extends U {}
+    private class W extends V {}
+    private class X extends W {}
+    private class Y extends X {}
+    private class Z extends Y {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/io/Serializable/unresolvableObjectStreamClass/UnresolvableObjectStreamClass.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 8039396
+ * @run main UnresolvableObjectStreamClass serialize
+ * @clean MySerializable
+ * @run main UnresolvableObjectStreamClass deserialize
+ *
+ * @summary NPE when writing a class descriptor object to a custom
+ *          ObjectOutputStream
+ */
+
+import java.io.*;
+
+public class UnresolvableObjectStreamClass {
+    public static void main(String[] args) throws Throwable {
+        if (args.length > 0 && args[0].equals("serialize")) {
+            try (FileOutputStream fos = new FileOutputStream("temp1.ser");
+                 ObjectOutputStream oos = new ObjectOutputStream(fos)) {
+                ObjectStreamClass osc =
+                         ObjectStreamClass.lookup(MySerializable.class);
+                oos.writeObject(osc);
+            }
+        } else if (args.length > 0 && args[0].equals("deserialize")) {
+            try (FileInputStream fis = new FileInputStream("temp1.ser");
+                 ObjectInputStream ois = new ObjectInputStream(fis);
+                 FileOutputStream fos = new FileOutputStream("temp2.ser");
+                 ObjectOutputStream oos = new ObjectOutputStream(fos) {
+                         /*must be subclassed*/}) {
+                ObjectStreamClass osc = (ObjectStreamClass)ois.readObject();
+                // serialize it again
+                try {
+                    oos.writeObject(osc);
+                } catch (NullPointerException e) {
+                    throw new RuntimeException("Failed to write" +
+                            " unresolvable ObjectStreamClass", e);
+                }
+            }
+        } else {
+            throw new RuntimeException("The command line option must be" +
+                                       " one of: serialize or deserialize");
+        }
+    }
+}
+
+class MySerializable implements Serializable {
+}
--- a/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java	Wed Apr 30 11:16:49 2014 -0700
+++ b/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java	Thu May 01 00:00:08 2014 -0700
@@ -90,9 +90,6 @@
 import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
 import static java.time.temporal.ChronoField.YEAR;
 import static java.time.temporal.ChronoField.YEAR_OF_ERA;
-import static java.time.temporal.ChronoUnit.DAYS;
-import static java.time.temporal.ChronoUnit.FOREVER;
-import static java.time.temporal.ChronoUnit.NANOS;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.fail;
 
@@ -102,13 +99,17 @@
 import java.time.Period;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
-import java.time.chrono.Chronology;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.ChronoLocalDateTime;
+import java.time.chrono.ChronoZonedDateTime;
+import java.time.chrono.IsoChronology;
+import java.time.chrono.MinguoChronology;
+import java.time.chrono.MinguoDate;
 import java.time.chrono.ThaiBuddhistChronology;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
 import java.time.format.DateTimeParseException;
 import java.time.format.ResolverStyle;
-import java.time.temporal.ChronoUnit;
 import java.time.temporal.IsoFields;
 import java.time.temporal.Temporal;
 import java.time.temporal.TemporalAccessor;
@@ -129,6 +130,9 @@
     // TODO: tests with weird TenporalField implementations
     // TODO: tests with non-ISO chronologies
 
+    private static final ZoneId EUROPE_ATHENS = ZoneId.of("Europe/Athens");
+    private static final ZoneId EUROPE_PARIS = ZoneId.of("Europe/Paris");
+
     //-----------------------------------------------------------------------
     @DataProvider(name="resolveOneNoChange")
     Object[][] data_resolveOneNoChange() {
@@ -886,205 +890,273 @@
     }
 
     //-----------------------------------------------------------------------
+    // SPEC: DateTimeFormatter.withChronology()
     @Test
-    public void test_fieldResolvesToLocalTime() {
-        TemporalField field = new TemporalField() {
-            @Override
-            public TemporalUnit getBaseUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalUnit getRangeUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange range() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isDateBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isTimeBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isSupportedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public long getFrom(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public <R extends Temporal> R adjustInto(R temporal, long newValue) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalAccessor resolve(
-                    Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
-                return LocalTime.MIDNIGHT.plusNanos(fieldValues.remove(this));
-            }
-        };
-        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter();
-        TemporalAccessor accessor = f.parse("1234567890");
-        assertEquals(accessor.query(TemporalQueries.localDate()), null);
-        assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(0, 0, 1, 234_567_890));
+    public void test_withChronology_noOverride() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+        TemporalAccessor accessor = f.parse("");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+    }
+
+    @Test
+    public void test_withChronology_override() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        TemporalAccessor accessor = f.parse("");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
+    }
+
+    @Test
+    public void test_withChronology_parsedChronology_noOverride() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendChronologyId().toFormatter();
+        TemporalAccessor accessor = f.parse("ThaiBuddhist");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.chronology()), ThaiBuddhistChronology.INSTANCE);
+    }
+
+    @Test
+    public void test_withChronology_parsedChronology_override() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendChronologyId().toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        TemporalAccessor accessor = f.parse("ThaiBuddhist");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.chronology()), ThaiBuddhistChronology.INSTANCE);
+    }
+
+    //-----------------------------------------------------------------------
+    // SPEC: DateTimeFormatter.withZone()
+    @Test
+    public void test_withZone_noOverride() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+        TemporalAccessor accessor = f.parse("");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.zoneId()), null);
     }
 
     @Test
-    public void test_fieldResolvesToChronoLocalDateTime() {
-        TemporalField field = new TemporalField() {
-            @Override
-            public TemporalUnit getBaseUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalUnit getRangeUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange range() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isDateBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isTimeBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isSupportedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public long getFrom(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public <R extends Temporal> R adjustInto(R temporal, long newValue) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalAccessor resolve(
-                    Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
-                fieldValues.remove(this);
-                return LocalDateTime.of(2010, 6, 30, 12, 30);
-            }
-        };
-        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter();
+    public void test_withZone_override() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+        f = f.withZone(EUROPE_ATHENS);
+        TemporalAccessor accessor = f.parse("");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_ATHENS);
+    }
+
+    @Test
+    public void test_withZone_parsedZone_noOverride() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendZoneId().toFormatter();
+        TemporalAccessor accessor = f.parse("Europe/Paris");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+    }
+
+    @Test
+    public void test_withZone_parsedZone_override() {
+        DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendZoneId().toFormatter();
+        f = f.withZone(EUROPE_ATHENS);
+        TemporalAccessor accessor = f.parse("Europe/Paris");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+    }
+
+    //-----------------------------------------------------------------------
+    @Test
+    public void test_fieldResolvesToLocalTime() {
+        LocalTime lt = LocalTime.of(12, 30, 40);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(lt)).toFormatter();
+        TemporalAccessor accessor = f.parse("1234567890");
+        assertEquals(accessor.query(TemporalQueries.localDate()), null);
+        assertEquals(accessor.query(TemporalQueries.localTime()), lt);
+    }
+
+    //-------------------------------------------------------------------------
+    @Test
+    public void test_fieldResolvesToChronoLocalDate_noOverrideChrono_matches() {
+        LocalDate ldt = LocalDate.of(2010, 6, 30);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(ldt)).toFormatter();
         TemporalAccessor accessor = f.parse("1234567890");
         assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
-        assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+    }
+
+    @Test
+    public void test_fieldResolvesToChronoLocalDate_overrideChrono_matches() {
+        MinguoDate mdt = MinguoDate.of(100, 6, 30);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt)).toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        TemporalAccessor accessor = f.parse("1234567890");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
+        assertEquals(accessor.query(TemporalQueries.localTime()), null);
+        assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
     }
 
     @Test(expectedExceptions = DateTimeParseException.class)
-    public void test_fieldResolvesWrongChrono() {
-        TemporalField field = new TemporalField() {
-            @Override
-            public TemporalUnit getBaseUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalUnit getRangeUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange range() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isDateBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isTimeBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isSupportedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public long getFrom(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public <R extends Temporal> R adjustInto(R temporal, long newValue) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalAccessor resolve(
-                    Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
-                return ThaiBuddhistChronology.INSTANCE.dateNow();
-            }
-        };
-        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter();
+    public void test_fieldResolvesToChronoLocalDate_noOverrideChrono_wrongChrono() {
+        ChronoLocalDate cld = ThaiBuddhistChronology.INSTANCE.dateNow();
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cld)).toFormatter();
         f.parse("1234567890");
     }
 
     @Test(expectedExceptions = DateTimeParseException.class)
-    public void test_fieldResolvesWrongZone() {
-        TemporalField field = new TemporalField() {
-            @Override
-            public TemporalUnit getBaseUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalUnit getRangeUnit() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange range() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isDateBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isTimeBased() {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public boolean isSupportedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public long getFrom(TemporalAccessor temporal) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public <R extends Temporal> R adjustInto(R temporal, long newValue) {
-                throw new UnsupportedOperationException();
-            }
-            @Override
-            public TemporalAccessor resolve(
-                    Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
-                return ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, ZoneId.of("Europe/Paris"));
-            }
-        };
-        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter().withZone(ZoneId.of("Europe/London"));
+    public void test_fieldResolvesToChronoLocalDate_overrideChrono_wrongChrono() {
+        ChronoLocalDate cld = ThaiBuddhistChronology.INSTANCE.dateNow();
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cld)).toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        f.parse("1234567890");
+    }
+
+    //-------------------------------------------------------------------------
+    @Test
+    public void test_fieldResolvesToChronoLocalDateTime_noOverrideChrono_matches() {
+        LocalDateTime ldt = LocalDateTime.of(2010, 6, 30, 12, 30);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(ldt)).toFormatter();
+        TemporalAccessor accessor = f.parse("1234567890");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
+        assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
+        assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+    }
+
+    @Test
+    public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_matches() {
+        MinguoDate mdt = MinguoDate.of(100, 6, 30);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt.atTime(LocalTime.NOON))).toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        TemporalAccessor accessor = f.parse("1234567890");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
+        assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.NOON);
+        assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
+    }
+
+    @Test(expectedExceptions = DateTimeParseException.class)
+    public void test_fieldResolvesToChronoLocalDateTime_noOverrideChrono_wrongChrono() {
+        ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
+        f.parse("1234567890");
+    }
+
+    @Test(expectedExceptions = DateTimeParseException.class)
+    public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_wrongChrono() {
+        ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        f.parse("1234567890");
+    }
+
+    //-------------------------------------------------------------------------
+    @Test
+    public void test_fieldResolvesToChronoZonedDateTime_noOverrideChrono_matches() {
+        ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
+        TemporalAccessor accessor = f.parse("1234567890");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
+        assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
+        assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+        assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+    }
+
+    @Test
+    public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_matches() {
+        MinguoDate mdt = MinguoDate.of(100, 6, 30);
+        ChronoZonedDateTime<MinguoDate> mzdt = mdt.atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mzdt)).toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        TemporalAccessor accessor = f.parse("1234567890");
+        assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
+        assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.NOON);
+        assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
+        assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+    }
+
+    @Test(expectedExceptions = DateTimeParseException.class)
+    public void test_fieldResolvesToChronoZonedDateTime_noOverrideChrono_wrongChrono() {
+        ChronoZonedDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
         f.parse("1234567890");
     }
 
+    @Test(expectedExceptions = DateTimeParseException.class)
+    public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_wrongChrono() {
+        ChronoZonedDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
+        f = f.withChronology(MinguoChronology.INSTANCE);
+        f.parse("1234567890");
+    }
+
+    @Test
+    public void test_fieldResolvesToChronoZonedDateTime_overrideZone_matches() {
+        ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
+        f = f.withZone(EUROPE_PARIS);
+        assertEquals(f.parse("1234567890", ZonedDateTime::from), zdt);
+    }
+
+    @Test(expectedExceptions = DateTimeParseException.class)
+    public void test_fieldResolvesToChronoZonedDateTime_overrideZone_wrongZone() {
+        ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
+        DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
+        f = f.withZone(ZoneId.of("Europe/London"));
+        f.parse("1234567890");
+    }
+
+    //-------------------------------------------------------------------------
+    private static class ResolvingField implements TemporalField {
+        private final TemporalAccessor resolvedValue;
+        ResolvingField(TemporalAccessor resolvedValue) {
+            this.resolvedValue = resolvedValue;
+        }
+        @Override
+        public TemporalUnit getBaseUnit() {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public TemporalUnit getRangeUnit() {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public ValueRange range() {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public boolean isDateBased() {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public boolean isTimeBased() {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public boolean isSupportedBy(TemporalAccessor temporal) {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public long getFrom(TemporalAccessor temporal) {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public <R extends Temporal> R adjustInto(R temporal, long newValue) {
+            throw new UnsupportedOperationException();
+        }
+        @Override
+        public TemporalAccessor resolve(
+                Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
+            fieldValues.remove(this);
+            return resolvedValue;
+        }
+    };
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/concurrent/CopyOnWriteArrayList/COWSubList.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8011645
+ * @summary CopyOnWriteArrayList.COWSubList.subList does not validate range properly
+ */
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+public class COWSubList {
+    public static void main(String[] args) {
+        List<String> list = new CopyOnWriteArrayList<>();
+        list.add("A");
+        list.add("B");
+        list.add("C");
+        list.add("D");
+        list.add("E");
+
+        expectThrow(() -> list.subList(-1, 5));
+        expectThrow(() -> list.subList(0, 6));
+        expectThrow(() -> list.subList(4, 3));
+        expectThrow(() -> list.subList(0, 5).subList(-1, 5));
+        expectThrow(() -> list.subList(0, 5).subList(0, 6));
+        expectThrow(() -> list.subList(0, 5).subList(4, 3));
+    }
+
+    static void expectThrow(Runnable r) {
+        try {
+            r.run();
+            throw new RuntimeException("Failed: expected IOOBE to be thrown");
+        } catch (IndexOutOfBoundsException x) {
+            // ok, excpeted
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/zip/ZipFile/MultiThreadedReadTest.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 8038491
+ * @summary Crash in ZipFile.read() when ZipFileInputStream is shared between threads
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.FileUtils
+ * @run main MultiThreadedReadTest
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.nio.file.Paths;
+import java.util.Random;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+import jdk.testlibrary.FileUtils;
+
+public class MultiThreadedReadTest extends Thread {
+
+    private static final int NUM_THREADS = 10;
+    private static final String ZIPFILE_NAME = "large.zip";
+    private static final String ZIPENTRY_NAME = "random.txt";
+    private static InputStream is = null;
+
+    public static void main(String args[]) throws Exception {
+        createZipFile();
+        try (ZipFile zf = new ZipFile(new File(ZIPFILE_NAME))) {
+            is = zf.getInputStream(zf.getEntry(ZIPENTRY_NAME));
+            Thread[] threadArray = new Thread[NUM_THREADS];
+            for (int i = 0; i < threadArray.length; i++) {
+                threadArray[i] = new MultiThreadedReadTest();
+            }
+            for (int i = 0; i < threadArray.length; i++) {
+                threadArray[i].start();
+            }
+            for (int i = 0; i < threadArray.length; i++) {
+                threadArray[i].join();
+            }
+        } finally {
+            FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME));
+        }
+    }
+
+    private static void createZipFile() throws Exception {
+        try (ZipOutputStream zos =
+            new ZipOutputStream(new FileOutputStream(ZIPFILE_NAME))) {
+
+            zos.putNextEntry(new ZipEntry(ZIPENTRY_NAME));
+            StringBuilder sb = new StringBuilder();
+            Random rnd = new Random();
+            for(int i = 0; i < 1000; i++) {
+                // append some random string for ZipEntry
+                sb.append(Long.toString(rnd.nextLong()));
+            }
+            byte[] b = sb.toString().getBytes();
+            zos.write(b, 0, b.length);
+        }
+    }
+
+    @Override
+    public void run() {
+        try {
+            while (is.read() != -1) { }
+        } catch (Exception e) {
+            // Swallow any Exceptions (which are expected) - we're only interested in the crash
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JScrollBar/8039464/Test8039464.html	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,32 @@
+<!--
+ 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.
+
+ 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.
+-->
+
+<html>
+<body>
+Choose the variable applet size and try to resize the applet.
+The test passes the thumb is painted correctly.
+
+<applet width="400" height="200" code="Test8039464">
+</applet>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JScrollBar/8039464/Test8039464.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+
+import javax.swing.JApplet;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JScrollBar;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+
+/*
+ * @test
+ * @bug 8039464
+ * @summary Tests enabling/disabling of titled border's caption
+ * @author Sergey Malenkov
+ * @run applet/manual=yesno Test8039464.html
+ */
+
+public class Test8039464 extends JApplet {
+    static {
+        try {
+            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+        } catch (Exception exception) {
+            throw new Error("unexpected", exception);
+        }
+    }
+
+    @Override
+    public void init() {
+        init(this);
+    }
+
+    private static void init(Container container) {
+        container.setLayout(new GridBagLayout());
+        GridBagConstraints gbc = new GridBagConstraints();
+        gbc.fill = GridBagConstraints.BOTH;
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        JLabel label = new JLabel();
+        Dimension size = new Dimension(111, 0);
+        label.setPreferredSize(size);
+        label.setMinimumSize(size);
+        container.add(label, gbc);
+        gbc.gridx = 1;
+        gbc.weightx = 1;
+        container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
+        gbc.gridx = 2;
+        gbc.gridy = 0;
+        gbc.weightx = 0;
+        gbc.weighty = 1;
+        container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
+    }
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                JFrame frame = new JFrame("8039464");
+                init(frame);
+                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+                frame.pack();
+                frame.setLocationRelativeTo(null);
+                frame.setVisible(true);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTable/8031971/bug8031971.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+import java.util.Date;
+import java.util.Hashtable;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @bug 8031971 8039750
+ * @author Alexander Scherbatiy
+ * @summary Use only public methods in the SwingLazyValue
+ * @run main bug8031971
+ */
+public class bug8031971 {
+
+    static Object[][] RENDERERS = {
+        {Object.class, "javax.swing.table.DefaultTableCellRenderer$UIResource"},
+        {Number.class, "javax.swing.JTable$NumberRenderer"},
+        {Float.class, "javax.swing.JTable$DoubleRenderer"},
+        {Double.class, "javax.swing.JTable$DoubleRenderer"},
+        {Date.class, "javax.swing.JTable$DateRenderer"},
+        {Icon.class, "javax.swing.JTable$IconRenderer"},
+        {ImageIcon.class, "javax.swing.JTable$IconRenderer"},
+        {Boolean.class, "javax.swing.JTable$BooleanRenderer"}
+    };
+
+    static Object[][] EDITORS = {
+        {Object.class, "javax.swing.JTable$GenericEditor"},
+        {Number.class, "javax.swing.JTable$NumberEditor"},
+        {Boolean.class, "javax.swing.JTable$BooleanEditor"}
+    };
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(() -> {
+
+            TestTable table = new TestTable();
+            test(table.getDefaultRenderersByColumnClass(), RENDERERS);
+            test(table.getDefaultEditorsByColumnClass(), EDITORS);
+        });
+    }
+
+    static void test(Hashtable table, Object[][] values) {
+        for (int i = 0; i < values.length; i++) {
+            test(table.get(values[i][0]), (String) values[i][1]);
+        }
+    }
+
+    static void test(Object obj, String className) {
+        if (!obj.getClass().getCanonicalName().equals(className.replace('$', '.'))) {
+            throw new RuntimeException("Wrong value!");
+        }
+    }
+
+    static class TestTable extends JTable {
+
+        Hashtable getDefaultRenderersByColumnClass() {
+            return defaultRenderersByColumnClass;
+        }
+
+        Hashtable getDefaultEditorsByColumnClass() {
+            return defaultEditorsByColumnClass;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/plaf/metal/MetalLookAndFeel/Test8039750.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import javax.swing.UIDefaults;
+import javax.swing.border.CompoundBorder;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/*
+ * @test
+ * @bug 8039750
+ * @summary Tests MetalLazyValue removing
+ * @author Sergey Malenkov
+ */
+public class Test8039750 {
+    public static void main(String[] args) {
+        UIDefaults table= new MetalLookAndFeel().getDefaults();
+        test(table.get("ToolBar.rolloverBorder"),
+                "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
+                "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
+        test(table.get("ToolBar.nonrolloverBorder"),
+                "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
+                "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
+        test(table.get("RootPane.frameBorder"),
+                "javax.swing.plaf.metal.MetalBorders$FrameBorder");
+        test(table.get("RootPane.plainDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$DialogBorder");
+        test(table.get("RootPane.informationDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$DialogBorder");
+        test(table.get("RootPane.errorDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
+        test(table.get("RootPane.colorChooserDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        test(table.get("RootPane.fileChooserDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        test(table.get("RootPane.questionDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        test(table.get("RootPane.warningDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
+    }
+
+    private static void test(Object value, String name) {
+        if (!value.getClass().getName().equals(name)) {
+            throw new Error(name);
+        }
+    }
+
+    private static void test(Object value, String one, String two) {
+        if (value instanceof CompoundBorder) {
+            CompoundBorder border = (CompoundBorder) value;
+            test(border.getOutsideBorder(), one);
+            test(border.getInsideBorder(), two);
+        } else {
+            throw new Error("CompoundBorder");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/awt/dnd/8024061/bug8024061.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,357 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 8024061
+ * @summary Checks that no exception is thrown if dragGestureRecognized
+ *          takes a while to complete.
+ */
+import sun.awt.OSInfo;
+import sun.awt.OSInfo.OSType;
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.event.InputEvent;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.swing.*;
+
+/**
+ * If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
+ * an exception is thrown from DropTargetListener.dragEnter when it calls
+ * DropTargetDragEvent.getTransferable().
+ * <p>
+ * This class introduces a delay in dragGestureRecognized() to cause the exception.
+ */
+public class bug8024061 {
+    private static final DataFlavor DropObjectFlavor;
+    private static final int DELAY = 1000;
+
+    private final DnDPanel panel1 = new DnDPanel(Color.yellow);
+    private final DnDPanel panel2 = new DnDPanel(Color.pink);
+    private final JFrame frame;
+
+    private static final CountDownLatch lock = new CountDownLatch(1);
+    private static volatile Exception dragEnterException = null;
+
+    static {
+        DataFlavor flavor = null;
+        try {
+            flavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+        }
+        DropObjectFlavor = flavor;
+    }
+
+    bug8024061() {
+        frame = new JFrame("DnDWithRobot");
+        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+        Dimension d = new Dimension(100, 100);
+
+        panel1.setPreferredSize(d);
+        panel2.setPreferredSize(d);
+
+        Container content = frame.getContentPane();
+        content.setLayout(new GridLayout(1, 2, 5, 5));
+        content.add(panel1);
+        content.add(panel2);
+
+        frame.pack();
+
+        DropObject drop = new DropObject();
+        drop.place(panel1, new Point(10, 10));
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
+        OSType type = OSInfo.getOSType();
+        if (type != OSType.LINUX && type != OSType.SOLARIS) {
+            System.out.println("This test is for Linux and Solaris only... " +
+                               "skipping!");
+            return;
+        }
+
+        final bug8024061[] dnd = {null};
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                dnd[0] = new bug8024061();
+            }
+        });
+        final Robot robot = new Robot();
+        robot.setAutoDelay(10);
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        toolkit.realSync();
+
+        JFrame frame = dnd[0].frame;
+        Point point = frame.getLocationOnScreen();
+        Point here = new Point(point.x + 35, point.y + 45);
+        Point there = new Point(point.x + 120, point.y + 45);
+        here.x += 25;
+        robot.mouseMove(here.x, here.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        while (here.x < there.x) {
+            here.x += 20;
+            robot.mouseMove(here.x, here.y);
+            System.out.println("x = " + here.x);
+        }
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        toolkit.realSync();
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        System.out.println("finished");
+
+        try {
+            if (lock.await(5, TimeUnit.SECONDS)) {
+                if (dragEnterException == null) {
+                    System.out.println("Test passed.");
+                } else {
+                    System.out.println("Test failed.");
+                    dragEnterException.printStackTrace();
+                    throw new RuntimeException(dragEnterException);
+                }
+            } else {
+                System.out.println("Test failed. Timeout reached");
+                throw new RuntimeException("Timed out waiting for dragEnter()");
+            }
+        } finally {
+            frame.dispose();
+        }
+    }
+
+    class DropObject implements Transferable {
+        DnDPanel panel;
+        Color color = Color.CYAN;
+        int width = 50;
+        int height = 50;
+        int x;
+        int y;
+
+        void draw(Graphics2D g) {
+            Color savedColor = g.getColor();
+            g.setColor(color);
+            g.fillRect(x, y, width, height);
+            g.setColor(Color.lightGray);
+            g.drawRect(x, y, width, height);
+            g.setColor(savedColor);
+        }
+
+        boolean contains(int x, int y) {
+            return (x > this.x && x < this.x + width)
+                    && (y > this.y && y < this.y + height);
+        }
+
+        @Override
+        public DataFlavor[] getTransferDataFlavors() {
+            return new DataFlavor[]{DropObjectFlavor};
+        }
+
+        void place(DnDPanel panel, Point location) {
+            if (panel != this.panel) {
+                x = location.x;
+                y = location.y;
+                if (this.panel != null) {
+                    this.panel.setDropObject(null);
+                    this.panel.repaint();
+                }
+                this.panel = panel;
+                this.panel.setDropObject(this);
+                this.panel.repaint();
+            }
+        }
+
+        @Override
+        public boolean isDataFlavorSupported(DataFlavor flavor) {
+            return DropObjectFlavor.equals(flavor);
+        }
+
+        @Override
+        public Object getTransferData(DataFlavor flavor)
+                throws UnsupportedFlavorException, IOException {
+            if (isDataFlavorSupported(flavor)) {
+                return this;
+            } else {
+                throw new UnsupportedFlavorException(flavor);
+            }
+        }
+    }
+
+    class DnDPanel extends JPanel {
+        DropObject dropObject;
+        final DragSource dragSource;
+        final DropTarget dropTarget;
+        final Color color;
+        final DragGestureListener dgListener;
+        final DragSourceListener dsListener;
+        final DropTargetListener dtListener;
+
+        DnDPanel(Color color) {
+            this.color = color;
+            this.dragSource = DragSource.getDefaultDragSource();
+            dgListener = new DragGestureListener() {
+                @Override
+                public void dragGestureRecognized(DragGestureEvent dge) {
+                    Point location = dge.getDragOrigin();
+                    if (dropObject != null && dropObject.contains(location.x, location.y)) {
+                        dragSource.startDrag(dge, DragSource.DefaultCopyNoDrop, dropObject, dsListener);
+                        try {
+                            Thread.sleep(DELAY);
+                        } catch (InterruptedException e) {
+                        }
+                    }
+                }
+            };
+
+            dsListener = new DragSourceListener() {
+                @Override
+                public void dragEnter(DragSourceDragEvent dsde) {
+                }
+
+                @Override
+                public void dragOver(DragSourceDragEvent dsde) {
+                }
+
+                @Override
+                public void dropActionChanged(DragSourceDragEvent dsde) {
+                }
+
+                @Override
+                public void dragExit(DragSourceEvent dse) {
+                }
+
+                @Override
+                public void dragDropEnd(DragSourceDropEvent dsde) {
+                }
+            };
+
+            dtListener = new DropTargetListener() {
+                @Override
+                public void dragEnter(DropTargetDragEvent dtde) {
+                    if (dropObject != null) {
+                        dtde.rejectDrag();
+                        return;
+                    }
+                    dtde.acceptDrag(DnDConstants.ACTION_MOVE);
+                    try {
+                        Transferable t = dtde.getTransferable();
+                        Object data = t.getTransferData(DropObjectFlavor);
+                        if (data != null) {
+                            throw new Exception("getTransferData returned non-null");
+                        }
+                    } catch (Exception e) {
+                        dragEnterException = e;
+                        e.printStackTrace();
+                    } finally {
+                        lock.countDown();
+                    }
+                }
+
+                @Override
+                public void dragOver(DropTargetDragEvent dtde) {
+                    if (dropObject != null) {
+                        dtde.rejectDrag();
+                        return;
+                    }
+                    dtde.acceptDrag(DnDConstants.ACTION_MOVE);
+                }
+
+                @Override
+                public void dropActionChanged(DropTargetDragEvent dtde) {
+                }
+
+                @Override
+                public void dragExit(DropTargetEvent dte) {
+                }
+
+                @Override
+                public void drop(DropTargetDropEvent dtde) {
+                    if (dropObject != null) {
+                        dtde.rejectDrop();
+                        return;
+                    }
+                    try {
+                        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
+                        Transferable t = dtde.getTransferable();
+                        DropObject dropObject = (DropObject) t.getTransferData(DropObjectFlavor);
+                        Point location = dtde.getLocation();
+                        dropObject.place(DnDPanel.this, location);
+                        dtde.dropComplete(true);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+
+                }
+            };
+
+            dragSource.createDefaultDragGestureRecognizer(this,
+                    DnDConstants.ACTION_MOVE, dgListener);
+
+            dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, dtListener, true);
+
+        }
+
+        public void paintComponent(Graphics g) {
+            super.paintComponent(g);
+            Color savedColor = g.getColor();
+            g.setColor(color);
+            g.fillRect(0, 0, getWidth(), getHeight());
+            g.setColor(savedColor);
+            if (dropObject != null) {
+                dropObject.draw((Graphics2D) g);
+            }
+        }
+
+        void setDropObject(DropObject dropObject) {
+            this.dropObject = dropObject;
+        }
+
+        DropObject findDropObject(int x, int y) {
+            if (dropObject != null && dropObject.contains(x, y)) {
+                return dropObject;
+            }
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/net/www/http/HttpClient/B8025710.java	Thu May 01 00:00:08 2014 -0700
@@ -0,0 +1,409 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.io.*;
+import java.net.*;
+import java.security.*;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+import javax.net.ssl.*;
+
+/**
+ * @test
+ * @bug 8025710
+ * @summary Proxied https connection reuse by HttpClient can send CONNECT to the server
+ */
+public class B8025710 {
+
+    private final static AtomicBoolean connectInServer = new AtomicBoolean();
+    private static final String keystorefile =
+            System.getProperty("test.src", "./")
+            + "/../../../../../sun/security/ssl/etc/keystore";
+    private static final String passphrase = "passphrase";
+
+    public static void main(String[] args) throws Exception {
+        new B8025710().runTest();
+
+        if (connectInServer.get())
+            throw new RuntimeException("TEST FAILED: server got proxy header");
+        else
+            System.out.println("TEST PASSED");
+    }
+
+    private void runTest() throws Exception {
+        ProxyServer proxyServer = new ProxyServer();
+        HttpServer httpServer = new HttpServer();
+        httpServer.start();
+        proxyServer.start();
+
+        URL url = new URL("https", InetAddress.getLocalHost().getHostName(),
+                httpServer.getPort(), "/");
+
+        Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyServer.getAddress());
+
+        HttpsURLConnection.setDefaultSSLSocketFactory(createTestSSLSocketFactory());
+
+        // Make two connections. The bug occurs when the second request is made
+        for (int i = 0; i < 2; i++) {
+            System.out.println("Client: Requesting " + url.toExternalForm()
+                    + " via " + proxy.toString()
+                    + " (attempt " + (i + 1) + " of 2)");
+
+            HttpsURLConnection connection =
+                    (HttpsURLConnection) url.openConnection(proxy);
+
+            connection.setRequestMethod("POST");
+            connection.setDoInput(true);
+            connection.setDoOutput(true);
+            connection.setRequestProperty("User-Agent", "Test/1.0");
+            connection.getOutputStream().write("Hello, world!".getBytes("UTF-8"));
+
+            if (connection.getResponseCode() != 200) {
+                System.err.println("Client: Unexpected response code "
+                        + connection.getResponseCode());
+                break;
+            }
+
+            String response = readLine(connection.getInputStream());
+            if (!"Hi!".equals(response)) {
+                System.err.println("Client: Unexpected response body: "
+                        + response);
+            }
+        }
+        httpServer.close();
+        proxyServer.close();
+        httpServer.join();
+        proxyServer.join();
+    }
+
+    class ProxyServer extends Thread implements Closeable {
+
+        private final ServerSocket proxySocket;
+        private final Pattern connectLinePattern =
+                Pattern.compile("^CONNECT ([^: ]+):([0-9]+) HTTP/[0-9.]+$");
+        private final String PROXY_RESPONSE =
+                "HTTP/1.0 200 Connection Established\r\n"
+                + "Proxy-Agent: TestProxy/1.0\r\n"
+                + "\r\n";
+
+        ProxyServer() throws Exception {
+            super("ProxyServer Thread");
+
+            // Create the http proxy server socket
+            proxySocket = ServerSocketFactory.getDefault().createServerSocket();
+            proxySocket.bind(new InetSocketAddress(InetAddress.getLocalHost(), 0));
+        }
+
+        public SocketAddress getAddress() { return  proxySocket.getLocalSocketAddress(); }
+
+        @Override
+        public void close() throws IOException {
+            proxySocket.close();
+        }
+
+        @Override
+        public void run() {
+            ArrayList<Thread> threads = new ArrayList<>();
+            int connectionCount = 0;
+            try {
+                while (connectionCount++ < 2) {
+                    final Socket clientSocket = proxySocket.accept();
+                    final int proxyConnectionCount = connectionCount;
+                    System.out.println("Proxy: NEW CONNECTION "
+                            + proxyConnectionCount);
+
+                    Thread t = new Thread("ProxySocket" + proxyConnectionCount) {
+                        @Override
+                        public void run() {
+                            try {
+                                String firstLine =
+                                        readHeader(clientSocket.getInputStream());
+
+                                Matcher connectLineMatcher =
+                                        connectLinePattern.matcher(firstLine);
+                                if (!connectLineMatcher.matches()) {
+                                    System.out.println("Proxy: Unexpected"
+                                            + " request to the proxy: "
+                                            + firstLine);
+                                    return;
+                                }
+
+                                String host    = connectLineMatcher.group(1);
+                                String portStr = connectLineMatcher.group(2);
+                                int port       = Integer.parseInt(portStr);
+
+                                Socket serverSocket = SocketFactory.getDefault()
+                                        .createSocket(host, port);
+
+                                clientSocket.getOutputStream()
+                                        .write(PROXY_RESPONSE.getBytes("UTF-8"));
+
+                                ProxyTunnel copyToClient =
+                                        new ProxyTunnel(serverSocket, clientSocket);
+                                ProxyTunnel copyToServer =
+                                        new ProxyTunnel(clientSocket, serverSocket);
+
+                                copyToClient.start();
+                                copyToServer.start();
+
+                                copyToClient.join();
+                                // here copyToClient.close() would not provoke the
+                                // bug ( since it would trigger the retry logic in
+                                // HttpURLConnction.writeRequests ), so close only
+                                // the output to get the connection in this state.
+                                clientSocket.shutdownOutput();
+
+                                try {
+                                    Thread.sleep(3000);
+                                } catch (InterruptedException ignored) { }
+
+                                // now close all connections to finish the test
+                                copyToServer.close();
+                                copyToClient.close();
+                            } catch (IOException | NumberFormatException
+                                    | InterruptedException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    };
+                    threads.add(t);
+                    t.start();
+                }
+                for (Thread t: threads)
+                    t.join();
+            } catch (IOException | InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * This inner class provides unidirectional data flow through the sockets
+     * by continuously copying bytes from the input socket onto the output
+     * socket, until both sockets are open and EOF has not been received.
+     */
+    class ProxyTunnel extends Thread {
+        private final Socket sockIn;
+        private final Socket sockOut;
+        private final InputStream input;
+        private final OutputStream output;
+
+        public ProxyTunnel(Socket sockIn, Socket sockOut) throws IOException {
+            super("ProxyTunnel");
+            this.sockIn  = sockIn;
+            this.sockOut = sockOut;
+            input  = sockIn.getInputStream();
+            output = sockOut.getOutputStream();
+        }
+
+        public void run() {
+            byte[] buf = new byte[8192];
+            int bytesRead;
+
+            try {
+                while ((bytesRead = input.read(buf)) >= 0) {
+                    output.write(buf, 0, bytesRead);
+                    output.flush();
+                }
+            } catch (IOException ignored) {
+                close();
+            }
+        }
+
+        public void close() {
+            try {
+                if (!sockIn.isClosed())
+                    sockIn.close();
+                if (!sockOut.isClosed())
+                    sockOut.close();
+            } catch (IOException ignored) { }
+        }
+    }
+
+    /**
+     * the server thread
+     */
+    class HttpServer extends Thread implements Closeable {
+
+        private final ServerSocket serverSocket;
+        private final SSLSocketFactory sslSocketFactory;
+        private final String serverResponse =
+                "HTTP/1.1 200 OK\r\n"
+                + "Content-Type: text/plain\r\n"
+                + "Content-Length: 3\r\n"
+                + "\r\n"
+                + "Hi!";
+        private int connectionCount = 0;
+
+        HttpServer() throws Exception {
+            super("HttpServer Thread");
+
+            KeyStore ks = KeyStore.getInstance("JKS");
+            ks.load(new FileInputStream(keystorefile), passphrase.toCharArray());
+            KeyManagerFactory factory = KeyManagerFactory.getInstance("SunX509");
+            factory.init(ks, passphrase.toCharArray());
+            SSLContext ctx = SSLContext.getInstance("TLS");
+            ctx.init(factory.getKeyManagers(), null, null);
+
+            sslSocketFactory = ctx.getSocketFactory();
+
+            // Create the server that the test wants to connect to via the proxy
+            serverSocket = ServerSocketFactory.getDefault().createServerSocket();
+            serverSocket.bind(new InetSocketAddress(InetAddress.getLocalHost(), 0));
+        }
+
+        public int getPort() { return  serverSocket.getLocalPort(); }
+
+        @Override
+        public void close() throws IOException { serverSocket.close(); }
+
+        @Override
+        public void run() {
+            try {
+                while (connectionCount++ < 2) {
+                    Socket socket = serverSocket.accept();
+                    System.out.println("Server: NEW CONNECTION "
+                            + connectionCount);
+
+                    SSLSocket sslSocket = (SSLSocket) sslSocketFactory
+                            .createSocket(socket,null, getPort(), false);
+                    sslSocket.setUseClientMode(false);
+                    sslSocket.startHandshake();
+
+                    String firstLine = readHeader(sslSocket.getInputStream());
+                    if (firstLine != null && firstLine.contains("CONNECT")) {
+                        System.out.println("Server: BUG! HTTP CONNECT"
+                                + " encountered: " + firstLine);
+                        connectInServer.set(true);
+                    }
+
+                    // write the success response, the request body is not read.
+                    // close only output and keep input open.
+                    OutputStream out = sslSocket.getOutputStream();
+                    out.write(serverResponse.getBytes("UTF-8"));
+                    socket.shutdownOutput();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * read the header and return only the first line.
+     *
+     * @param inputStream the stream to read from
+     * @return the first line of the stream
+     * @throws IOException if reading failed
+     */
+    private static String readHeader(InputStream inputStream)
+            throws IOException {
+        String line;
+        String firstLine = null;
+        while ((line = readLine(inputStream)) != null && line.length() > 0) {
+            if (firstLine == null) {
+                firstLine = line;
+            }
+        }
+
+        return firstLine;
+    }
+
+    /**
+     * read a line from stream.
+     *
+     * @param inputStream the stream to read from
+     * @return the line
+     * @throws IOException  if reading failed
+     */
+    private static String readLine(InputStream inputStream)
+            throws IOException {
+        final StringBuilder line = new StringBuilder();
+        int ch;
+        while ((ch = inputStream.read()) != -1) {
+            if (ch == '\r') {
+                continue;
+            }
+
+            if (ch == '\n') {
+                break;
+            }
+
+            line.append((char) ch);
+        }
+
+        return line.toString();
+    }
+
+    private SSLSocketFactory createTestSSLSocketFactory() {
+
+        HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+            @Override
+            public boolean verify(String hostname, SSLSession sslSession) {
+                // ignore the cert's CN; it's not important to this test
+                return true;
+            }
+        });
+
+        // Set up the socket factory to use a trust manager that trusts all
+        // certs, since trust validation isn't important to this test
+        final TrustManager[] trustAllCertChains = new TrustManager[] {
+            new X509TrustManager() {
+                @Override
+                public X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+
+                @Override
+                public void checkClientTrusted(X509Certificate[] certs,
+                        String authType) {
+                }
+
+                @Override
+                public void checkServerTrusted(X509Certificate[] certs,
+                        String authType) {
+                }
+            }
+        };
+
+        final SSLContext sc;
+        try {
+            sc = SSLContext.getInstance("TLS");
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException(e);
+        }
+
+        try {
+            sc.init(null, trustAllCertChains, new java.security.SecureRandom());
+        } catch (KeyManagementException e) {
+            throw new RuntimeException(e);
+        }
+
+        return sc.getSocketFactory();
+    }
+}