changeset 9175:5a9f04957f82 jdk8u20-b03

Merge
author dcherepanov
date Wed, 26 Feb 2014 07:43:38 +0400
parents 356fe4090505 (current diff) 0906a9d88fa0 (diff)
children c347889445c1
files src/share/classes/sun/swing/AbstractFilterComboBoxModel.java
diffstat 74 files changed, 4354 insertions(+), 350 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Feb 18 16:38:13 2014 +0400
+++ b/.hgtags	Wed Feb 26 07:43:38 2014 +0400
@@ -248,3 +248,9 @@
 13b28cffa140d8637d37273e3791b484191965bb jdk8u20-b00
 ae303640bc1cca06f1c6ac887e6b523ceeb425a6 jdk8-b124
 435a8a2f6d33ae28f3de5e40b6cfb552451ea348 jdk8u20-b01
+ae303640bc1cca06f1c6ac887e6b523ceeb425a6 jdk8-b125
+a9088d517f2fa9919886d3d95023c518b59172b8 jdk8-b126
+fbf251b8ef8a4a2aa1fd58efc8d0d5c8e2fd582b jdk8-b127
+f644211c59fd7c1d0c81239c55b31e1d377d7650 jdk8-b128
+80568a19aab7300bc92baf2dc225be929f5b03ed jdk8-b129
+9543b632ab87368c887d8b29b21157ebb44228d0 jdk8u20-b02
--- a/make/lib/Awt2dLibraries.gmk	Tue Feb 18 16:38:13 2014 +0400
+++ b/make/lib/Awt2dLibraries.gmk	Wed Feb 26 07:43:38 2014 +0400
@@ -1303,6 +1303,7 @@
       LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
       LDFLAGS_SUFFIX := $(LIBM) $(LDFLAGS_JDKLIB_SUFFIX), \
+      LDFLAGS_SUFFIX_windows := $(WIN_JAVA_LIB), \
       LDFLAGS_SUFFIX_posix := -lm, \
       VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
       RC_FLAGS := $(RC_FLAGS) \
--- a/src/macosx/classes/apple/laf/JRSUIUtils.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/macosx/classes/apple/laf/JRSUIUtils.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -28,6 +28,9 @@
 import com.apple.laf.AquaImageFactory.NineSliceMetrics;
 
 import apple.laf.JRSUIConstants.*;
+import sun.security.action.GetPropertyAction;
+
+import java.security.AccessController;
 
 public class JRSUIUtils {
     static boolean isLeopard = isMacOSXLeopard();
@@ -47,7 +50,7 @@
 
     static boolean currentMacOSXVersionMatchesGivenVersionRange(final int version, final boolean inclusive, final boolean matchBelow, final boolean matchAbove) {
         // split the "10.x.y" version number
-        String osVersion = System.getProperty("os.version");
+        String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version"));
         String[] fragments = osVersion.split("\\.");
 
         // sanity check the "10." part of the version
--- a/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Wed Feb 26 07:43:38 2014 +0400
@@ -42,7 +42,6 @@
 import javax.swing.plaf.*;
 import javax.swing.table.*;
 
-import sun.swing.AbstractFilterComboBoxModel;
 import sun.swing.SwingUtilities2;
 
 public class AquaFileChooserUI extends FileChooserUI {
@@ -1267,9 +1266,64 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractFilterComboBoxModel {
-        protected JFileChooser getFileChooser() {
-            return AquaFileChooserUI.this.getFileChooser();
+    protected class FilterComboBoxModel extends DefaultListModel implements ComboBoxModel, PropertyChangeListener {
+        int selectedIndex = -1;
+
+        protected FilterComboBoxModel() {
+            super();
+            final FileFilter filters[] = getFileChooser().getChoosableFileFilters();
+            for (int i = 0; i < filters.length; i++) {
+                this.add(i, filters[i]);
+            }
+        }
+
+        public void propertyChange(final PropertyChangeEvent e) {
+            final String prop = e.getPropertyName();
+            if (prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
+                this.clear();
+                final FileFilter filters[] = (FileFilter[])e.getNewValue();
+
+                for (int i = 0; i < filters.length; i++) {
+                    this.add(i, filters[i]);
+                }
+
+                fireContentsChanged(this, -1, -1);
+            } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
+                final FileFilter currentFilter = (FileFilter)e.getNewValue();
+                FileFilter filters[] = getFileChooser().getChoosableFileFilters();
+
+                boolean found = false;
+                if (currentFilter != null) {
+                    for (final FileFilter element : filters) {
+                        if (element == currentFilter) {
+                            found = true;
+                        }
+                    }
+                    if (found == false) {
+                        getFileChooser().addChoosableFileFilter(currentFilter);
+                    }
+                }
+
+                filters = getFileChooser().getChoosableFileFilters();
+                setSelectedItem(e.getNewValue());
+            }
+        }
+
+        public void setSelectedItem(final Object filter) {
+            if (filter != null) {
+                selectedIndex = this.indexOf(filter);
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public Object getSelectedItem() {
+            final Object returnValue = null;
+
+            if (this.size() > 0) {
+                if ((selectedIndex != -1) && (selectedIndex < size())) { return this.get(selectedIndex); }
+            }
+
+            return returnValue;
         }
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java	Wed Feb 26 07:43:38 2014 +0400
@@ -41,7 +41,6 @@
 import javax.swing.table.*;
 import javax.accessibility.*;
 
-import sun.swing.AbstractFilterComboBoxModel;
 import sun.swing.SwingUtilities2;
 
 import sun.swing.plaf.synth.*;
@@ -1329,9 +1328,71 @@
     /**
      * Data model for filter combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractFilterComboBoxModel {
-        protected JFileChooser getFileChooser() {
-            return GTKFileChooserUI.this.getFileChooser();
+    protected class FilterComboBoxModel extends AbstractListModel
+            implements ComboBoxModel, PropertyChangeListener {
+        protected FileFilter[] filters;
+
+        protected FilterComboBoxModel() {
+            super();
+            filters = getFileChooser().getChoosableFileFilters();
+        }
+
+        public void propertyChange(PropertyChangeEvent e) {
+            String prop = e.getPropertyName();
+            if (prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
+                filters = (FileFilter[]) e.getNewValue();
+                fireContentsChanged(this, -1, -1);
+            } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public void setSelectedItem(Object filter) {
+            if (filter != null) {
+                getFileChooser().setFileFilter((FileFilter) filter);
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public Object getSelectedItem() {
+            // Ensure that the current filter is in the list.
+            // NOTE: we shouldnt' have to do this, since JFileChooser adds
+            // the filter to the choosable filters list when the filter
+            // is set. Lets be paranoid just in case someone overrides
+            // setFileFilter in JFileChooser.
+            FileFilter currentFilter = getFileChooser().getFileFilter();
+            boolean found = false;
+            if (currentFilter != null) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
+                        found = true;
+                    }
+                }
+                if (found == false) {
+                    getFileChooser().addChoosableFileFilter(currentFilter);
+                }
+            }
+            return getFileChooser().getFileFilter();
+        }
+
+        public int getSize() {
+            if (filters != null) {
+                return filters.length;
+            } else {
+                return 0;
+            }
+        }
+
+        public Object getElementAt(int index) {
+            if (index > getSize() - 1) {
+                // This shouldn't happen. Try to recover gracefully.
+                return getFileChooser().getFileFilter();
+            }
+            if (filters != null) {
+                return filters[index];
+            } else {
+                return null;
+            }
         }
     }
 }
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java	Wed Feb 26 07:43:38 2014 +0400
@@ -38,7 +38,6 @@
 import java.io.IOException;
 import java.util.*;
 import sun.awt.shell.ShellFolder;
-import sun.swing.AbstractFilterComboBoxModel;
 import sun.swing.SwingUtilities2;
 
 /**
@@ -778,9 +777,70 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractFilterComboBoxModel {
-        protected JFileChooser getFileChooser() {
-            return MotifFileChooserUI.this.getFileChooser();
+    protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
+            PropertyChangeListener {
+        protected FileFilter[] filters;
+        protected FilterComboBoxModel() {
+            super();
+            filters = getFileChooser().getChoosableFileFilters();
+        }
+
+        public void propertyChange(PropertyChangeEvent e) {
+            String prop = e.getPropertyName();
+            if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {
+                filters = (FileFilter[]) e.getNewValue();
+                fireContentsChanged(this, -1, -1);
+            } else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public void setSelectedItem(Object filter) {
+            if(filter != null) {
+                getFileChooser().setFileFilter((FileFilter) filter);
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public Object getSelectedItem() {
+            // Ensure that the current filter is in the list.
+            // NOTE: we shouldnt' have to do this, since JFileChooser adds
+            // the filter to the choosable filters list when the filter
+            // is set. Lets be paranoid just in case someone overrides
+            // setFileFilter in JFileChooser.
+            FileFilter currentFilter = getFileChooser().getFileFilter();
+            boolean found = false;
+            if(currentFilter != null) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
+                        found = true;
+                    }
+                }
+                if (!found) {
+                    getFileChooser().addChoosableFileFilter(currentFilter);
+                }
+            }
+            return getFileChooser().getFileFilter();
+        }
+
+        public int getSize() {
+            if(filters != null) {
+                return filters.length;
+            } else {
+                return 0;
+            }
+        }
+
+        public FileFilter getElementAt(int index) {
+            if(index > getSize() - 1) {
+                // This shouldn't happen. Try to recover gracefully.
+                return getFileChooser().getFileFilter();
+            }
+            if(filters != null) {
+                return filters[index];
+            } else {
+                return null;
+            }
         }
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1193,9 +1193,70 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractFilterComboBoxModel {
-        protected JFileChooser getFileChooser() {
-            return WindowsFileChooserUI.this.getFileChooser();
+    protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
+            PropertyChangeListener {
+        protected FileFilter[] filters;
+        protected FilterComboBoxModel() {
+            super();
+            filters = getFileChooser().getChoosableFileFilters();
+        }
+
+        public void propertyChange(PropertyChangeEvent e) {
+            String prop = e.getPropertyName();
+            if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
+                filters = (FileFilter[]) e.getNewValue();
+                fireContentsChanged(this, -1, -1);
+            } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public void setSelectedItem(Object filter) {
+            if(filter != null) {
+                getFileChooser().setFileFilter((FileFilter) filter);
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public Object getSelectedItem() {
+            // Ensure that the current filter is in the list.
+            // NOTE: we shouldnt' have to do this, since JFileChooser adds
+            // the filter to the choosable filters list when the filter
+            // is set. Lets be paranoid just in case someone overrides
+            // setFileFilter in JFileChooser.
+            FileFilter currentFilter = getFileChooser().getFileFilter();
+            boolean found = false;
+            if(currentFilter != null) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
+                        found = true;
+                    }
+                }
+                if(found == false) {
+                    getFileChooser().addChoosableFileFilter(currentFilter);
+                }
+            }
+            return getFileChooser().getFileFilter();
+        }
+
+        public int getSize() {
+            if(filters != null) {
+                return filters.length;
+            } else {
+                return 0;
+            }
+        }
+
+        public FileFilter getElementAt(int index) {
+            if(index > getSize() - 1) {
+                // This shouldn't happen. Try to recover gracefully.
+                return getFileChooser().getFileFilter();
+            }
+            if(filters != null) {
+                return filters[index];
+            } else {
+                return null;
+            }
         }
     }
 
--- a/src/share/classes/java/awt/EventQueue.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/java/awt/EventQueue.java	Wed Feb 26 07:43:38 2014 +0400
@@ -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
@@ -1093,6 +1093,13 @@
                 dispatchThread = null;
             }
             AWTAutoShutdown.getInstance().notifyThreadFree(edt);
+            /*
+             * Event was posted after EDT events pumping had stopped, so start
+             * another EDT to handle this event
+             */
+            if (peekEvent() != null) {
+                initDispatchThread();
+            }
         } finally {
             pushPopLock.unlock();
         }
--- a/src/share/classes/java/util/Comparator.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/java/util/Comparator.java	Wed Feb 26 07:43:38 2014 +0400
@@ -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
@@ -235,7 +235,7 @@
      * @see #thenComparing(Comparator)
      * @since 1.8
      */
-    default <U extends Comparable<? super U>> Comparator<T> thenComparing(
+    default <U> Comparator<T> thenComparing(
             Function<? super T, ? extends U> keyExtractor,
             Comparator<? super U> keyComparator)
     {
--- a/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1067,9 +1067,69 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractFilterComboBoxModel {
-        protected JFileChooser getFileChooser() {
-            return MetalFileChooserUI.this.getFileChooser();
+    protected class FilterComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object>, PropertyChangeListener {
+        protected FileFilter[] filters;
+        protected FilterComboBoxModel() {
+            super();
+            filters = getFileChooser().getChoosableFileFilters();
+        }
+
+        public void propertyChange(PropertyChangeEvent e) {
+            String prop = e.getPropertyName();
+            if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
+                filters = (FileFilter[]) e.getNewValue();
+                fireContentsChanged(this, -1, -1);
+            } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public void setSelectedItem(Object filter) {
+            if(filter != null) {
+                getFileChooser().setFileFilter((FileFilter) filter);
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public Object getSelectedItem() {
+            // Ensure that the current filter is in the list.
+            // NOTE: we shouldnt' have to do this, since JFileChooser adds
+            // the filter to the choosable filters list when the filter
+            // is set. Lets be paranoid just in case someone overrides
+            // setFileFilter in JFileChooser.
+            FileFilter currentFilter = getFileChooser().getFileFilter();
+            boolean found = false;
+            if(currentFilter != null) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
+                        found = true;
+                    }
+                }
+                if(found == false) {
+                    getFileChooser().addChoosableFileFilter(currentFilter);
+                }
+            }
+            return getFileChooser().getFileFilter();
+        }
+
+        public int getSize() {
+            if(filters != null) {
+                return filters.length;
+            } else {
+                return 0;
+            }
+        }
+
+        public Object getElementAt(int index) {
+            if(index > getSize() - 1) {
+                // This shouldn't happen. Try to recover gracefully.
+                return getFileChooser().getFileFilter();
+            }
+            if(filters != null) {
+                return filters[index];
+            } else {
+                return null;
+            }
         }
     }
 
--- a/src/share/classes/sun/font/FontFamily.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/font/FontFamily.java	Wed Feb 26 07:43:38 2014 +0400
@@ -25,6 +25,7 @@
 
 package sun.font;
 
+import java.io.File;
 import java.awt.Font;
 import java.util.HashMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -105,8 +106,39 @@
         return familyRank;
     }
 
+    private boolean isFromSameSource(Font2D font) {
+        if (!(font instanceof FileFont)) {
+            return false;
+        }
+
+        FileFont existingFont = null;
+        if (plain instanceof FileFont) {
+            existingFont = (FileFont)plain;
+        } else if (bold instanceof FileFont) {
+            existingFont = (FileFont)bold;
+        } else if (italic instanceof FileFont) {
+             existingFont = (FileFont)italic;
+        } else if (bolditalic instanceof FileFont) {
+             existingFont = (FileFont)bolditalic;
+        }
+        // A family isn't created until there's a font.
+        // So if we didn't find a file font it means this
+        // isn't a file-based family.
+        if (existingFont == null) {
+            return false;
+        }
+        File existDir = (new File(existingFont.platName)).getParentFile();
+
+        FileFont newFont = (FileFont)font;
+        File newDir = (new File(newFont.platName)).getParentFile();
+        return java.util.Objects.equals(newDir, existDir);
+    }
+
     public void setFont(Font2D font, int style) {
-        if (font.getRank() > familyRank) {
+        /* Allow a lower-rank font only if its a file font
+         * from the exact same source as any previous font.
+         */
+        if ((font.getRank() > familyRank) && !isFromSameSource(font)) {
             if (FontUtilities.isLogging()) {
                 FontUtilities.getLogger()
                                   .warning("Rejecting adding " + font +
--- a/src/share/classes/sun/font/SunFontManager.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/font/SunFontManager.java	Wed Feb 26 07:43:38 2014 +0400
@@ -763,7 +763,7 @@
             if (family == null) {
                 family = new FontFamily(familyName, false, rank);
                 family.setFont(f, f.style);
-            } else if (family.getRank() >= rank) {
+            } else {
                 family.setFont(f, f.style);
             }
             fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH), f);
@@ -854,7 +854,7 @@
                 if (family == null) {
                     family = new FontFamily(familyName, false, rank);
                     family.setFont(newFont, newFont.style);
-                } else if (family.getRank() >= rank) {
+                } else {
                     family.setFont(newFont, newFont.style);
                 }
                 return newFont;
--- a/src/share/classes/sun/invoke/util/VerifyAccess.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/invoke/util/VerifyAccess.java	Wed Feb 26 07:43:38 2014 +0400
@@ -90,33 +90,26 @@
         if (allowedModes == 0)  return false;
         assert((allowedModes & PUBLIC) != 0 &&
                (allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED)) == 0);
-        // Usually refc and defc are the same, but if they differ, verify them both.
-        if (refc != defc) {
-            if (!isClassAccessible(refc, lookupClass, allowedModes)) {
-                // Note that defc is verified in the switch below.
-                return false;
-            }
-            if ((mods & (ALL_ACCESS_MODES|STATIC)) == (PROTECTED|STATIC) &&
-                (allowedModes & PROTECTED_OR_PACKAGE_ALLOWED) != 0) {
-                // Apply the special rules for refc here.
-                if (!isRelatedClass(refc, lookupClass))
-                    return isSamePackage(defc, lookupClass);
-                // If refc == defc, the call to isPublicSuperClass will do
-                // the whole job, since in that case refc (as defc) will be
-                // a superclass of the lookup class.
-            }
+        // The symbolic reference class (refc) must always be fully verified.
+        if (!isClassAccessible(refc, lookupClass, allowedModes)) {
+            return false;
         }
+        // Usually refc and defc are the same, but verify defc also in case they differ.
         if (defc == lookupClass &&
             (allowedModes & PRIVATE) != 0)
             return true;        // easy check; all self-access is OK
         switch (mods & ALL_ACCESS_MODES) {
         case PUBLIC:
-            if (refc != defc)  return true;  // already checked above
-            return isClassAccessible(refc, lookupClass, allowedModes);
+            return true;  // already checked above
         case PROTECTED:
             if ((allowedModes & PROTECTED_OR_PACKAGE_ALLOWED) != 0 &&
                 isSamePackage(defc, lookupClass))
                 return true;
+            if ((allowedModes & PROTECTED) == 0)
+                return false;
+            if ((mods & STATIC) != 0 &&
+                !isRelatedClass(refc, lookupClass))
+                return false;
             if ((allowedModes & PROTECTED) != 0 &&
                 isSuperClass(defc, lookupClass))
                 return true;
--- a/src/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -26,13 +26,16 @@
 package sun.security.provider.certpath;
 
 import java.io.IOException;
-import java.util.Date;
-
+import java.math.BigInteger;
 import java.security.cert.Certificate;
 import java.security.cert.X509Certificate;
 import java.security.cert.X509CertSelector;
 import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.Date;
 
+import sun.security.util.Debug;
+import sun.security.util.DerInputStream;
 import sun.security.util.DerOutputStream;
 import sun.security.x509.SerialNumber;
 import sun.security.x509.KeyIdentifier;
@@ -40,26 +43,27 @@
 
 /**
  * An adaptable X509 certificate selector for forward certification path
- * building.
+ * building. This selector overrides the default X509CertSelector matching
+ * rules for the subjectKeyIdentifier and serialNumber criteria, and adds
+ * additional rules for certificate validity.
  *
  * @since 1.7
  */
 class AdaptableX509CertSelector extends X509CertSelector {
+
+    private static final Debug debug = Debug.getInstance("certpath");
+
     // The start date of a validity period.
     private Date startDate;
 
     // The end date of a validity period.
     private Date endDate;
 
-    // Is subject key identifier sensitive?
-    private boolean isSKIDSensitive = false;
+    // The subject key identifier
+    private byte[] ski;
 
-    // Is serial number sensitive?
-    private boolean isSNSensitive = false;
-
-    AdaptableX509CertSelector() {
-        super();
-    }
+    // The serial number
+    private BigInteger serial;
 
     /**
      * Sets the criterion of the X509Certificate validity period.
@@ -86,51 +90,70 @@
     }
 
     /**
-     * Parse the authority key identifier extension.
+     * This selector overrides the subjectKeyIdentifier matching rules of
+     * X509CertSelector, so it throws IllegalArgumentException if this method
+     * is ever called.
+     */
+    @Override
+    public void setSubjectKeyIdentifier(byte[] subjectKeyID) {
+        throw new IllegalArgumentException();
+    }
+
+    /**
+     * This selector overrides the serialNumber matching rules of
+     * X509CertSelector, so it throws IllegalArgumentException if this method
+     * is ever called.
+     */
+    @Override
+    public void setSerialNumber(BigInteger serial) {
+        throw new IllegalArgumentException();
+    }
+
+    /**
+     * Sets the subjectKeyIdentifier and serialNumber criteria from the
+     * authority key identifier extension.
      *
-     * If the keyIdentifier field of the extension is non-null, set the
-     * subjectKeyIdentifier criterion. If the authorityCertSerialNumber
-     * field is non-null, set the serialNumber criterion.
+     * The subjectKeyIdentifier criterion is set to the keyIdentifier field
+     * of the extension, or null if it is empty. The serialNumber criterion
+     * is set to the authorityCertSerialNumber field, or null if it is empty.
      *
-     * Note that we will not set the subject criterion according to the
+     * Note that we do not set the subject criterion to the
      * authorityCertIssuer field of the extension. The caller MUST set
-     * the subject criterion before call match().
+     * the subject criterion before calling match().
      *
-     * @param akidext the authorityKeyIdentifier extension
+     * @param ext the authorityKeyIdentifier extension
+     * @throws IOException if there is an error parsing the extension
      */
-    void parseAuthorityKeyIdentifierExtension(
-            AuthorityKeyIdentifierExtension akidext) throws IOException {
-        if (akidext != null) {
-            KeyIdentifier akid = (KeyIdentifier)akidext.get(
-                    AuthorityKeyIdentifierExtension.KEY_ID);
+    void setSkiAndSerialNumber(AuthorityKeyIdentifierExtension ext)
+        throws IOException {
+
+        ski = null;
+        serial = null;
+
+        if (ext != null) {
+            KeyIdentifier akid = (KeyIdentifier)ext.get(
+                AuthorityKeyIdentifierExtension.KEY_ID);
             if (akid != null) {
-                // Do not override the previous setting for initial selection.
-                if (isSKIDSensitive || getSubjectKeyIdentifier() == null) {
-                    DerOutputStream derout = new DerOutputStream();
-                    derout.putOctetString(akid.getIdentifier());
-                    super.setSubjectKeyIdentifier(derout.toByteArray());
-
-                    isSKIDSensitive = true;
-                }
+                DerOutputStream derout = new DerOutputStream();
+                derout.putOctetString(akid.getIdentifier());
+                ski = derout.toByteArray();
             }
-
-            SerialNumber asn = (SerialNumber)akidext.get(
-                    AuthorityKeyIdentifierExtension.SERIAL_NUMBER);
+            SerialNumber asn = (SerialNumber)ext.get(
+                AuthorityKeyIdentifierExtension.SERIAL_NUMBER);
             if (asn != null) {
-                // Do not override the previous setting for initial selection.
-                if (isSNSensitive || getSerialNumber() == null) {
-                    super.setSerialNumber(asn.getNumber());
-                    isSNSensitive = true;
-                }
+                serial = asn.getNumber();
             }
-
-            // the subject criterion should be set by the caller.
+            // the subject criterion should be set by the caller
         }
     }
 
     /**
      * Decides whether a <code>Certificate</code> should be selected.
      *
+     * This method overrides the matching rules for the subjectKeyIdentifier
+     * and serialNumber criteria and adds additional rules for certificate
+     * validity.
+     *
      * For the purpose of compatibility, when a certificate is of
      * version 1 and version 2, or the certificate does not include
      * a subject key identifier extension, the selection criterion
@@ -138,12 +161,28 @@
      */
     @Override
     public boolean match(Certificate cert) {
-        if (!(cert instanceof X509Certificate)) {
+        X509Certificate xcert = (X509Certificate)cert;
+
+        // match subject key identifier
+        if (!matchSubjectKeyID(xcert)) {
             return false;
         }
 
-        X509Certificate xcert = (X509Certificate)cert;
+        // In practice, a CA may replace its root certificate and require that
+        // the existing certificate is still valid, even if the AKID extension
+        // does not match the replacement root certificate fields.
+        //
+        // Conservatively, we only support the replacement for version 1 and
+        // version 2 certificate. As for version 3, the certificate extension
+        // may contain sensitive information (for example, policies), the
+        // AKID need to be respected to seek the exact certificate in case
+        // of key or certificate abuse.
         int version = xcert.getVersion();
+        if (serial != null && version > 2) {
+            if (!serial.equals(xcert.getSerialNumber())) {
+                return false;
+            }
+        }
 
         // Check the validity period for version 1 and 2 certificate.
         if (version < 3) {
@@ -154,7 +193,6 @@
                     return false;
                 }
             }
-
             if (endDate != null) {
                 try {
                     xcert.checkValidity(endDate);
@@ -164,26 +202,50 @@
             }
         }
 
-        // If no SubjectKeyIdentifier extension, don't bother to check it.
-        if (isSKIDSensitive &&
-            (version < 3 || xcert.getExtensionValue("2.5.29.14") == null)) {
-            setSubjectKeyIdentifier(null);
+
+        if (!super.match(cert)) {
+            return false;
         }
 
-        // In practice, a CA may replace its root certificate and require that
-        // the existing certificate is still valid, even if the AKID extension
-        // does not match the replacement root certificate fields.
-        //
-        // Conservatively, we only support the replacement for version 1 and
-        // version 2 certificate. As for version 2, the certificate extension
-        // may contain sensitive information (for example, policies), the
-        // AKID need to be respected to seek the exact certificate in case
-        // of key or certificate abuse.
-        if (isSNSensitive && version < 3) {
-            setSerialNumber(null);
+        return true;
+    }
+
+    /*
+     * Match on subject key identifier extension value. These matching rules
+     * are identical to X509CertSelector except that if the certificate does
+     * not have a subject key identifier extension, it returns true.
+     */
+    private boolean matchSubjectKeyID(X509Certificate xcert) {
+        if (ski == null) {
+            return true;
         }
-
-        return super.match(cert);
+        try {
+            byte[] extVal = xcert.getExtensionValue("2.5.29.14");
+            if (extVal == null) {
+                if (debug != null) {
+                    debug.println("AdaptableX509CertSelector.match: "
+                        + "no subject key ID extension");
+                }
+                return true;
+            }
+            DerInputStream in = new DerInputStream(extVal);
+            byte[] certSubjectKeyID = in.getOctetString();
+            if (certSubjectKeyID == null ||
+                    !Arrays.equals(ski, certSubjectKeyID)) {
+                if (debug != null) {
+                    debug.println("AdaptableX509CertSelector.match: "
+                        + "subject key IDs don't match");
+                }
+                return false;
+            }
+        } catch (IOException ex) {
+            if (debug != null) {
+                debug.println("AdaptableX509CertSelector.match: "
+                    + "exception in subject key ID check");
+            }
+            return false;
+        }
+        return true;
     }
 
     @Override
@@ -198,6 +260,9 @@
             copy.endDate = (Date)endDate.clone();
         }
 
+        if (ski != null) {
+            copy.ski = ski.clone();
+        }
         return copy;
     }
 }
--- a/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -751,9 +751,7 @@
          * issued. [section 5.2.1, RFC 2459]
          */
         AuthorityKeyIdentifierExtension crlAKID = crl.getAuthKeyIdExtension();
-        if (crlAKID != null) {
-            issuerSelector.parseAuthorityKeyIdentifierExtension(crlAKID);
-        }
+        issuerSelector.setSkiAndSerialNumber(crlAKID);
 
         matched = issuerSelector.match(cert);
 
--- a/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java	Wed Feb 26 07:43:38 2014 +0400
@@ -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
@@ -269,7 +269,7 @@
              */
             AuthorityKeyIdentifierExtension akidext =
                     currentState.cert.getAuthorityKeyIdentifierExtension();
-            caSelector.parseAuthorityKeyIdentifierExtension(akidext);
+            caSelector.setSkiAndSerialNumber(akidext);
 
             /*
              * check the validity period
--- a/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Wed Feb 26 07:43:38 2014 +0400
@@ -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
@@ -103,7 +103,7 @@
              */
             try {
                 X509CertImpl firstCertImpl = X509CertImpl.toImpl(firstCert);
-                selector.parseAuthorityKeyIdentifierExtension(
+                selector.setSkiAndSerialNumber(
                             firstCertImpl.getAuthorityKeyIdentifierExtension());
             } catch (CertificateException | IOException e) {
                 // ignore
--- a/src/share/classes/sun/security/provider/certpath/RevocationChecker.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/security/provider/certpath/RevocationChecker.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -1035,6 +1035,9 @@
                 boolean signFlag = true;
                 List<? extends Certificate> cpList =
                     cpbr.getCertPath().getCertificates();
+                if (cpList.isEmpty()) {
+                    return;
+                }
                 try {
                     for (int i = cpList.size()-1; i >= 0; i-- ) {
                         X509Certificate cert = (X509Certificate)cpList.get(i);
--- a/src/share/classes/sun/swing/AbstractFilterComboBoxModel.java	Tue Feb 18 16:38:13 2014 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.swing;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-import javax.swing.JFileChooser;
-import javax.swing.filechooser.FileFilter;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-/**
- * Data model for a type-face selection combo-box.
- */
-public abstract class AbstractFilterComboBoxModel
-        extends AbstractListModel<FileFilter>
-        implements ComboBoxModel<FileFilter>, PropertyChangeListener {
-
-    protected FileFilter[] filters;
-
-    protected AbstractFilterComboBoxModel() {
-        this.filters = getFileChooser().getChoosableFileFilters();
-    }
-
-    protected abstract JFileChooser getFileChooser();
-
-    @Override
-    public void propertyChange(PropertyChangeEvent event) {
-        String property = event.getPropertyName();
-        if (property == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
-            this.filters = (FileFilter[]) event.getNewValue();
-            fireContentsChanged(this, -1, -1);
-        } else if (property == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
-            fireContentsChanged(this, -1, -1);
-        }
-    }
-
-    @Override
-    public void setSelectedItem(Object filter) {
-        if (filter != null) {
-            getFileChooser().setFileFilter((FileFilter) filter);
-            fireContentsChanged(this, -1, -1);
-        }
-    }
-
-    @Override
-    public Object getSelectedItem() {
-        // Ensure that the current filter is in the list.
-        // NOTE: we should not have to do this, since JFileChooser adds
-        // the filter to the choosable filters list when the filter
-        // is set. Lets be paranoid just in case someone overrides
-        // setFileFilter in JFileChooser.
-        FileFilter currentFilter = getFileChooser().getFileFilter();
-        if (currentFilter != null) {
-            for (FileFilter filter : this.filters) {
-                if (filter == currentFilter) {
-                    return currentFilter;
-                }
-            }
-            getFileChooser().addChoosableFileFilter(currentFilter);
-        }
-        return currentFilter;
-    }
-
-    @Override
-    public int getSize() {
-        return (this.filters != null)
-                ? filters.length
-                : 0;
-    }
-
-    @Override
-    public FileFilter getElementAt(int index) {
-        if (index >= getSize()) {
-            // This shouldn't happen. Try to recover gracefully.
-            return getFileChooser().getFileFilter();
-        }
-        return (this.filters != null)
-                ? filters[index]
-                : null;
-    }
-}
--- a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Wed Feb 26 07:43:38 2014 +0400
@@ -923,9 +923,70 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractFilterComboBoxModel {
-        protected JFileChooser getFileChooser() {
-            return SynthFileChooserUIImpl.this.getFileChooser();
+    protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
+            PropertyChangeListener {
+        protected FileFilter[] filters;
+        protected FilterComboBoxModel() {
+            super();
+            filters = getFileChooser().getChoosableFileFilters();
+        }
+
+        public void propertyChange(PropertyChangeEvent e) {
+            String prop = e.getPropertyName();
+            if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
+                filters = (FileFilter[]) e.getNewValue();
+                fireContentsChanged(this, -1, -1);
+            } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public void setSelectedItem(Object filter) {
+            if(filter != null) {
+                getFileChooser().setFileFilter((FileFilter) filter);
+                fireContentsChanged(this, -1, -1);
+            }
+        }
+
+        public Object getSelectedItem() {
+            // Ensure that the current filter is in the list.
+            // NOTE: we shouldnt' have to do this, since JFileChooser adds
+            // the filter to the choosable filters list when the filter
+            // is set. Lets be paranoid just in case someone overrides
+            // setFileFilter in JFileChooser.
+            FileFilter currentFilter = getFileChooser().getFileFilter();
+            boolean found = false;
+            if(currentFilter != null) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
+                        found = true;
+                    }
+                }
+                if(found == false) {
+                    getFileChooser().addChoosableFileFilter(currentFilter);
+                }
+            }
+            return getFileChooser().getFileFilter();
+        }
+
+        public int getSize() {
+            if(filters != null) {
+                return filters.length;
+            } else {
+                return 0;
+            }
+        }
+
+        public FileFilter getElementAt(int index) {
+            if(index > getSize() - 1) {
+                // This shouldn't happen. Try to recover gracefully.
+                return getFileChooser().getFileFilter();
+            }
+            if(filters != null) {
+                return filters[index];
+            } else {
+                return null;
+            }
         }
     }
 
--- a/src/share/native/common/jni_util.h	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/native/common/jni_util.h	Wed Feb 26 07:43:38 2014 +0400
@@ -278,6 +278,38 @@
 #define IS_NULL(obj) ((obj) == NULL)
 #define JNU_IsNull(env,obj) ((obj) == NULL)
 
+/************************************************************************
+ * Miscellaneous utilities used by the class libraries to return from
+ * a function if a value is NULL or an exception is pending.
+ */
+
+#define CHECK_NULL(x)                           \
+    do {                                        \
+        if ((x) == NULL) {                      \
+            return;                             \
+        }                                       \
+    } while (0)                                 \
+
+#define CHECK_NULL_RETURN(x, y)                 \
+    do {                                        \
+        if ((x) == NULL) {                      \
+            return (y);                         \
+        }                                       \
+    } while (0)                                 \
+
+#define JNU_CHECK_EXCEPTION(env)                \
+    do {                                        \
+        if ((*env)->ExceptionCheck(env)) {      \
+            return;                             \
+        }                                       \
+    } while (0)                                 \
+
+#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
+    do {                                        \
+        if ((*env)->ExceptionCheck(env)) {      \
+            return (y);                         \
+        }                                       \
+    } while (0)
 
 /************************************************************************
  * Debugging utilities
--- a/src/share/native/java/net/net_util.h	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/native/java/net/net_util.h	Wed Feb 26 07:43:38 2014 +0400
@@ -42,9 +42,6 @@
 #define NET_ERROR(env, ex, msg) \
 { if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg) }
 
-#define CHECK_NULL(x) if ((x) == NULL) return;
-#define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return y;
-
 /************************************************************************
  * Cached field IDs
  *
--- a/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h	Wed Feb 26 07:43:38 2014 +0400
@@ -189,7 +189,11 @@
             PUT(rgbquad_t, ptr, value);
             break;
         case 3:                /* not supported, LSB or MSB should always be specified */
-            *(int *) 0 = 0;    /* crash */
+            PUT(byte_t, ptr, 0xff); /* Put a stub value */
+            INCP(byte_t, ptr);
+            PUT(byte_t, ptr, 0xff);
+            INCP(byte_t, ptr);
+            PUT(byte_t, ptr, 0xff);
             break;
         case 2:
             PUT(word_t, ptr, value);
@@ -253,7 +257,7 @@
             value = GET(rgbquad_t, ptr);
             break;
         case 3:                /* not supported, LSB or MSB should always be specified */
-            *(int *) 0 = 0;
+            value = 0xFFFFFFFF; /*return a stub value */
             break;
         case 2:
             value = (rgbquad_t) GET(word_t, ptr);
--- a/src/share/native/sun/misc/Version.c	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/share/native/sun/misc/Version.c	Wed Feb 26 07:43:38 2014 +0400
@@ -90,10 +90,15 @@
 
     (*func_p)(env, &info, sizeof(info));
     setStaticIntField(env, cls, "jvm_major_version", JVM_VERSION_MAJOR(info.jvm_version));
+    JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
     setStaticIntField(env, cls, "jvm_minor_version", JVM_VERSION_MINOR(info.jvm_version));
+    JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
     setStaticIntField(env, cls, "jvm_micro_version", JVM_VERSION_MICRO(info.jvm_version));
+    JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
     setStaticIntField(env, cls, "jvm_build_number", JVM_VERSION_BUILD(info.jvm_version));
+    JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
     setStaticIntField(env, cls, "jvm_update_version", info.update_version);
+    JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
     jvm_special_version = info.special_update_version;
 
     return JNI_TRUE;
@@ -116,10 +121,15 @@
 
     JDK_GetVersionInfo0(&info, sizeof(info));
     setStaticIntField(env, cls, "jdk_major_version", JDK_VERSION_MAJOR(info.jdk_version));
+    JNU_CHECK_EXCEPTION(env);
     setStaticIntField(env, cls, "jdk_minor_version", JDK_VERSION_MINOR(info.jdk_version));
+    JNU_CHECK_EXCEPTION(env);
     setStaticIntField(env, cls, "jdk_micro_version", JDK_VERSION_MICRO(info.jdk_version));
+    JNU_CHECK_EXCEPTION(env);
     setStaticIntField(env, cls, "jdk_build_number", JDK_VERSION_BUILD(info.jdk_version));
+    JNU_CHECK_EXCEPTION(env);
     setStaticIntField(env, cls, "jdk_update_version", info.update_version);
+    JNU_CHECK_EXCEPTION(env);
     jdk_special_version = info.special_update_version;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Device.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,66 @@
+package checker;
+
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.Map;
+
+/**
+ * Represents the device configuration. The values are loaded from an XML file by JAXB.
+ */
+@XmlRootElement
+public class Device {
+
+    @XmlElement()
+    private Map<Module, Integer> supportedModules = new EnumMap<>(Module.class);
+
+    /**
+     * Returns map of supported modules. The map key is module. The map value is version.
+     *
+     * @return map of supported modules.
+     */
+    public Map<Module, Integer> getSupportedModules() {
+        return Collections.unmodifiableMap(supportedModules);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Kettle.xml	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+    - Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    - Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+    - Neither the name of Oracle nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+  This source code is provided to illustrate the usage of a given feature
+  or technique and has been deliberately simplified. Additional steps
+  required for a production-quality application, such as security checks,
+  input validation and proper error handling, might not be present in
+  this sample code.
+
+  -->
+
+<device>
+    <supportedModules>
+        <entry>
+            <key>DISPLAY</key>
+            <value>2</value>
+        </entry>
+        <entry>
+            <key>THERMOMETER</key>
+            <value>1</value>
+        </entry>
+        <entry>
+            <key>CLOCK</key>
+            <value>4</value>
+        </entry>
+    </supportedModules>
+</device>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Module.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,49 @@
+package checker;
+
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+
+
+/**
+ * Represents available modules.
+ */
+public enum Module {
+
+    DISPLAY, CLOCK, THERMOMETER, HEATER, SPEAKER, GSM, LED;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/PluginChecker.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+package checker;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.xml.bind.JAXBContext;
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.bind.JAXBException;
+
+/**
+ * Reads the device configuration from the XML file specified by -Adevice=device.xml.
+ * For each class in a project, checks required modules. If the device doesn't have
+ * the required module, then a compilation error will be shown.
+ */
+@SupportedAnnotationTypes("checker.RequireContainer")
+@SupportedSourceVersion(SourceVersion.RELEASE_8)
+public class PluginChecker extends javax.annotation.processing.AbstractProcessor {
+
+    /**
+     * Name of the option to get the path to the xml with device configuration.
+     */
+    public static final String DEVICE_OPTION = "device";
+    private Device device;
+
+    /**
+     * Only the device option is supported.
+     *
+     * {@inheritDoc}
+     */
+    @Override
+    public Set<String> getSupportedOptions() {
+        return new HashSet<>(Arrays.asList(DEVICE_OPTION));
+    }
+
+    /**
+     * Initializes the processor by loading the device configuration.
+     *
+     * {@inheritDoc}
+     */
+    @Override
+    public synchronized void init(ProcessingEnvironment processingEnv) {
+        super.init(processingEnv);
+        try {
+            String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
+            device = (Device) JAXBContext.newInstance(Device.class)
+                    .createUnmarshaller().unmarshal(new File(deviceOption));
+        } catch (JAXBException e) {
+            throw new RuntimeException(
+                    "Please specify device by -Adevice=device.xml\n"
+                    + e.toString(), e);
+        }
+    }
+
+    /**
+     * Processes @Require annotations and checks that Device meets requirements.
+     *
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations,
+            RoundEnvironment roundEnv) {
+        for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) {
+            for (Require req : el.getAnnotationsByType(Require.class)) {
+                //for every Require annotation checks if device has module of required version.
+                Integer version = device.getSupportedModules().get(req.value());
+
+                if (version == null
+                        || version < req.minVersion()
+                        || version > req.maxVersion()) {
+                    //if module is optional then show only warning not error
+                    if (req.optional()) {
+                        processingEnv.getMessager()
+                                .printMessage(Diagnostic.Kind.WARNING,
+                                        "Plugin [" + el + "] requires " + req
+                                        + "\n but device " + (version == null
+                                        ? "doesn't have such module."
+                                        + " This module is optional."
+                                        + " So plugin will work but miss"
+                                        + " some functionality"
+                                        : "has " + version
+                                        + " version of that module"));
+                    } else {
+                        processingEnv.getMessager()
+                                .printMessage(Diagnostic.Kind.ERROR,
+                                        "Plugin [" + el + "] requires " + req
+                                        + "\n but device "
+                                        + (version == null
+                                        ? "doesn't have such module"
+                                        : "has " + version
+                                        + " version of that module"));
+                    }
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Require.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+package checker;
+
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Indicates that a plug-in depends on a module.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Repeatable(RequireContainer.class)
+public @interface Require {
+
+    /**
+     * Returns the required module.
+     *
+     * @return required module.
+     */
+    Module value();
+
+    /**
+     * Returns the minimum supported version of a module.
+     *
+     * @return minimum supported version of a module.
+     */
+    int minVersion() default 1;
+
+    /**
+     * Returns the maximum supported version of a module.
+     *
+     * @return maximum supported version of a module.
+     */
+    int maxVersion() default Integer.MAX_VALUE;
+
+    /**
+     * Returns true if a module is optional. A module is optional if a system
+     * works without that module but is missing some functionality. Returns false if a system
+     * won't work without the specified module.
+     *
+     * @return true if module is optional. False otherwise.
+     */
+    boolean optional() default false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/RequireContainer.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,51 @@
+package checker;
+
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A container for the repeatable @Require annotation.
+ */
+@Retention(RetentionPolicy.CLASS)
+public @interface RequireContainer {
+
+    Require[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/BoilerPlugin.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+package plugins;
+
+import checker.Module;
+import checker.Require;
+
+/**
+ * BoilerPlugin provides support for boiling water and keeping water warm.
+ */
+@Require(value = Module.CLOCK, maxVersion = 3)
+@Require(value = Module.THERMOMETER)
+@Require(value = Module.HEATER)
+@Require(value = Module.LED, optional = true) //will use if present
+public class BoilerPlugin {
+
+    /**
+     * Heats water up to 100 degrees Celsius.
+     */
+    public void boil() {
+        boil(100);
+    }
+
+    /**
+     * Heats water up to temperature.
+     *
+     * @param temperature - desired temperature of the water in the boiler
+     */
+    public void boil(int temperature) {
+        /*
+         * Turn on heater and wait while temperature reaches desired temperature
+         * in Celsius. Finally, turn off heater.
+         * If present, the LED light changes color according to the temperature.
+         */
+    }
+
+    /**
+     * Keeps desired temperature.
+     *
+     * @param temperature - desired temperature of the water in the boiler
+     * @param seconds - period of time for checking temperature in seconds
+     */
+    public void keepWarm(int temperature, int seconds) {
+        //Every n seconds check temperature and warm up, if necessary.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/ExtendedBoilerPlugin.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+package plugins;
+
+import checker.Module;
+import checker.Require;
+import java.util.Calendar;
+
+/**
+ * Introduces new features for BoilerPlugin. Features are boiling water by an
+ * SMS and boiling water by date with notification by a phone call.
+ */
+@Require(value = Module.SPEAKER)
+@Require(value = Module.GSM, minVersion = 3)
+@Require(value = Module.DISPLAY)
+public class ExtendedBoilerPlugin extends BoilerPlugin {
+
+    /**
+     * Boils water at the appointed time and wakes you up by a ring and phone
+     * call. Shows "Good morning" and a quote of the day from the Internet on the
+     * display.
+     *
+     * @param calendar - date and time when water should be boiled
+     * @param phoneNumber - phone number to call
+     */
+    public void boilAndWakeUp(Calendar calendar, int phoneNumber) {
+        //implementation
+    }
+
+    /**
+     * Boils water at the appointed time by getting an SMS of fixed format.
+     * Sends an SMS on finish.
+     *
+     * @param sms - text of SMS
+     */
+    public void boilBySMS(String sms) {
+        //implementation
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/TimerPlugin.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+package plugins;
+
+import checker.Module;
+import checker.Require;
+
+/**
+ * Timer plug-in is used to support an alarm and a timer. It depends on Display and
+ * Clock modules.
+ */
+@Require(Module.DISPLAY)
+@Require(value = Module.CLOCK, maxVersion = 3)
+public class TimerPlugin {
+
+    /**
+     * Sets timer.
+     *
+     * @param time - the remaining time.
+     */
+    public void timer(long time) {
+        //start timer
+        //show the remaining time on display
+    }
+
+    /**
+     * Sets alarm.
+     *
+     * @param time - the alarm time.
+     */
+    public void alarm(long time) {
+        //start alarm
+        //show current time and alarm time on display
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/Validator/src/PositiveIntegerSupplier.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+import java.util.function.Supplier;
+
+/**
+ * Supplies a positive number.
+ */
+@Validate(value = Validator.INTEGER_NUMBER,
+        description = "It's not an Integer ")
+@Validate(value = Validator.POSITIVE_NUMBER,
+        description = "It's not a positive Number")
+public class PositiveIntegerSupplier implements Supplier<String> {
+
+    /**
+     * Returns a string representation of a positive integer.
+     *
+     * @return string representation of a positive integer.
+     */
+    @Override
+    public String get() {
+        return "20005"; //random number
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/Validator/src/SupplierValidator.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+import javax.xml.bind.ValidationException;
+import java.util.function.Supplier;
+
+/**
+ * Validates the supplier.
+ */
+public class SupplierValidator {
+
+    /**
+     * Validates the supplier.
+     *
+     * @param supplier - Supplier that needs to be validated.
+     * @return true if supplier has passed validation check. False otherwise.
+     */
+    public static boolean validate(Supplier<?> supplier) {
+        for (Validate annotation
+                : supplier.getClass().getAnnotationsByType(Validate.class)) {
+            try {
+                annotation.value().validate(supplier);
+            } catch (ValidationException e) {
+                System.out.println(annotation.description());
+                e.printStackTrace();
+                return false;
+            }
+        }
+        return true;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/Validator/src/Validate.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Indicates that the class should be validated by the specified validator.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Repeatable(ValidateContainer.class)
+public @interface Validate {
+
+    /**
+     * Returns the validator that should validate the annotated class.
+     *
+     * @return Validator that should validate annotated class.
+     */
+    Validator value();
+
+    /**
+     * Returns text to describe the failure of the validation check.
+     *
+     * @return text to describe the failure of the validation check.
+     */
+    String description() default "";
+}
+
+/**
+ * A container for the repeatable @Validate annotation.
+ *
+ * @author Andrey Nazarov
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@interface ValidateContainer {
+
+    Validate[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/Validator/src/Validator.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation and proper error handling, might not be present in
+ * this sample code.
+ */
+import javax.xml.bind.ValidationException;
+import java.util.function.Supplier;
+
+/**
+ * Enum of Validator implementations.
+ */
+public enum Validator {
+
+    /**
+     * This validator checks that the string represents an integer.
+     */
+    INTEGER_NUMBER {
+                /**
+                 * Checks that the string represents an integer.
+                 *
+                 * @param string - a string supplier
+                 * @throws ValidationException if the validation check fails
+                 */
+                @Override
+                void validate(Supplier<?> string) throws ValidationException {
+                    try {
+                        Integer.parseInt((String) string.get());
+                    } catch (NumberFormatException ex) {
+                        throw new ValidationException("Error while validating "
+                                + string.get());
+                    }
+                }
+            },
+    /**
+     * This validator checks that the string represents a positive number.
+     */
+    POSITIVE_NUMBER {
+                /**
+                 * Checks that the string represents a positive number.
+                 *
+                 * @param string - an string supplier
+                 * @throws ValidationException if the validation check fails
+                 */
+                @Override
+                void validate(Supplier<?> string) throws ValidationException {
+                    try {
+                        if (Double.compare(0.0, Double.parseDouble(
+                                        (String) string.get())) > 0) {
+                            throw new Exception();
+                        }
+                    } catch (Exception ex) {
+                        throw new ValidationException("Error while validating "
+                                + string.get());
+                    }
+                }
+            };
+
+    /**
+     * Checks that the supplier is valid.
+     *
+     * @param string - a string supplier
+     * @throws ValidationException if validation check fails
+     */
+    abstract void validate(Supplier<?> string) throws ValidationException;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/annotations/index.html	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Repeating Annotations Demo</title>
+</head>
+<body>
+<h2>Repeating Annotations Demo</h2>
+
+<p>
+    This demo shows how to use repeating annotations at runtime and at compile time.
+</p>
+
+<ul>
+    <li><h3>Dependency checker.</h3>
+
+        <p>
+            Shows how to define repeating annotations and process them at compile time.
+            The problem domain is some code that performs useful operations on hardware devices.
+            The code relies on "modules" to be present on the devices. Applicability of the code to a particular
+            device is checked while compiling the code for a particular device.
+            A set of modules provided by a device is listed in an xml file that turns red during the compilation
+            phase and is compared with the required module set specified by annotations.
+            For instance, there is kettle with hardware modules: thermometer, display, and clock.
+            There is also a boiler plug-in that requires clock, thermometer, heater, and optionally an LED light.
+
+            Build the PluginChecker annotation processor first.
+            Then, run javac with the annotation processor against plug-in sources using the following command: </p>
+
+        <code>javac -cp "PluginChecker.jar" -processor checker.PluginChecker -Adevice=Kettle.xml -proc:only &lt;source
+            files&gt;</code>
+
+        <p>
+            where <code>PluginChecker.jar</code> - path to jar file that contains PluginChecker annotation processor
+            class. </br>
+            <code>Kettle.xml</code> - path to device descriptor Kettle.xml                                         </br>
+            <code>&lt;source files&gt;</code> - source files in Plugins/src
+        </p>
+        For more information, see the source files.
+        </p>
+        <ul>
+            <li>Annotation processor sources: <a href="DependencyChecker/PluginChecker/src/">DependencyChecker/PluginChecker/src</a>
+            <li>Processing of repeating annotations can be found in <a href="DependencyChecker/PluginChecker/src/checker/PluginChecker.java">PluginChecker.java</a>
+            <li>Usage of repeating annotation is shown in modules sources.<a href="DependencyChecker/Plugins/src">DependencyChecker/Plugins/src</a>
+        </ul>
+
+    <li><h3>Validator.</h3>
+
+        <p>
+            Shows how to define repeating annotations and process them at runtime.
+            A problem domain is code that needs to validate provided Suppliers for conformance to some criteria.
+            The criteria are implemented by the Validator class which is applied by using annotations that are placed in
+            the code whenever validation is needed. For more information, see the
+            source files.
+        </p>
+
+        <p>
+        <ul>
+            <li>Usage of repeating annotation is described in <a href="Validator/src/PositiveIntegerSupplier.java">PositiveIntegerSupplier.java</a>
+            <li> Example of how to define a repeating annotation type can be found in
+                <a href="Validator/src/Validate.java">Validate.java</a>
+            <li> Usages of the new reflective methods can be found in <a href="Validator/src/SupplierValidator.java">SupplierValidator.java</a>
+        </ul>
+        </p>
+        Sources: <a href="Validator/src/">Validator/src/</a>
+</ul>
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/BulkDataOperations/index.html	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Bulk Data Operations Demo</title>
+</head>
+<body>
+<h2>Bulk Data Operations Demo</h2>
+
+<p>
+    This demo shows how to use bulk data operations with the new JDK8
+    Collections API.
+    The demo also demonstrates new features of JDK8 such as lambda expressions
+    and method/constructor references.
+</p>
+
+<ul>
+    <li><h3>CSV Processor</h3>
+
+        <p>
+            Analyzes a CSV file, finds and collects useful information, computes
+            different statistics. For more information, see the source file.
+        </p>
+        Source: <a href="src/CSVProcessor.java">src/CSVProcessor.java</a>
+    <li><h3>Grep</h3>
+
+        <p>
+            Behaves like the standard Linux tool Grep. For more information, see
+            the source file.
+        </p>
+        Source: <a href="src/Grep.java">src/Grep.java</a>
+    <li><h3>PasswordGenerator</h3>
+
+        <p>
+            Produces a password of desired length. For more information see
+            source file.
+        </p>
+        Source: <a
+                href="src/PasswordGenerator.java">src/PasswordGenerator.java</a>
+    <li><h3>WC</h3>
+
+        <p>
+            Counts newlines, words, characters, and the maximum line length of a
+            text file. For more information, see the source
+            file.
+        </p>
+        Source: <a href="src/WC.java">src/WC.java</a>
+</ul>
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/BulkDataOperations/src/CSVProcessor.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation, and proper error handling, might not be present in
+ * this sample code.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.function.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
+
+import static java.lang.Double.parseDouble;
+import static java.util.stream.Collectors.*;
+
+/**
+ * CSVProcessor is a tool for processing CSV files. There are several
+ * command-line options. Consult the {@link #printUsageAndExit} method for
+ * instructions and command line parameters. This sample shows examples of the
+ * following features:
+ * <ul>
+ * <li>Lambda and bulk operations. Working with streams: map(...), filter(...),
+ * sorted(...) methods. The collect(...) method with different collectors:
+ * Collectors.maxBy(...), Collectors.minBy(...), Collectors.toList(),
+ * Collectors.toCollection(...), Collectors.groupingBy(...),
+ * Collectors.toDoubleSummaryStatistics(...), and a custom Collector.</li>
+ * <li>Static method reference for printing values.</li>
+ * <li>Try-with-resources feature for closing files.</li>
+ * <li>Switch by String feature.</li>
+ * <li>Other new APIs: Pattern.asPredicate(), BinaryOperator
+ * BufferedReader.lines(), Collection.forEach(...), Comparator.comparing(...),
+ * Comparator.reversed(), Arrays.stream(...).</li>
+ * </ul>
+ *
+ */
+public class CSVProcessor {
+
+    //Number of characters that may be read
+    private static final int READ_AHEAD_LIMIT = 100_000_000;
+
+    /**
+     * The main method for the CSVProcessor program. Run the program with an
+     * empty argument list to see possible arguments.
+     *
+     * @param args the argument list for CSVProcessor.
+     */
+    public static void main(String[] args) {
+        if (args.length < 2) {
+            printUsageAndExit();
+        }
+        try (BufferedReader br = new BufferedReader(
+                Files.newBufferedReader(Paths.get(args[args.length - 1])))) {
+            //Assume that the first line contains column names.
+            List<String> header = Arrays.stream(br.readLine().split(","))
+                    .map(String::trim).collect(toList());
+            //Calculate an index of the column in question.
+            int column = getColumnNumber(header, args[1]);
+            switch (args[0]) {
+                case "sort":
+                    verifyArgumentNumber(args, 4);
+                    //Define the sort order.
+                    boolean isAsc;
+                    switch (args[2].toUpperCase()) {
+                        case "ASC":
+                            isAsc = true;
+                            break;
+                        case "DESC":
+                            isAsc = false;
+                            break;
+                        default:
+                            printUsageAndExit("Illegal argument" + args[2]);
+                            return;//Should not be reached.
+                    }
+                    /*
+                     * Create a comparator that compares lines by comparing
+                     * values in the specified column.
+                     */
+                    Comparator<String> cmp
+                            = Comparator.comparing(str -> getCell(str, column),
+                                    String.CASE_INSENSITIVE_ORDER);
+                    /*
+                     * sorted(...) is used to sort records.
+                     * forEach(...) is used to output sorted records.
+                     */
+                    br.lines().sorted(isAsc ? cmp : cmp.reversed())
+                            .forEach(System.out::println);
+                    break;
+                case "search":
+                    verifyArgumentNumber(args, 4);
+                    /*
+                     * Records are filtered by a regex.
+                     * forEach(...) is used to output filtered records.
+                     */
+                    Predicate<String> pattern
+                            = Pattern.compile(args[2]).asPredicate();
+                    br.lines().filter(str -> pattern.test(getCell(str, column)))
+                            .forEach(System.out::println);
+                    break;
+                case "groupby":
+                    verifyArgumentNumber(args, 3);
+                    /*
+                     * Group lines by values in the column with collect(...), and
+                     * print with forEach(...) for every distinct value within
+                     * the column.
+                     */
+                    br.lines().collect(
+                            Collectors.groupingBy(str -> getCell(str, column),
+                                    toCollection(TreeSet::new)))
+                            .forEach((str, set) -> {
+                                System.out.println(str + ":");
+                                set.forEach(System.out::println);
+                            });
+                    break;
+                case "stat":
+                    verifyArgumentNumber(args, 3);
+
+                    /*
+                     * BufferedReader will be read several times.
+                     * Mark this point to return here after each pass.
+                     * BufferedReader will be read right after the headers line
+                     * because it is already read.
+                     */
+                    br.mark(READ_AHEAD_LIMIT);
+
+                    /*
+                     * Statistics can be collected by a custom collector in one
+                     * pass. One pass is preferable.
+                     */
+                    System.out.println(
+                            br.lines().collect(new Statistics(column)));
+
+                    /*
+                     * Alternatively, statistics can be collected
+                     * by a built-in API in several passes.
+                     * This method demonstrates how separate operations can be
+                     * implemented using a built-in API.
+                     */
+                    br.reset();
+                    statInSeveralPasses(br, column);
+                    break;
+                default:
+                    printUsageAndExit("Illegal argument" + args[0]);
+            }
+        } catch (IOException e) {
+            printUsageAndExit(e.toString());
+        }
+    }
+
+    private static void statInSeveralPasses(BufferedReader br, int column)
+            throws IOException {
+        System.out.println("#-----Statistics in several passes-------#");
+        //Create a comparator to compare records by the column.
+        Comparator<String> comparator
+                = Comparator.comparing(
+                        (String str) -> parseDouble(getCell(str, column)));
+        //Find max record by using Collectors.maxBy(...)
+        System.out.println(
+                "Max: " + br.lines().collect(maxBy(comparator)).get());
+        br.reset();
+        //Find min record by using Collectors.minBy(...)
+        System.out.println(
+                "Min: " + br.lines().collect(minBy(comparator)).get());
+        br.reset();
+        //Compute the average value and sum with
+        //Collectors.toDoubleSummaryStatistics(...)
+        DoubleSummaryStatistics doubleSummaryStatistics
+                = br.lines().collect(summarizingDouble(
+                    str -> parseDouble(getCell(str, column))));
+        System.out.println("Average: " + doubleSummaryStatistics.getAverage());
+        System.out.println("Sum: " + doubleSummaryStatistics.getSum());
+    }
+
+    private static void verifyArgumentNumber(String[] args, int n) {
+        if (args.length != n) {
+            printUsageAndExit("Expected " + n + " arguments but was "
+                    + args.length);
+        }
+    }
+
+    private static int getColumnNumber(List<String> header, String name) {
+        int column = header.indexOf(name);
+        if (column == -1) {
+            printUsageAndExit("There is no column with name " + name);
+        }
+        return column;
+    }
+
+    private static String getCell(String record, int column) {
+        return record.split(",")[column].trim();
+    }
+
+    private static void printUsageAndExit(String... str) {
+        System.out.println("Usages:");
+
+        System.out.println("CSVProcessor sort COLUMN_NAME ASC|DESC FILE");
+        System.out.println("Sort lines by column COLUMN_NAME in CSV FILE\n");
+
+        System.out.println("CSVProcessor search COLUMN_NAME REGEX FILE");
+        System.out.println("Search for REGEX in column COLUMN_NAME in CSV FILE\n");
+
+        System.out.println("CSVProcessor groupby COLUMN_NAME FILE");
+        System.out.println("Split lines into different groups according to column "
+                + "COLUMN_NAME value\n");
+
+        System.out.println("CSVProcessor stat COLUMN_NAME FILE");
+        System.out.println("Compute max/min/average/sum  statistics by column "
+                + "COLUMN_NAME\n");
+
+        Arrays.asList(str).forEach(System.err::println);
+        System.exit(1);
+    }
+
+    /*
+     * This is a custom implementation of the Collector interface.
+     * Statistics are objects gather max,min,sum,average statistics.
+     */
+    private static class Statistics
+            implements Collector<String, Statistics, Statistics> {
+
+
+        /*
+         * This implementation does not need to be thread safe because
+         * the parallel implementation of
+         * {@link java.util.stream.Stream#collect Stream.collect()}
+         * provides the necessary partitioning and isolation for safe parallel
+         * execution.
+         */
+        private String maxRecord;
+        private String minRecord;
+
+        private double sum;
+        private int lineCount;
+        private final BinaryOperator<String> maxOperator;
+        private final BinaryOperator<String> minOperator;
+        private final int column;
+
+        public Statistics(int column) {
+            this.column = column;
+            Comparator<String> cmp = Comparator.comparing(
+                    (String str) -> parseDouble(getCell(str, column)));
+            maxOperator = BinaryOperator.maxBy(cmp);
+            minOperator = BinaryOperator.minBy(cmp);
+        }
+
+        /*
+         * Process line.
+         */
+        public Statistics accept(String line) {
+            maxRecord = maxRecord == null
+                    ? line : maxOperator.apply(maxRecord, line);
+            minRecord = minRecord == null
+                    ? line : minOperator.apply(minRecord, line);
+
+            sum += parseDouble(getCell(line, column));
+            lineCount++;
+            return this;
+        }
+
+
+        /*
+         * Merge two Statistics.
+         */
+        public Statistics combine(Statistics stat) {
+            maxRecord = maxOperator.apply(maxRecord, stat.getMaxRecord());
+            minRecord = minOperator.apply(minRecord, stat.getMinRecord());
+            sum += stat.getSum();
+            lineCount += stat.getLineCount();
+            return this;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("#------Statistics------#\n");
+            sb.append("Max: ").append(getMaxRecord()).append("\n");
+            sb.append("Min: ").append(getMinRecord()).append("\n");
+            sb.append("Sum = ").append(getSum()).append("\n");
+            sb.append("Average = ").append(average()).append("\n");
+            sb.append("#------Statistics------#\n");
+            return sb.toString();
+        }
+
+        @Override
+        public Supplier<Statistics> supplier() {
+            return () -> new Statistics(column);
+        }
+
+        @Override
+        public BiConsumer<Statistics, String> accumulator() {
+            return Statistics::accept;
+        }
+
+        @Override
+        public BinaryOperator<Statistics> combiner() {
+            return Statistics::combine;
+
+        }
+
+        @Override
+        public Function<Statistics, Statistics> finisher() {
+            return stat -> stat;
+        }
+
+        @Override
+        public Set<Characteristics> characteristics() {
+            return EnumSet.of(Characteristics.IDENTITY_FINISH);
+        }
+
+        private String getMaxRecord() {
+            return maxRecord;
+        }
+
+        private String getMinRecord() {
+            return minRecord;
+        }
+
+        private double getSum() {
+            return sum;
+        }
+
+        private double average() {
+            return sum / lineCount;
+        }
+
+        private int getLineCount() {
+            return lineCount;
+        }
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/BulkDataOperations/src/Grep.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation, and proper error handling, might not be present in
+ * this sample code.
+ */
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.stream.Stream;
+
+import static java.util.stream.Collectors.toList;
+
+/**
+ * Grep prints lines matching a regex. See {@link #printUsageAndExit(String...)}
+ * method for instructions and command line parameters. This sample shows
+ * examples of using next features:
+ * <ul>
+ * <li>Lambda and bulk operations. Working with streams:
+ * map(...),filter(...),flatMap(...),limit(...) methods.</li>
+ * <li>Static method reference for printing values.</li>
+ * <li>New Collections API forEach(...) method.</li>
+ * <li>Try-with-resources feature.</li>
+ * <li>new Files.walk(...), Files.lines(...) API.</li>
+ * <li>Streams that need to be closed.</li>
+ * </ul>
+ *
+ */
+public class Grep {
+
+    private static void printUsageAndExit(String... str) {
+        System.out.println("Usage: " + Grep.class.getSimpleName()
+                + " [OPTION]... PATTERN FILE...");
+        System.out.println("Search for PATTERN in each FILE. "
+                + "If FILE is a directory then whole file tree of the directory"
+                + " will be processed.");
+        System.out.println("Example: grep -m 100 'hello world' menu.h main.c");
+        System.out.println("Options:");
+        System.out.println("    -m NUM: stop analysis after NUM matches");
+        Arrays.asList(str).forEach(System.err::println);
+        System.exit(1);
+    }
+
+    /**
+     * The main method for the Grep program. Run program with empty argument
+     * list to see possible arguments.
+     *
+     * @param args the argument list for Grep.
+     * @throws java.io.IOException If an I/O error occurs.
+     */
+    public static void main(String[] args) throws IOException {
+        long maxCount = Long.MAX_VALUE;
+        if (args.length < 2) {
+            printUsageAndExit();
+        }
+        int i = 0;
+        //parse OPTIONS
+        while (args[i].startsWith("-")) {
+            switch (args[i]) {
+                case "-m":
+                    try {
+                        maxCount = Long.parseLong(args[++i]);
+                    } catch (NumberFormatException ex) {
+                        printUsageAndExit(ex.toString());
+                    }
+                    break;
+                default:
+                    printUsageAndExit("Unexpected option " + args[i]);
+            }
+            i++;
+        }
+        //parse PATTERN
+        Pattern pattern = Pattern.compile(args[i++]);
+        if (i == args.length) {
+            printUsageAndExit("There are no files for input");
+        }
+
+        try {
+            /*
+            * First obtain the list of all paths.
+            * For a small number of arguments there is little to be gained
+            * by producing this list in parallel. For one argument
+            * there will be no parallelism.
+            *
+            * File names are converted to paths. If a path is a directory then
+            * Stream is populated with whole file tree of the directory by
+            * flatMap() method. Files are filtered from directories.
+            */
+            List<Path> files = Arrays.stream(args, i, args.length)
+                    .map(Paths::get)
+                    // flatMap will ensure each I/O-based stream will be closed
+                    .flatMap(Grep::getPathStream)
+                    .filter(Files::isRegularFile)
+                    .collect(toList());
+            /*
+            * Then operate on that list in parallel.
+            * This is likely to give a more even distribution of work for
+            * parallel execution.
+            *
+            * Lines are extracted from files. Lines are filtered by pattern.
+            * Stream is limited by number of matches. Each remaining string is
+            * displayed in std output by method reference System.out::println.
+            */
+            files.parallelStream()
+                    // flatMap will ensure each I/O-based stream will be closed
+                    .flatMap(Grep::path2Lines)
+                    .filter(pattern.asPredicate())
+                    .limit(maxCount)
+                    .forEachOrdered(System.out::println);
+        } catch (UncheckedIOException ioe) {
+            printUsageAndExit(ioe.toString());
+        }
+    }
+
+    /**
+     * Flattens file system hierarchy into a stream. This code is not inlined
+     * for the reason of Files.walk() throwing a checked IOException that must
+     * be caught.
+     *
+     * @param path - the file or directory
+     * @return Whole file tree starting from path, a stream with one element -
+     * the path itself - if it is a file.
+     */
+    private static Stream<Path> getPathStream(Path path) {
+        try {
+            return Files.walk(path);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
+    /**
+     * Produces a stream of lines from a file. The result is a stream in order
+     * to close it later. This code is not inlined for the reason of
+     * Files.lines() throwing a checked IOException that must be caught.
+     *
+     * @param path - the file to read
+     * @return stream of lines from the file
+     */
+    private static Stream<String> path2Lines(Path path) {
+        try {
+            return Files.lines(path);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/BulkDataOperations/src/PasswordGenerator.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation, and proper error handling, might not be present in
+ * this sample code.
+ */
+
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.IntStream;
+
+/**
+ * Generates password of desired length. See {@link #usage} method
+ * for instructions and command line parameters. This sample shows usages of:
+ * <ul>
+ * <li>Method references.</li>
+ * <li>Lambda and bulk operations. A stream of random integers is mapped to
+ * chars, limited by desired length and printed in standard output as password
+ * string.</li>
+ * </ul>
+ *
+ */
+public class PasswordGenerator {
+
+    private static void usage() {
+        System.out.println("Usage: PasswordGenerator LENGTH");
+        System.out.println(
+                "Password Generator produces password of desired LENGTH.");
+    }
+
+    private static final List<Integer> PASSWORD_CHARS = new ArrayList<>();
+
+    //Valid symbols.
+    static {
+        IntStream.rangeClosed('0', '9').forEach(PASSWORD_CHARS::add);    // 0-9
+        IntStream.rangeClosed('A', 'Z').forEach(PASSWORD_CHARS::add);    // A-Z
+        IntStream.rangeClosed('a', 'z').forEach(PASSWORD_CHARS::add);    // a-z
+    }
+
+    /**
+     * The main method for the PasswordGenerator program. Run program with empty
+     * argument list to see possible arguments.
+     *
+     * @param args the argument list for PasswordGenerator.
+     */
+    public static void main(String[] args) {
+
+        if (args.length != 1) {
+            usage();
+            return;
+        }
+
+        long passwordLength;
+        try {
+            passwordLength = Long.parseLong(args[0]);
+            if (passwordLength < 1) {
+                printMessageAndUsage("Length has to be positive");
+                return;
+            }
+        } catch (NumberFormatException ex) {
+            printMessageAndUsage("Unexpected number format" + args[0]);
+            return;
+        }
+        /*
+         * Stream of random integers is created containing Integer values
+         * in range from 0 to PASSWORD_CHARS.size().
+         * The stream is limited by passwordLength.
+         * Valid chars are selected by generated index.
+         */
+        new SecureRandom().ints(passwordLength, 0, PASSWORD_CHARS.size())
+                .map(PASSWORD_CHARS::get)
+                .forEach(i -> System.out.print((char) i));
+    }
+
+    private static void printMessageAndUsage(String message) {
+        System.err.println(message);
+        usage();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/BulkDataOperations/src/WC.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation, and proper error handling, might not be present in
+ * this sample code.
+ */
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.function.Consumer;
+import java.util.regex.Pattern;
+
+/**
+ * WC - Prints newline, word, and character counts for each file. See
+ * the {@link #usage} method for instructions and command line parameters. This
+ * sample shows usages of:
+ * <ul>
+ * <li>Lambda and bulk operations. Shows how to create a custom collector to
+ * gather custom statistics. Implements the collection of statistics using a
+ * built-in API.</li>
+ * <li>Constructor reference.</li>
+ * <li>Try-with-resources feature.</li>
+ * </ul>
+ *
+ */
+public class WC {
+
+    //The number of characters that may be read.
+    private static final int READ_AHEAD_LIMIT = 100_000_000;
+
+    //The pattern for splitting strings by non word characters to get words.
+    private static final Pattern nonWordPattern = Pattern.compile("\\W");
+
+    /**
+     * The main method for the WC program. Run the program with an empty
+     * argument list to see possible arguments.
+     *
+     * @param args the argument list for WC
+     * @throws java.io.IOException If an input exception occurred.
+     */
+    public static void main(String[] args) throws IOException {
+
+        if (args.length != 1) {
+            usage();
+            return;
+        }
+
+        try (BufferedReader reader = new BufferedReader(
+                new FileReader(args[0]))) {
+            reader.mark(READ_AHEAD_LIMIT);
+            /*
+             * Statistics can be gathered in four passes using a built-in API.
+             * The method demonstrates how separate operations can be
+             * implemented using a built-in API.
+             */
+            collectInFourPasses(reader);
+            /*
+             * Usage of several passes to collect data is not the best way.
+             * Statistics can be gathered by a custom collector in one pass.
+             */
+            reader.reset();
+            collectInOnePass(reader);
+        } catch (FileNotFoundException e) {
+            usage();
+            System.err.println(e);
+        }
+    }
+
+    private static void collectInFourPasses(BufferedReader reader)
+            throws IOException {
+        /*
+         * Input is read as a stream of lines by lines().
+         * Every line is turned into a stream of chars by the flatMapToInt(...)
+         * method.
+         * Length of the stream is counted by count().
+         */
+        System.out.println("Character count = "
+                + reader.lines().flatMapToInt(String::chars).count());
+        /*
+         * Input is read as a stream of lines by lines().
+         * Every line is split by nonWordPattern into words by flatMap(...)
+         * method.
+         * Empty lines are removed by the filter(...) method.
+         * Length of the stream is counted by count().
+         */
+        reader.reset();
+        System.out.println("Word count = "
+                + reader.lines()
+                .flatMap(nonWordPattern::splitAsStream)
+                .filter(str -> !str.isEmpty()).count());
+
+        reader.reset();
+        System.out.println("Newline count = " + reader.lines().count());
+        /*
+         * Input is read as a stream of lines by lines().
+         * Every line is mapped to its length.
+         * Maximum of the lengths is calculated.
+         */
+        reader.reset();
+        System.out.println("Max line length = "
+                + reader.lines().mapToInt(String::length).max().getAsInt());
+    }
+
+    private static void collectInOnePass(BufferedReader reader) {
+        /*
+         * The collect() method has three parameters:
+         * The first parameter is the {@code WCStatistic} constructor reference.
+         * collect() will create {@code WCStatistics} instances, where
+         * statistics will be aggregated.
+         * The second parameter shows how {@code WCStatistics} will process
+         * String.
+         * The third parameter shows how to merge two {@code WCStatistic}
+         * instances.
+         *
+         * Also {@code Collector} can be used, which would be more reusable
+         * solution. See {@code CSVProcessor} example for how {@code Collector}
+         * can be implemented.
+         *
+         * Note that the any performance increase when going parallel will
+         * depend on the size of the input (lines) and the cost per-element.
+         */
+        WCStatistics wc = reader.lines().parallel()
+                .collect(WCStatistics::new,
+                        WCStatistics::accept,
+                        WCStatistics::combine);
+        System.out.println(wc);
+    }
+
+    private static void usage() {
+        System.out.println("Usage: " + WC.class.getSimpleName() + " FILE");
+        System.out.println("Print newline, word,"
+                + "  character counts and max line length for FILE.");
+    }
+
+    private static class WCStatistics implements Consumer<String> {
+        /*
+         * @implNote This implementation does not need to be thread safe because
+         * the parallel implementation of
+         * {@link java.util.stream.Stream#collect Stream.collect()}
+         * provides the necessary partitioning and isolation for safe parallel
+         * execution.
+         */
+
+        private long characterCount;
+        private long lineCount;
+        private long wordCount;
+        private long maxLineLength;
+
+
+        /*
+         * Processes line.
+         */
+        @Override
+        public void accept(String line) {
+            characterCount += line.length();
+            lineCount++;
+            wordCount += nonWordPattern.splitAsStream(line)
+                    .filter(str -> !str.isEmpty()).count();
+            maxLineLength = Math.max(maxLineLength, line.length());
+        }
+
+        /*
+         * Merges two WCStatistics.
+         */
+        public void combine(WCStatistics stat) {
+            wordCount += stat.wordCount;
+            lineCount += stat.lineCount;
+            characterCount += stat.characterCount;
+            maxLineLength = Math.max(maxLineLength, stat.maxLineLength);
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("#------WCStatistic------#\n");
+            sb.append("Character count = ").append(characterCount).append('\n');
+            sb.append("Word count = ").append(wordCount).append('\n');
+            sb.append("Newline count = ").append(lineCount).append('\n');
+            sb.append("Max line length = ").append(maxLineLength).append('\n');
+            return sb.toString();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/DefaultMethods/ArrayIterator.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * The code sample illustrates the usage of default methods in the JDK 8. Most
+ * implementations of {@link Iterator} don't provide a useful
+ * {@link Iterator#remove()} method, however,
+ * they still have to implement this method to throw
+ * an UnsupportedOperationException. With the default method, the same
+ * default behavior in interface Iterator itself can be provided.
+ */
+public class ArrayIterator {
+
+    /** Close the constructor because ArrayIterator is part of the utility
+     * class.
+     */
+    protected ArrayIterator() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns an iterator that goes over the elements in the array.
+     *
+     * @param <E> type of an array element
+     * @param array source array to iterate over it
+     * @return an iterator that goes over the elements in the array
+     */
+    public static <E> Iterator<E> iterator(final E[] array) {
+        return new Iterator<E>() {
+            /**
+             * Index of the current position
+             *
+             */
+            private int index = 0;
+
+            /**
+             * Returns the next element in the iteration
+             *
+             * @return the next element in the iteration
+             * @throws NoSuchElementException if the iteration has no more
+             * elements
+             */
+            @Override
+            public boolean hasNext() {
+                return (index < array.length);
+            }
+
+            /**
+             * Returns {@code true} if the iteration has more elements. (In
+             * other words, returns {@code true} if {@link #next} returns
+             * an element, rather than throwing an exception.)
+             *
+             * @return {@code true} if the iteration has more elements
+             */
+            @Override
+            public E next() {
+                if (!hasNext()) {
+                    throw new NoSuchElementException();
+                }
+                return array[index++];
+            }
+
+            /**
+             * This method does not need to be overwritten in JDK 8.
+             */
+            //@Override
+            //public void remove() {
+            //    throw UnsupportedOperationException(
+            //            "Arrays don't support remove.")
+            //}
+        };
+    }
+
+    /**
+     * Sample usage of the ArrayIterator
+     *
+     * @param args command-line arguments
+     */
+    public static void main(final String[] args) {
+        Iterator<String> it = ArrayIterator.iterator(
+                new String[]{"one", "two", "three"});
+
+        while (it.hasNext()) {
+            System.out.println(it.next());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/DefaultMethods/DiamondInheritance.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * This sample diamond interface inheritance with <b>default methods</b>.
+ * If there's not already a unique method implementation to inherit,
+ * you must provide it. The inheritance diagram is similar to the following:
+ * <pre>
+ *                   Animal
+ *                    /   \
+ *                 Horse   Bird
+ *                    \   /
+ *                   Pegasus
+ * </pre>
+ *
+ * Both {@link Horse} and {@link Bird} interfaces implements the <code>go</code>
+ * method. The {@link Pegasus} class have to overrides the
+ * <code>go</code> method.
+ *
+ * The new syntax of super-call is used here:
+ * <pre>
+ *     &lt;interface_name&gt;.super.&lt;method&gt;(...);
+ *     For example:  Horse.super.go();
+ * </pre> So, Pegasus moves like a horse.
+ */
+public class DiamondInheritance {
+
+    /**
+     * Base interface to illustrate the diamond inheritance.
+     *
+     * @see DiamondInheritance
+     */
+    public interface Animal {
+
+        /**
+         * Return string representation of the "go" action for concrete animal
+         *
+         * @return string representation of the "go" action for concrete animal
+         */
+        String go();
+    }
+
+    /**
+     * Interface to illustrate the diamond inheritance.
+     *
+     * @see DiamondInheritance
+     */
+    public interface Horse extends Animal {
+
+        /**
+         * Return string representation of the "go" action for horse
+         *
+         * @return string representation of the "go" action for horse
+         */
+        @Override
+        default String go() {
+            return this.getClass().getSimpleName() + " walks on four legs";
+        }
+    }
+
+    /**
+     * Interface to illustrate the diamond inheritance.
+     *
+     * @see DiamondInheritance
+     */
+    public interface Bird extends Animal {
+
+        /**
+         * Return string representation of the "go" action for bird
+         *
+         * @return string representation of the "go" action for bird
+         */
+        @Override
+        default String go() {
+            return this.getClass().getSimpleName() + " walks on two legs";
+        }
+
+        /**
+         * Return string representation of the "fly" action for bird
+         *
+         * @return string representation of the "fly" action for bird
+         */
+        default String fly() {
+            return "I can fly";
+        }
+    }
+
+    /**
+     * Class to illustrate the diamond inheritance. Pegasus must mix horse and
+     * bird behavior.
+     *
+     * @see DiamondInheritance
+     */
+    public static class Pegasus implements Horse, Bird {
+
+        /**
+         * Return string representation of the "go" action for the fictitious
+         * creature Pegasus
+         *
+         * @return string representation of the "go" action for the fictitious
+         * creature Pegasus
+         */
+        @Override
+        public String go() {
+            return Horse.super.go();
+        }
+    }
+
+    /**
+     * Illustrate the behavior of the {@link Pegasus} class
+     *
+     * @param args command line arguments
+     */
+    public static void main(final String[] args) {
+        System.out.println(new Pegasus().go());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/DefaultMethods/Inheritance.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * The sample illustrates rules to resolve conflicts between inheritance
+ * candidates with <b>default methods</b>. There are two simple rules:
+ * <ul>
+ * <li>Class wins. If the superclass has a concrete or abstract declaration of
+ * this method, then it is preferred over all defaults.</li>
+ * <li>Subtype wins. If an interface extends another interface, and both provide
+ * a default, then the more specific interface wins. </li>
+ * </ul>
+ */
+public class Inheritance {
+
+    /**
+     * The behavior of an creature that can swim
+     */
+    public interface Swimable {
+
+        /**
+         * Return string representation of the swim action for a creature that
+         * can swim
+         *
+         * @return string representation of the swim action for a creature
+         * that can swim
+         */
+        default String swim() {
+            return "I can swim.";
+        }
+    }
+
+    /**
+     * The abstract class that overrides {@link #swim} method
+     */
+    public abstract static class Fish implements Swimable {
+
+        /**
+         * Return string representation of the swim action for a fish
+         *
+         * @return string representation of the swim action for a fish
+         */
+        @Override
+        public String swim() {
+            return this.getClass().getSimpleName() + " swims under water";
+        }
+    }
+
+    /**
+     * This class is used for the illustration rule of 1. See the source code
+     * of the {@link #main} method.
+     * <pre>
+     *      System.out.println(new Tuna().swim()); //"Tuna swims under water" output is suspected here
+     * </pre>
+     */
+    public static class Tuna extends Fish implements Swimable {
+    }
+
+    /**
+     * The behavior of an creature that can dive: the interface that overrides
+     * {@link #swim} method (subtype of {@link Swimable})
+     */
+    public interface Diveable extends Swimable {
+
+        /**
+         * Return string representation of the swim action for a creature that
+         * can dive
+         *
+         * @return string representation of the swim action for a creature
+         * that can dive
+         */
+        @Override
+        default String swim() {
+            return "I can swim on the surface of the water.";
+        }
+
+        /**
+         * Return string representation of the dive action for a creature that
+         * can dive
+         *
+         * @return string representation of the dive action for a creature
+         * that can dive
+         */
+        default String dive() {
+            return "I can dive.";
+        }
+    }
+
+    /**
+     * This class is used for the illustration of rule 2. See the source code
+     * of the {@link #main} method
+     * <pre>
+     *      //"I can swim on the surface of the water." output is suspected here
+     *      System.out.println(new Duck().swim());
+     * </pre>
+     */
+    public static class Duck implements Swimable, Diveable {
+    }
+
+    /**
+     * Illustrate behavior of the classes: {@link Tuna} and {@link Duck}
+     *
+     * @param args command line arguments
+     */
+    public static void main(final String[] args) {
+        // Illustrates rule 1. The Fish.swim() implementation wins
+        //"Tuna swims under water" is output
+        System.out.println(new Tuna().swim());
+
+        // Illustrates rule 2. The Diveable.swim() implementation wins
+        //"I can swim on the surface of the water." is output
+        System.out.println(new Duck().swim());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/DefaultMethods/MixIn.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+/**
+ * The example illustrates how to use the default method for mixin.
+ * @see BuildType
+ * @see Debuggable
+ */
+public class MixIn {
+
+    /**
+     * Implement this interface for a class that must be in debug print
+     */
+    public interface Debuggable {
+
+        /**
+         * Print the class name and all fields to a string. Uses reflection to
+         * obtain and access fields of this object.
+         *
+         * @return the string formatted like the following: <pre>
+         * State of the: &lt;Class Name&gt;
+         * &lt;member name&gt; : &lt;value&gt;
+         * ...
+         * </pre>
+         */
+        default String toDebugString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("State of the: ").append(
+                    this.getClass().getSimpleName()).append("\n");
+            for (Class cls = this.getClass();
+                    cls != null;
+                    cls = cls.getSuperclass()) {
+                for (Field f : cls.getDeclaredFields()) {
+                    try {
+                        f.setAccessible(true);
+                        sb.append(f.getName()).append(" : ").
+                                append(f.get(this)).append("\n");
+                    } catch (IllegalAccessException e) {
+                    }
+                }
+            }
+            return sb.toString();
+        }
+    }
+
+    /**
+     * Sample exception class to demonstrate mixin. This enum inherits the
+     * behavior of the {@link Debuggable}
+     */
+    public static enum BuildType implements Debuggable {
+
+        BUILD(0, "-build"),
+        PLAN(0, "-plan"),
+        EXCLUDE(1, "-exclude"),
+        TOTAL(2, "-total");
+
+        private final int compareOrder;
+        private final String pathSuffix;
+
+        private BuildType(int compareOrder, String pathSuffix) {
+            this.compareOrder = compareOrder;
+            this.pathSuffix = pathSuffix;
+        }
+
+        public int getCompareOrder() {
+            return compareOrder;
+        }
+
+        public String getPathSuffix() {
+            return pathSuffix;
+        }
+    }
+
+    /**
+     * Illustrate the behavior of the MixClass
+     *
+     * @param args command-line arguments
+     * @throws java.io.IOException internal demo error
+     */
+    public static void main(final String[] args) throws IOException {
+        System.out.println(BuildType.BUILD.toDebugString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/DefaultMethods/Reflection.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+/**
+ * The code sample illustrates changes in the reflection API linked
+ * <b>default methods</b>. Since Java SE 8, a new method is added into the class
+ * <b><code>java.lang.reflect.Method</code></b>, with which you can reflectively
+ * determine whether or not a default method provided by an interface
+ * (<b><code>Method.isDefault()</code></b>).
+ */
+public class Reflection {
+
+    /**
+     * Base interface to illustrate the new reflection API.
+     *
+     * @see Dog
+     */
+    public interface Animal {
+
+        /**
+         * Return string representation of the eat action for Animal
+         *
+         * @return string representation of the eat action for Animal
+         */
+        default String eat() {
+            return this.getClass().getSimpleName()
+                    + " eats like an ordinary animal";
+        }
+
+        /**
+         * Return string representation of the sleep action for Animal
+         *
+         * @return string representation of the sleep action for Animal
+         */
+        default String sleep() {
+            return this.getClass().getSimpleName()
+                    + " sleeps like an ordinary animal";
+        }
+
+        /**
+         * Return string representation of the go action for Animal
+         *
+         * @return string representation of the go action for Animal
+         */
+        String go();
+    }
+
+    /**
+     * Dog class to illustrate the new reflection API. You can see that:
+     * <ul>
+     * <li> the {@link #go} and {@link #sleep} methods are not default.
+     * {@link #go} is not the default implementation and the {@link #sleep}
+     * method implementation wins as subtype (according with {@link Inheritance}
+     * rule. 2) </li>
+     * <li> the {@link #eat} is a simple default method that is not overridden
+     * in this class.
+     * </li>
+     * </ul>
+     */
+    public static class Dog implements Animal {
+
+        /**
+         * Return string representation of the go action for Dog
+         *
+         * @return string representation of the go action for Dog
+         */
+        @Override
+        public String go() {
+            return "Dog walks on four legs";
+        }
+
+        /**
+         * Return string representation of the sleep action for Dog
+         *
+         * @return string representation of the sleep action for Dog
+         */
+        @Override
+        public String sleep() {
+            return "Dog sleeps";
+        }
+    }
+
+    /**
+     * Illustrate the usage of the method java.lang.reflect.Method.isDefault()
+     *
+     * @param args command-line arguments
+     * @throws NoSuchMethodException internal demo error
+     */
+    public static void main(final String[] args) throws NoSuchMethodException {
+        Dog dog = new Dog();
+        Stream.of(Dog.class.getMethod("eat"), Dog.class.getMethod("go"), Dog.class.getMethod("sleep"))
+                .forEach((m) -> {
+                    System.out.println("Method name:   " + m.getName());
+                    System.out.println("    isDefault: " + m.isDefault());
+                    System.out.print("    invoke:    ");
+                    try {
+                        m.invoke(dog);
+                    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+                    }
+                    System.out.println();
+                });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/lambda/DefaultMethods/SimplestUsage.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * The sample illustrates the simplest use case of the <b>default methods</b>.
+ */
+public class SimplestUsage {
+
+    /**
+     * The Animal interface provides the default implementation
+     * of the {@link #eat} method.
+     */
+    public interface Animal {
+
+        /**
+         * Return string representation of the eat action for Animal
+         *
+         * @return string representation of the eat action for Animal
+         */
+        default String eat() {
+            return this.getClass().getSimpleName()
+                    + " eats like an ordinary animal";
+        }
+    }
+
+    /**
+     * The Dog class doesn't have its own implementation of the {@link #eat}
+     * method and uses the default implementation.
+     */
+    public static class Dog implements Animal {
+    }
+
+    /**
+     * The Mosquito class implements {@link #eat} method, its own implementation
+     * overrides the default implementation.
+     *
+     */
+    public static class Mosquito implements Animal {
+
+        /**
+         * Return string representation of the eat action for Mosquito
+         *
+         * @return string representation of the eat action for Mosquito
+         */
+        @Override
+        public String eat() {
+            return "Mosquito consumes blood";
+        }
+    }
+
+    /**
+     * Illustrate behavior of the classes: {@link Dog} and {@link Mosquito}
+     *
+     * @param args command-line arguments
+     */
+    public static void main(String[] args) {
+        // "Dog eats like an ordinary animal" is output
+        System.out.println(new Dog().eat());
+
+        // "Mosquito consumes blood" is output
+        System.out.println(new Mosquito().eat());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/try-with-resources/index.html	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <title>Try-with-Resources Feature Demo</title>
+</head>
+<body>
+<h2>Try-with-Resources Feature Demo</h2>
+
+<p>
+    This demo shows how to use the try-with-resources feature introduced in JDK7.
+</p>
+
+<ul>
+    <li><h3>Custom AutoCloseable.</h3>
+
+        <p>
+            Shows how to use a custom resource with the try-with-resources construct.
+            For more information, see the source file.
+        </p>
+        Source: <a href="src/CustomAutoCloseableSample.java">src/CustomAutoCloseableSample.java</a>
+
+    <li><h3>Unzip</h3>
+
+        <p>
+            Extracts archived files. For more information, see the source file.
+        </p>
+        Source: <a href="src/Unzip.java">src/Unzip.java</a>
+    <li><h3>ZipCat</h3>
+
+        <p>Prints data about a specified file from an archive. For more information, see the source file.</p>
+        Source: <a href="src/ZipCat.java">src/ZipCat.java</a>
+
+</ul>
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/try-with-resources/src/CustomAutoCloseableSample.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation, and proper error handling, might not be present in
+ * this sample code.
+ */
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * This sample demonstrates the ability to create custom resource that
+ * implements the {@code AutoCloseable} interface. This resource can be used in
+ * the try-with-resources construct.
+ */
+public class CustomAutoCloseableSample {
+
+    /**
+     * The main method for the CustomAutoCloseableSample program.
+     *
+     * @param args is not used.
+     */
+    public static void main(String[] args) {
+        /*
+         * TeeStream will be closed automatically after the try block.
+         */
+        try (TeeStream teeStream = new TeeStream(System.out, Paths.get("out.txt"));
+             PrintStream out = new PrintStream(teeStream)) {
+            out.print("Hello, world");
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+    /**
+     * Passes the output through to the specified output stream while copying it into a file.
+     * The TeeStream functionality is similar to the Unix tee utility.
+     * TeeStream implements AutoCloseable interface. See OutputStream for details.
+     */
+    public static class TeeStream extends OutputStream {
+
+        private final OutputStream fileStream;
+        private final OutputStream outputStream;
+
+        /**
+         * Creates a TeeStream.
+         *
+         * @param outputStream an output stream.
+         * @param outputFile   an path to file.
+         * @throws IOException If an I/O error occurs.
+         */
+        public TeeStream(OutputStream outputStream, Path outputFile) throws IOException {
+            this.fileStream = new BufferedOutputStream(Files.newOutputStream(outputFile));
+            this.outputStream = outputStream;
+        }
+
+        /**
+         * Writes the specified byte to the specified output stream
+         * and copies it to the file.
+         *
+         * @param b the byte to be written.
+         * @throws IOException If an I/O error occurs.
+         */
+        @Override
+        public void write(int b) throws IOException {
+            fileStream.write(b);
+            outputStream.write(b);
+        }
+
+        /**
+         * Flushes this output stream and forces any buffered output bytes
+         * to be written out.
+         * The <code>flush</code> method of <code>TeeStream</code> flushes
+         * the specified output stream and the file output stream.
+         *
+         * @throws IOException if an I/O error occurs.
+         */
+        @Override
+        public void flush() throws IOException {
+            outputStream.flush();
+            fileStream.flush();
+        }
+
+        /**
+         * Closes underlying streams and resources.
+         * The external output stream won't be closed.
+         * This method is the member of AutoCloseable interface and
+         * it will be invoked automatically after the try-with-resources block.
+         *
+         * @throws IOException If an I/O error occurs.
+         */
+        @Override
+        public void close() throws IOException {
+            try (OutputStream file = fileStream) {
+                flush();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/try-with-resources/src/Unzip.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation, and proper error handling, might not be present in
+ * this sample code.
+ */
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.*;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+/**
+ * Extract (unzip) a file to the current directory.
+ */
+public class Unzip {
+
+    /**
+     * The main method for the Unzip program. Run the program with an empty
+     * argument list to see possible arguments.
+     *
+     * @param args the argument list for {@code Unzip}.
+     */
+    public static void main(String[] args) {
+        if (args.length != 1) {
+            System.out.println("Usage: Unzip zipfile");
+        }
+        final Path destDir = Paths.get(".");
+        /*
+         * Create AutoCloseable FileSystem. It will be closed automatically
+         * after the try block.
+         */
+        try (FileSystem zipFileSystem = FileSystems.newFileSystem(Paths.get(args[0]), null)) {
+
+            Path top = zipFileSystem.getPath("/");
+            Files.walk(top).skip(1).forEach(file -> {
+                Path target = destDir.resolve(top.relativize(file).toString());
+                System.out.println("Extracting " + target);
+                try {
+                    Files.copy(file, target, REPLACE_EXISTING);
+                } catch (IOException e) {
+                    throw new UncheckedIOException(e);
+                }
+            });
+        } catch (UncheckedIOException | IOException e) {
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/sample/try-with-resources/src/ZipCat.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This source code is provided to illustrate the usage of a given feature
+ * or technique and has been deliberately simplified. Additional steps
+ * required for a production-quality application, such as security checks,
+ * input validation, and proper error handling, might not be present in
+ * this sample code.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+/**
+ * Prints data of the specified file to standard output from a zip archive.
+ */
+public class ZipCat {
+
+    /**
+     * The main method for the ZipCat program. Run the program with an empty
+     * argument list to see possible arguments.
+     *
+     * @param args the argument list for ZipCat
+     */
+    public static void main(String[] args) {
+        if (args.length != 2) {
+            System.out.println("Usage: ZipCat zipfile fileToPrint");
+        }
+        /*
+         * Creates AutoCloseable FileSystem and BufferedReader.
+         * They will be closed automatically after the try block.
+         * If reader initialization fails, then zipFileSystem will be closed
+         * automatically.
+         */
+        try (FileSystem zipFileSystem
+                = FileSystems.newFileSystem(Paths.get(args[0]),null);
+                InputStream input
+                = Files.newInputStream(zipFileSystem.getPath(args[1]))) {
+                    byte[] buffer = new byte[1024];
+                    int len;
+                    while ((len = input.read(buffer)) != -1) {
+                        System.out.write(buffer, 0, len);
+                    }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+}
--- a/src/solaris/classes/sun/print/CUPSPrinter.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/solaris/classes/sun/print/CUPSPrinter.java	Wed Feb 26 07:43:38 2014 +0400
@@ -252,6 +252,7 @@
                             try {
                                 return urlConnection.getOutputStream();
                             } catch (Exception e) {
+                               IPPPrintService.debug_println(debugPrefix+e);
                             }
                             return null;
                         }
@@ -282,6 +283,9 @@
 
                     if (responseMap != null && responseMap.length > 0) {
                         defaultMap = responseMap[0];
+                    } else {
+                       IPPPrintService.debug_println(debugPrefix+
+                           " empty response map for GET_DEFAULT.");
                     }
 
                     if (defaultMap == null) {
@@ -310,7 +314,10 @@
 
                     if (attribClass != null) {
                         printerInfo[0] = attribClass.getStringValue();
-                        attribClass = (AttributeClass)defaultMap.get("device-uri");
+                        attribClass = (AttributeClass)
+                            defaultMap.get("printer-uri-supported");
+                        IPPPrintService.debug_println(debugPrefix+
+                          "printer-uri-supported="+attribClass);
                         if (attribClass != null) {
                             printerInfo[1] = attribClass.getStringValue();
                         } else {
--- a/src/solaris/classes/sun/print/IPPPrintService.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/solaris/classes/sun/print/IPPPrintService.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1906,9 +1906,8 @@
                                   new HashMap[respList.size()]);
             } else {
                 debug_println(debugPrefix+
-                              "readIPPResponse client error, IPP status code-"
-                                   +Integer.toHexString(response[2])+" & "
-                                   +Integer.toHexString(response[3]));
+                          "readIPPResponse client error, IPP status code: 0x"+
+                          toHex(response[2]) + toHex(response[3]));
                 return null;
             }
 
@@ -1921,6 +1920,10 @@
         }
     }
 
+    private static String toHex(byte v) {
+        String s = Integer.toHexString(v&0xff);
+        return (s.length() == 2) ? s :  "0"+s;
+    }
 
     public String toString() {
         return "IPP Printer : " + getName();
--- a/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	Wed Feb 26 07:43:38 2014 +0400
@@ -238,9 +238,25 @@
         String[] printers = null; // array of printer names
         String[] printerURIs = null; //array of printer URIs
 
-        getDefaultPrintService();
+        try {
+            getDefaultPrintService();
+        } catch (Throwable t) {
+            IPPPrintService.debug_println(debugPrefix+
+              "Exception getting default printer : " + t);
+        }
         if (CUPSPrinter.isCupsRunning()) {
-            printerURIs = CUPSPrinter.getAllPrinters();
+            try {
+                printerURIs = CUPSPrinter.getAllPrinters();
+                IPPPrintService.debug_println("CUPS URIs = " + printerURIs);
+                if (printerURIs != null) {
+                    for (int p = 0; p < printerURIs.length; p++) {
+                       IPPPrintService.debug_println("URI="+printerURIs[p]);
+                    }
+                }
+            } catch (Throwable t) {
+            IPPPrintService.debug_println(debugPrefix+
+              "Exception getting all CUPS printers : " + t);
+            }
             if ((printerURIs != null) && (printerURIs.length > 0)) {
                 printers = new String[printerURIs.length];
                 for (int i=0; i<printerURIs.length; i++) {
@@ -595,8 +611,10 @@
                                       (CUPSPrinter.isCupsRunning()));
         if (CUPSPrinter.isCupsRunning()) {
             String[] printerInfo = CUPSPrinter.getDefaultPrinter();
-            defaultPrinter = printerInfo[0];
-            psuri = printerInfo[1];
+            if (printerInfo != null && printerInfo.length >= 2) {
+                defaultPrinter = printerInfo[0];
+                psuri = printerInfo[1];
+            }
         } else {
             if (isMac() || isSysV()) {
                 defaultPrinter = getDefaultPrinterNameSysV();
--- a/src/windows/native/sun/security/krb5/NativeCreds.c	Tue Feb 18 16:38:13 2014 +0400
+++ b/src/windows/native/sun/security/krb5/NativeCreds.c	Wed Feb 26 07:43:38 2014 +0400
@@ -388,7 +388,7 @@
     jobject ticketFlags, startTime, endTime, krbCreds = NULL;
     jobject authTime, renewTillTime, hostAddresses = NULL;
     KERB_EXTERNAL_TICKET *msticket;
-    int found_in_cache = 0;
+    int found = 0;
     FILETIME Now, EndTime, LocalEndTime;
 
     int i, netypes;
@@ -476,7 +476,7 @@
             if (CompareFileTime(&Now, &LocalEndTime) < 0) {
                 for (i=0; i<netypes; i++) {
                     if (etypes[i] == msticket->SessionKey.KeyType) {
-                        found_in_cache = 1;
+                        found = 1;
                         if (native_debug) {
                             printf("LSA: Valid etype found: %d\n", etypes[i]);
                         }
@@ -486,7 +486,7 @@
             }
         }
 
-        if (!found_in_cache) {
+        if (!found) {
             if (native_debug) {
                 printf("LSA: MS TGT in cache is invalid/not supported; request new ticket\n");
             }
@@ -529,6 +529,14 @@
 
                 // got the native MS Kerberos TGT
                 msticket = &(pTicketResponse->Ticket);
+
+                if (msticket->SessionKey.KeyType != etypes[i]) {
+                    if (native_debug) {
+                        printf("LSA: Response etype is %d for %d. Retry.\n", msticket->SessionKey.KeyType, etypes[i]);
+                    }
+                    continue;
+                }
+                found = 1;
                 break;
             }
         }
@@ -583,6 +591,10 @@
         } KERB_CRYPTO_KEY, *PKERB_CRYPTO_KEY;
 
         */
+        if (!found) {
+            break;
+        }
+
         // Build a com.sun.security.krb5.Ticket
         ticket = BuildTicket(env, msticket->EncodedTicket,
                                 msticket->EncodedTicketSize);
--- a/test/com/sun/jdi/ExclusiveBind.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/com/sun/jdi/ExclusiveBind.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,57 +25,28 @@
  * @bug 4531526
  * @summary Test that more than one debuggee cannot bind to same port
  *          at the same time.
+ * @library /lib/testlibrary
  *
+ * @build jdk.testlibrary.ProcessTools jdk.testlibrary.JDKToolLauncher jdk.testlibrary.Utils
  * @build VMConnection ExclusiveBind HelloWorld
  * @run main ExclusiveBind
  */
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
 import java.net.ServerSocket;
 import com.sun.jdi.Bootstrap;
 import com.sun.jdi.VirtualMachine;
 import com.sun.jdi.connect.Connector;
 import com.sun.jdi.connect.AttachingConnector;
+
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.List;
 import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.Utils;
 
 public class ExclusiveBind {
-
-    /*
-     * Helper class to direct process output to the parent
-     * System.out
-     */
-    static class IOHandler implements Runnable {
-        InputStream in;
-
-        IOHandler(InputStream in) {
-            this.in = in;
-        }
-
-        static void handle(InputStream in) {
-            IOHandler handler = new IOHandler(in);
-            Thread thr = new Thread(handler);
-            thr.setDaemon(true);
-            thr.start();
-        }
-
-        public void run() {
-            try {
-                byte b[] = new byte[100];
-                for (;;) {
-                    int n = in.read(b);
-                    if (n < 0) return;
-                    for (int i=0; i<n; i++) {
-                        System.out.print((char)b[i]);
-                    }
-                }
-            } catch (IOException ioe) { }
-        }
-
-    }
-
     /*
      * Find a connector by name
      */
@@ -95,25 +66,23 @@
      * Launch (in server mode) a debuggee with the given address and
      * suspend mode.
      */
-    private static Process launch(String address, boolean suspend, String class_name) throws IOException {
-        String exe = System.getProperty("java.home") + File.separator + "bin" +
-            File.separator + "java";
-        String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
-            " -agentlib:jdwp=transport=dt_socket,server=y,suspend=";
-        if (suspend) {
-            cmd += "y";
-        } else {
-            cmd += "n";
+    private static ProcessBuilder prepareLauncher(String address, boolean suspend, String class_name) throws Exception {
+        List<String> args = new ArrayList<>();
+        for(String dbgOption : VMConnection.getDebuggeeVMOptions().split(" ")) {
+            args.add(dbgOption);
         }
-        cmd += ",address=" + address + " " + class_name;
-
-        System.out.println("Starting: " + cmd);
+        String lib = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=";
+        if (suspend) {
+            lib += "y";
+        } else {
+            lib += "n";
+        }
+        lib += ",address=" + address;
 
-        Process p = Runtime.getRuntime().exec(cmd);
-        IOHandler.handle(p.getInputStream());
-        IOHandler.handle(p.getErrorStream());
+        args.add(lib);
+        args.add(class_name);
 
-        return p;
+        return ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()]));
     }
 
     /*
@@ -132,16 +101,21 @@
         String address = String.valueOf(port);
 
         // launch the first debuggee
-        Process process1 = launch(address, true, "HelloWorld");
-
-        // give first debuggee time to suspend
-        Thread.currentThread().sleep(5000);
+        ProcessBuilder process1 = prepareLauncher(address, true, "HelloWorld");
+        // start the debuggee and wait for the "ready" message
+        Process p = ProcessTools.startProcess(
+                "process1",
+                process1,
+                line -> line.equals("Listening for transport dt_socket at address: " + address),
+                Math.round(5000 * Utils.TIMEOUT_FACTOR),
+                TimeUnit.MILLISECONDS
+        );
 
         // launch a second debuggee with the same address
-        Process process2 = launch(address, false, "HelloWorld");
+        ProcessBuilder process2 = prepareLauncher(address, false, "HelloWorld");
 
         // get exit status from second debuggee
-        int exitCode = process2.waitFor();
+        int exitCode = ProcessTools.startProcess("process2", process2).waitFor();
 
         // clean-up - attach to first debuggee and resume it
         AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
--- a/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -24,5 +24,6 @@
 interface InterprocessMessages {
     final static int EXECUTION_IS_SUCCESSFULL = 0;
     final static int DATA_IS_CORRUPTED = 212;
+    final static int NO_DROP_HAPPENED = 112;
 }
 
--- a/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2013, 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
@@ -24,7 +24,7 @@
 <html>
 <!--  
   @test
-  @bug 8005932
+  @bug 8005932 8017456
   @summary Java 7 on mac os x only provides text clipboard formats
   @author mikhail.cherkasov@oracle.com
   @library ../../regtesthelpers
--- a/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,17 +21,6 @@
  * questions.
  */
 
-/*
-  @bug 8005932
-  @summary Java 7 on mac os x only provides text clipboard formats
-  @author mikhail.cherkasov@oracle.com
-  @library ../../regtesthelpers
-  @library ../../regtesthelpers/process
-  @build Util
-  @build ProcessResults ProcessCommunicator
-  @run applet/othervm MissedHtmlAndRtfBug.html
-*/
-
 import java.awt.*;
 import java.awt.datatransfer.DataFlavor;
 import java.awt.event.*;
@@ -47,6 +36,7 @@
 import static java.lang.Thread.sleep;
 
 public class MissedHtmlAndRtfBug extends Applet {
+
     public void init() {
         setLayout(new BorderLayout());
     }//End  init()
@@ -82,9 +72,6 @@
         args.add(concatStrings(DataFlavorSearcher.RICH_TEXT_NAMES));
 
         ProcessResults processResults =
-//                ProcessCommunicator.executeChildProcess(this.getClass(), "/Users/mcherkasov/ws/clipboard/DataFlover/out/production/DataFlover" +
-//                        " -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 ",
-//                        args.toArray(new String[0]));
                 ProcessCommunicator.executeChildProcess(this.getClass(),
                         "." + File.separator + System.getProperty("java.class.path"), args.toArray(new String[]{}));
 
@@ -117,6 +104,13 @@
             throw new RuntimeException("TEST IS FAILED: Target has received" +
                     " corrupted data.");
         }
+        if (InterprocessMessages.NO_DROP_HAPPENED ==
+                processResults.getExitValue()) {
+            processResults.printProcessErrorOutput(System.err);
+            throw new RuntimeException("Error. Drop did not happen." +
+                " Target frame is possibly covered by a window of other application." +
+                " Please, rerun the test with all windows minimized.");
+        }
         processResults.verifyStdErr(System.err);
         processResults.verifyProcessExitValue(System.err);
         processResults.printProcessStandartOutput(System.out);
@@ -184,7 +178,7 @@
         }
     }
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws InterruptedException {
         Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extractInt(args),
                 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extractInt(args));
         Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extractInt(args),
@@ -197,6 +191,8 @@
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
+        sleep(5000);
+        System.exit(InterprocessMessages.NO_DROP_HAPPENED);
     }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/EventDispatchThread/EDTShutdownTest/EDTShutdownTest.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,100 @@
+/*
+ * 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 8031694
+  @summary [macosx] TwentyThousandTest test intermittently hangs
+  @author Oleg Pekhovskiy
+  @run main EDTShutdownTest
+ */
+
+import java.awt.EventQueue;
+import java.awt.Toolkit;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import sun.awt.AWTAccessor;
+
+public class EDTShutdownTest {
+
+    private static boolean passed = false;
+
+    public static void main(String[] args) {
+        // Force EDT start with InvocationEvent
+        EventQueue.invokeLater(() -> {
+            // EventQueue is empty now
+            EventQueue queue = Toolkit.getDefaultToolkit()
+                               .getSystemEventQueue();
+            Thread thread = AWTAccessor.getEventQueueAccessor()
+                            .getDispatchThread(queue);
+            try {
+                /*
+                 * Clear EventDispatchThread.doDispatch flag to break message
+                 * loop in EventDispatchThread.pumpEventsForFilter()
+                 */
+                Method stopDispatching = thread.getClass()
+                        .getDeclaredMethod("stopDispatching", null);
+                stopDispatching.setAccessible(true);
+                stopDispatching.invoke(thread, null);
+
+                /*
+                 * Post another InvocationEvent that must be handled by another
+                 * instance of EDT
+                 */
+                EventQueue.invokeLater(() -> {
+                    passed = true;
+                });
+            }
+            catch (InvocationTargetException | NoSuchMethodException
+                   | IllegalAccessException e) {
+            }
+        });
+
+        // Wait for EDT shutdown
+        EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
+        Thread thread = AWTAccessor.getEventQueueAccessor()
+                        .getDispatchThread(queue);
+        try {
+            thread.join();
+
+            /*
+             * Wait for another EDT instance to handle the InvocationEvent
+             * and shutdown
+             */
+            thread = AWTAccessor.getEventQueueAccessor()
+                     .getDispatchThread(queue);
+            if (thread != null) {
+                thread.join();
+            }
+        }
+        catch (InterruptedException e) {
+        }
+
+        if (passed) {
+            System.out.println("Test PASSED!");
+        }
+        else {
+            throw new RuntimeException("Test FAILED!");
+        }
+    }
+}
--- a/test/java/lang/ClassLoader/Assert.sh	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/lang/ClassLoader/Assert.sh	Wed Feb 26 07:43:38 2014 +0400
@@ -23,6 +23,21 @@
 
 #
 
+OS=`uname -s`
+case "$OS" in
+  SunOS | Linux | Darwin )
+    FS="/"
+    CHMOD="${FS}bin${FS}chmod"
+    ;;
+  Windows* | CYGWIN* )
+    CHMOD="chmod"
+    ;;
+  * )
+    echo "Unrecognized system!"
+    exit 1;
+    ;;
+esac
+
 if [ "${TESTSRC}" = "" ]
 then
   echo "TESTSRC not set.  Test cannot execute.  Failed."
@@ -50,6 +65,7 @@
 cp ${TESTSRC}/Assert.java .
 cp -R ${TESTSRC}/package1 .
 cp -R ${TESTSRC}/package2 .
+${CHMOD} -R u+w *
 
 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} Assert.java 
 
--- a/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java	Wed Feb 26 07:43:38 2014 +0400
@@ -24,7 +24,7 @@
 
 /**
  * @test
- * @bug 8032585
+ * @bug 8032585 8033278
  * @summary JSR292: IllegalAccessError when attempting to invoke protected method from different package
  *
  * @compile p1/T2.java p2/T3.java
--- a/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java	Wed Feb 26 07:43:38 2014 +0400
@@ -23,8 +23,57 @@
  */
 package p1;
 
+import p2.T3;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodHandles.Lookup;
+import java.lang.invoke.MethodType;
+import java.util.concurrent.Callable;
+
 class T1 {
-    protected void m() { System.out.println("T1.m");}
+    protected        void m1() {}
+    protected static void m2() {}
 }
 
-public class T2 extends T1 {}
+public class T2 extends T1 {
+    public static void main(String[] args) throws Throwable {
+        Lookup LOOKUP = T3.lookup();
+        Class<IllegalAccessException> IAE = IllegalAccessException.class;
+
+        assertFailure(IAE, () -> LOOKUP.findVirtual(T1.class, "m1", MethodType.methodType(void.class)));
+        assertFailure(IAE, () -> LOOKUP.findStatic(T1.class, "m2", MethodType.methodType(void.class)));
+
+        assertSuccess(() -> LOOKUP.findVirtual(T2.class, "m1", MethodType.methodType(void.class)));
+        assertSuccess(() -> LOOKUP.findVirtual(T3.class, "m1", MethodType.methodType(void.class)));
+
+        assertSuccess(() -> LOOKUP.findStatic(T2.class, "m2", MethodType.methodType(void.class)));
+        assertSuccess(() -> LOOKUP.findStatic(T3.class, "m2", MethodType.methodType(void.class)));
+
+        assertFailure(IAE, () -> LOOKUP.unreflect(T1.class.getDeclaredMethod("m1")));
+        assertFailure(IAE, () -> LOOKUP.unreflect(T1.class.getDeclaredMethod("m2")));
+
+        System.out.println("TEST PASSED");
+    }
+
+    public static void assertFailure(Class<? extends Throwable> expectedError, Callable r) {
+        try {
+            r.call();
+        } catch(Throwable e) {
+            if (expectedError.isAssignableFrom(e.getClass())) {
+                return; // expected error
+            } else {
+                throw new Error("Unexpected error type: "+e.getClass()+"; expected type: "+expectedError, e);
+            }
+        }
+        throw new Error("No error");
+    }
+
+    public static void assertSuccess(Callable r) {
+        try {
+            r.call();
+        } catch(Throwable e) {
+            throw new Error("Unexpected error", e);
+        }
+    }
+}
--- a/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java	Wed Feb 26 07:43:38 2014 +0400
@@ -25,13 +25,8 @@
 
 import p1.T2;
 
-import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
 
 public class T3 extends T2 {
-    public static void main(String[] args) throws Throwable {
-        MethodHandles.lookup().findVirtual(T3.class, "m", MethodType.methodType(void.class));
-        System.out.println("TEST PASSED");
-    }
+    public static MethodHandles.Lookup lookup() { return MethodHandles.lookup(); }
 }
--- a/test/java/rmi/registry/readTest/readTest.sh	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/rmi/registry/readTest/readTest.sh	Wed Feb 26 07:43:38 2014 +0400
@@ -37,11 +37,13 @@
   SunOS | Linux | Darwin )
     PS=":"
     FS="/"
+    CHMOD="${FS}bin${FS}chmod"
     FILEURL="file:"
     ;;
   Windows* )
     PS=";"
     FS="\\"
+    CHMOD="chmod"
     FILEURL="file:/"
     if [ "$VER" -eq "5" ]; then
         ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
@@ -51,6 +53,7 @@
   CYGWIN* )
     PS=";"
     FS="/"
+    CHMOD="chmod"
     FILEURL="file:/"
     if [ "$VER" -eq "5" ]; then
         ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
@@ -65,6 +68,7 @@
 
 TEST_CLASSPATH=.$PS${TESTCLASSPATH:-$TESTCLASSES}
 cp -r ${TESTSRC}${FS}* .
+${CHMOD} -R u+w *
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} testPkg${FS}*java
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -cp $TEST_CLASSPATH readTest.java
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/cert/CertPathBuilder/akiExt/AKISerialNumber.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,141 @@
+/*
+ * 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 8025708
+ * @summary make sure a PKIX CertPathBuilder can build a path when an
+ *     intermediate CA certificate contains an AKI extension with a key
+ *     identifier and no serial number and the end-entity certificate contains
+ *     an AKI extension with both a key identifier and a serial number.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.security.cert.*;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Collections;
+
+public class AKISerialNumber {
+
+    private static final String ROOT_CERT =
+        "MIICfTCCAeagAwIBAgIBATANBgkqhkiG9w0BAQUFADB3MQ0wCwYDVQQDEwRSb290\n" +
+        "MRYwFAYDVQQLEw1UZXN0IE9yZyBVbml0MREwDwYDVQQKEwhUZXN0IE9yZzEWMBQG\n" +
+        "A1UEBxMNVGVzdCBMb2NhbGl0eTEWMBQGA1UECBMNTWFzc2FjaHVzZXR0czELMAkG\n" +
+        "A1UEBhMCVVMwHhcNMTQwMjAxMDUwMDAwWhcNMjQwMjAxMDUwMDAwWjB3MQ0wCwYD\n" +
+        "VQQDEwRSb290MRYwFAYDVQQLEw1UZXN0IE9yZyBVbml0MREwDwYDVQQKEwhUZXN0\n" +
+        "IE9yZzEWMBQGA1UEBxMNVGVzdCBMb2NhbGl0eTEWMBQGA1UECBMNTWFzc2FjaHVz\n" +
+        "ZXR0czELMAkGA1UEBhMCVVMwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJvL\n" +
+        "cZu6Rzf9IrduEDjJxEFv5uBvUNMlIAph7NhfmFH9puPW3Ksci4a5yTCzxI9VeVf3\n" +
+        "oYZ/UrZdF+mNZmS23RUh71X5tjMO+xew196M1xNpCRLbjcZ6i4tNdZYkdRIe8ejN\n" +
+        "sbBoD7OAvPbQqTygeG4jYjK6ODofSrba3BndNoFxAgMBAAGjGTAXMBUGA1UdEwEB\n" +
+        "/wQLMAkBAf8CBH////8wDQYJKoZIhvcNAQEFBQADgYEATvCqn69pNHv0zLiZAXk7\n" +
+        "3AKwAoza0wa+1S2rVuZGfBWbV7CxmBHbgcDDbU7/I8pQVkCwOHNkVFnBgNpMuAvU\n" +
+        "aDyrHSNS/av5d1yk5WAuGX2B9mSwZdhnAvtz2fsV1q9NptdF54EkIiKtQQmTGnr9\n" +
+        "TID8CFEk/qje+AB272B1UJw=\n";
+
+    /**
+     * This certificate contains an AuthorityKeyIdentifier with only the
+     * keyIdentifier field filled in.
+     */
+    private static final String INT_CERT_WITH_KEYID_AKI =
+        "MIICqTCCAhKgAwIBAgIBAjANBgkqhkiG9w0BAQUFADB3MQ0wCwYDVQQDEwRSb290\n" +
+        "MRYwFAYDVQQLEw1UZXN0IE9yZyBVbml0MREwDwYDVQQKEwhUZXN0IE9yZzEWMBQG\n" +
+        "A1UEBxMNVGVzdCBMb2NhbGl0eTEWMBQGA1UECBMNTWFzc2FjaHVzZXR0czELMAkG\n" +
+        "A1UEBhMCVVMwHhcNMTQwMjAxMDUwMDAwWhcNMjQwMjAxMDUwMDAwWjCBhDEaMBgG\n" +
+        "A1UEAxMRSW50ZXJtZWRpYXRlIENBIDIxFjAUBgNVBAsTDVRlc3QgT3JnIFVuaXQx\n" +
+        "ETAPBgNVBAoTCFRlc3QgT3JnMRYwFAYDVQQHEw1UZXN0IExvY2FsaXR5MRYwFAYD\n" +
+        "VQQIEw1NYXNzYWNodXNldHRzMQswCQYDVQQGEwJVUzCBnzANBgkqhkiG9w0BAQEF\n" +
+        "AAOBjQAwgYkCgYEAwKTZekCqb9F9T54s2IXjkQbmLIjQamMpkUlZNrpjjNq9CpTT\n" +
+        "POkfxv2UPwzTz3Ij4XFL/kJFBLm8NUOsS5xPJ62pGoZBPw9R0iMTsTce+Fpukqnr\n" +
+        "I+8jTRaAvr0tR3pqrE6uHKg7dWYN2SsWesDia/LHhwEN38yyWtSuTTLo4hcCAwEA\n" +
+        "AaM3MDUwHwYDVR0jBBgwFoAU6gZP1pO8v7+i8gsFf1gWTf/j3PkwEgYDVR0TAQH/\n" +
+        "BAgwBgEB/wIBADANBgkqhkiG9w0BAQUFAAOBgQAQxeQruav4AqQM4gmEfrHr5hOq\n" +
+        "mB2CNJ1ZqVfpDZ8GHijncKTpjNoXzzQtV23Ge+39JHOVBNWtk+aghB3iu6xGq7Qn\n" +
+        "HlBhg9meqHFqd3igDDD/jhABL2/bEo/M9rv6saYWDFZ8nCIEE6iTLTpRRko4W2Xb\n" +
+        "DyzMzMsO1kPNrJaxRg==\n";
+
+    /**
+     * This certificate contains an AuthorityKeyIdentifier with all 3 fields
+     * (keyIdentifier, authorityCertIssuer, and authorityCertSerialNumber)
+     * filled in.
+     */
+    private static final String EE_CERT_WITH_FULL_AKI =
+        "MIIDLjCCApegAwIBAgIBAzANBgkqhkiG9w0BAQUFADCBhDEaMBgGA1UEAxMRSW50\n" +
+        "ZXJtZWRpYXRlIENBIDIxFjAUBgNVBAsTDVRlc3QgT3JnIFVuaXQxETAPBgNVBAoT\n" +
+        "CFRlc3QgT3JnMRYwFAYDVQQHEw1UZXN0IExvY2FsaXR5MRYwFAYDVQQIEw1NYXNz\n" +
+        "YWNodXNldHRzMQswCQYDVQQGEwJVUzAeFw0xNDAyMDEwNTAwMDBaFw0yNDAyMDEw\n" +
+        "NTAwMDBaMH0xEzARBgNVBAMTCkVuZCBFbnRpdHkxFjAUBgNVBAsTDVRlc3QgT3Jn\n" +
+        "IFVuaXQxETAPBgNVBAoTCFRlc3QgT3JnMRYwFAYDVQQHEw1UZXN0IExvY2FsaXR5\n" +
+        "MRYwFAYDVQQIEw1NYXNzYWNodXNldHRzMQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAqady46PdwlKHVP1iaP11CxVyL6cDlPjpwhHCcIUv\n" +
+        "nKHbzdamqmHebDcWVBNN/I0TLNCl3ga7n8KyygSN379fG7haU8SNjpy4IDAXM0/x\n" +
+        "mwTWNTbKfJEkSoiqx1WUy2JTzRUMhgYPguQNECPxBXAdQrthZ7wQosv6Ro2ySP9O\n" +
+        "YqsCAwEAAaOBtTCBsjCBoQYDVR0jBIGZMIGWgBQdeoKxTvlTgW2KgprD69vgHV4X\n" +
+        "kKF7pHkwdzENMAsGA1UEAxMEUm9vdDEWMBQGA1UECxMNVGVzdCBPcmcgVW5pdDER\n" +
+        "MA8GA1UEChMIVGVzdCBPcmcxFjAUBgNVBAcTDVRlc3QgTG9jYWxpdHkxFjAUBgNV\n" +
+        "BAgTDU1hc3NhY2h1c2V0dHMxCzAJBgNVBAYTAlVTggECMAwGA1UdEwEB/wQCMAAw\n" +
+        "DQYJKoZIhvcNAQEFBQADgYEAuG4mM1nLF7STQWwmceELZEl49ntapH/RVoekknmd\n" +
+        "aNzcL4XQf6BTl8KFUXuThHaukQnGIzFbSZV0hrpSQ5fTN2cSZgD4Fji+HuNURmmd\n" +
+        "+Kayl0piHyO1FSbrty0TFhlVNvzKXjmMp6Jdn42KyGOSCoROQcvUWN6xkV3Hvrei\n" +
+        "0ZE=\n";
+
+    private static Base64.Decoder b64Decoder = Base64.getMimeDecoder();
+    private static CertificateFactory cf;
+
+    public static void main(String[] args) throws Exception {
+
+        cf = CertificateFactory.getInstance("X.509");
+
+        X509Certificate rootCert = getCertFromMimeEncoding(ROOT_CERT);
+        TrustAnchor anchor = new TrustAnchor(rootCert, null);
+
+        X509Certificate eeCert = getCertFromMimeEncoding(EE_CERT_WITH_FULL_AKI);
+        X509Certificate intCert = getCertFromMimeEncoding(INT_CERT_WITH_KEYID_AKI);
+
+        X509CertSelector sel = new X509CertSelector();
+        sel.setCertificate(eeCert);
+        PKIXBuilderParameters params = new PKIXBuilderParameters
+            (Collections.singleton(anchor), sel);
+        params.setRevocationEnabled(false);
+
+        ArrayList<X509Certificate> certs = new ArrayList<>();
+        certs.add(intCert);
+        certs.add(eeCert);
+        CollectionCertStoreParameters ccsp =
+            new CollectionCertStoreParameters(certs);
+        CertStore cs = CertStore.getInstance("Collection", ccsp);
+        params.addCertStore(cs);
+
+        CertPathBuilder cpb = CertPathBuilder.getInstance("PKIX");
+        CertPathBuilderResult res = cpb.build(params);
+    }
+
+    private static X509Certificate getCertFromMimeEncoding(String encoded)
+        throws CertificateException
+    {
+        byte[] bytes = b64Decoder.decode(encoded);
+        ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+        return (X509Certificate)cf.generateCertificate(stream);
+    }
+}
--- a/test/java/util/Comparator/TypeTest.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/util/Comparator/TypeTest.java	Wed Feb 26 07:43:38 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -24,6 +24,7 @@
 /**
  * @test
  * @summary Comparator API narrowing type test
+ * @bug 8033590
  * @run testng TypeTest
  */
 
@@ -33,6 +34,8 @@
 import java.util.Comparator;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertTrue;
+
 @Test(groups = "unit")
 public class TypeTest {
     static class Person {
@@ -66,6 +69,24 @@
         }
     }
 
+    static class Department {
+        Manager mgr;
+        String hr_code;
+
+        Department(Manager mgr, String hr) {
+            this.mgr = mgr;
+            this.hr_code = hr;
+        }
+
+        Manager getManager() {
+            return mgr;
+        }
+
+        String getHR() {
+            return hr_code;
+        }
+    }
+
     static <T> void assertOrder(T o1, T o2, Comparator<? super T> cmp) {
         if (cmp.compare(o1, o2) > 0) {
             System.out.println("Fail!!");
@@ -75,6 +96,8 @@
         }
     }
 
+    // Type tests just to make sure the code can compile and build
+    // Not necessarily need a meaningful result
     public void testOrder() {
         Manager m1 = new Manager("Manager", 2, 2000);
         Manager m2 = new Manager("Manager", 4, 1300);
@@ -93,4 +116,23 @@
         Map<String, Integer> map = new TreeMap<>();
         map.entrySet().stream().sorted(Map.Entry.comparingByKey(String.CASE_INSENSITIVE_ORDER));
     }
+
+    public void testJDK8033590() {
+        Manager a = new Manager("John Doe", 1234, 16);
+        Manager b = new Manager("Jane Roe", 2468, 16);
+        Department da = new Department(a, "X");
+        Department db = new Department(b, "X");
+
+        Comparator<Department> cmp = Comparator.comparing(Department::getHR)
+                .thenComparing(Department::getManager, Employee.C);
+        assertTrue(cmp.compare(da, db) < 0);
+
+        cmp = Comparator.comparing(Department::getHR)
+                .thenComparing(Department::getManager, Manager.C);
+        assertTrue(cmp.compare(da, db) == 0);
+
+        cmp = Comparator.comparing(Department::getHR)
+                .thenComparing(Department::getManager, Person.C);
+        assertTrue(cmp.compare(da, db) > 0);
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/TestGetLoggerNPE.java	Wed Feb 26 07:43:38 2014 +0400
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013, 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.PrintStream;
+import java.security.Permission;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import sun.misc.JavaAWTAccess;
+import sun.misc.SharedSecrets;
+
+/*
+ * @test
+ * @bug 8025512
+ *
+ * @summary NPE with logging while launching webstart
+ *
+ * @build TestGetLoggerNPE
+ * @run main/othervm TestGetLoggerNPE getLogger
+ * @run main/othervm TestGetLoggerNPE getLogManager
+ */
+public class TestGetLoggerNPE {
+    static volatile Throwable thrown = null;
+    public static void main(String[] args) throws Exception {
+        final String testCase = args.length == 0 ? "getLogger" : args[0];
+        final JavaAWTAccessStub access = new JavaAWTAccessStub();
+        SharedSecrets.setJavaAWTAccess(access);
+        final ThreadGroup tg = new ThreadGroup("TestGroup");
+        Thread t = new Thread(tg, "test") {
+            public void run() {
+                try {
+                    access.setContext(Context.ONE);
+                    final PrintStream out = System.out;
+                    System.setOut(null);
+                    try {
+                        if ("getLogger".equals(testCase)) {
+                           Logger.getLogger("sun.plugin");
+                        } else {
+                           LogManager.getLogManager();
+                        }
+                    } finally {
+                        System.setOut(out);
+                    }
+
+                    System.out.println(Logger.global);
+                } catch (Throwable x) {
+                    x.printStackTrace();
+                    thrown = x;
+                }
+            }
+        };
+        Policy.setPolicy(new Policy() {
+             public boolean implies(ProtectionDomain domain,
+                                    Permission permission) {
+                 return true; // all permissions
+             }
+        });
+        System.setSecurityManager(new SecurityManager());
+        t.start();
+        t.join();
+        if (thrown == null) {
+            System.out.println("PASSED: " + testCase);
+        } else {
+            System.err.println("FAILED: " + testCase);
+            throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
+        }
+
+    }
+
+    static enum Context { ONE, TWO };
+
+    static final class JavaAWTAccessStub implements JavaAWTAccess {
+        private static final InheritableThreadLocal<Context> context = new InheritableThreadLocal<>();
+
+
+        public void setContext(Context context) {
+            JavaAWTAccessStub.context.set(context);
+        }
+
+        @Override
+        public Object getAppletContext() {
+            return context.get();
+        }
+
+     }
+
+}
--- a/test/java/util/zip/ZipFile/ReadZip.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/java/util/zip/ZipFile/ReadZip.java	Wed Feb 26 07:43:38 2014 +0400
@@ -63,6 +63,8 @@
         Files.copy(Paths.get(System.getProperty("test.src", ""), "input.zip"),
                    newZip.toPath(), StandardCopyOption.REPLACE_EXISTING);
 
+        newZip.setWritable(true);
+
         // pad some bytes
         try (OutputStream os = Files.newOutputStream(newZip.toPath(),
                                                      StandardOpenOption.APPEND)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/PrintServiceLookup/CountPrintServices.java	Wed Feb 26 07:43:38 2014 +0400
@@ -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.
+ */
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.standard.PrinterName;
+
+/*
+ * @test
+ * @bug 8032693
+ * @summary Test that lpstat and JDK agree whether there are printers.
+ */
+public class CountPrintServices {
+
+  public static void main(String[] args) throws Exception {
+    String os = System.getProperty("os.name").toLowerCase();
+    System.out.println("OS is " + os);
+    if (!os.equals("linux")) {
+        System.out.println("Linux specific test. No need to continue");
+        return;
+    }
+    PrintService services[] =
+        PrintServiceLookup.lookupPrintServices(null, null);
+    if (services.length > 0) {
+       System.out.println("Services found. No need to test further.");
+       return;
+    }
+    String[] lpcmd = { "lpstat", "-a" };
+    Process proc = Runtime.getRuntime().exec(lpcmd);
+    proc.waitFor();
+    InputStreamReader ir = new InputStreamReader(proc.getInputStream());
+    BufferedReader br = new BufferedReader(ir);
+    int count = 0;
+    String printer;
+    while ((printer = br.readLine()) != null) {
+       System.out.println("lpstat:: " + printer);
+       count++;
+    }
+    if (count > 0) {
+        throw new RuntimeException("Services exist, but not found by JDK.");
+    }
+ }
+}
+
--- a/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Wed Feb 26 07:43:38 2014 +0400
@@ -25,6 +25,7 @@
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.ConnectException;
+import java.net.ServerSocket;
 import java.rmi.NoSuchObjectException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
@@ -255,26 +256,23 @@
     private static List<Failure> failures = new ArrayList<>();
 
     public static void main(String args[]) throws Exception {
-        for (int i=0;i<3;i++) {
-            System.out.println("=== PASS " + i + " ===");
-            for (Method m : JMXStartStopTest.class.getDeclaredMethods()) {
-                if (m.getName().startsWith("test_")) {
-                    try {
-                        m.invoke(null);
-                        System.out.println("=== PASSED\n");
-                    } catch (Throwable e) {
-                        failures.add(new Failure(e, m.getName() + " failed"));
-                    }
+        for (Method m : JMXStartStopTest.class.getDeclaredMethods()) {
+            if (m.getName().startsWith("test_")) {
+                try {
+                    m.invoke(null);
+                    System.out.println("=== PASSED\n");
+                } catch (Throwable e) {
+                    failures.add(new Failure(e, m.getName() + " failed"));
                 }
             }
+        }
 
-            if (!failures.isEmpty()) {
-                for(Failure f : failures) {
-                    System.err.println(f.getMsg());
-                    f.getCause().printStackTrace(System.err);
-                }
-                throw new Error();
+        if (!failures.isEmpty()) {
+            for(Failure f : failures) {
+                System.err.println(f.getMsg());
+                f.getCause().printStackTrace(System.err);
             }
+            throw new Error();
         }
     }
 
@@ -371,6 +369,7 @@
         ));
         pbArgs.addAll(Arrays.asList(args));
         pbArgs.add("JMXStartStopDoSomething");
+
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             pbArgs.toArray(new String[pbArgs.size()])
         );
@@ -596,14 +595,16 @@
             jcmd(CMD_STOP);
             jcmd(CMD_STOP);
 
+            ServerSocket ss = new ServerSocket(0);
+
             jcmd(
                 line -> {
-                    if (line.contains("Port already in use: 22")) {
+                    if (line.contains("Port already in use: " + ss.getLocalPort())) {
                         checks[2] = true;
                     }
                 },
                 CMD_START,
-                "jmxremote.port=22",
+                "jmxremote.port=" + ss.getLocalPort(),
                 "jmxremote.rmi.port=" + port2,
                 "jmxremote.authenticate=false",
                 "jmxremote.ssl=false");
@@ -616,7 +617,7 @@
                                     "report an invalid agent state");
             }
             if (!checks[2]) {
-                throw new Exception("Starting agent on port 22 should " +
+                throw new Exception("Starting agent on port " + ss.getLocalPort() + " should " +
                                     "report port in use");
             }
         } finally {
@@ -627,7 +628,7 @@
     private static void test_07() throws Exception {
         // Run an app without JMX enabled, but with some properties set
         // in command line.
-        // make sure these properties overriden corectly
+        // make sure these properties overridden corectly
 
         System.out.println("**** Test seven ****");
 
@@ -654,7 +655,7 @@
         // Run an app with JMX enabled and with some properties set
         // in command line.
         // stop JMX agent and then start it again with different property values
-        // make sure these properties overriden corectly
+        // make sure these properties overridden corectly
 
         System.out.println("**** Test eight ****");
 
@@ -690,7 +691,7 @@
         // stop JMX agent and then start it again with different property values
         // specifing some property in management config file and some of them
         // in command line
-        // make sure these properties overriden corectly
+        // make sure these properties overridden corectly
 
         System.out.println("**** Test nine ****");
 
@@ -725,7 +726,7 @@
         // in command line.
         // stop JMX agent and then start it again with different property values
         // stop JMX agent again and then start it without property value
-        // make sure these properties overriden corectly
+        // make sure these properties overridden corectly
 
         System.out.println("**** Test ten ****");
 
@@ -800,7 +801,7 @@
         // Run an app with -javaagent make sure it works as expected -
         // system properties are ignored
 
-        System.out.println("**** Test fourteen ****");
+        System.out.println("**** Test thirteen ****");
 
         String agent = TEST_JDK + "/jre/lib/management-agent.jar";
         if (!new File(agent).exists()) {
--- a/test/sun/net/www/protocol/jar/jarbug/run.sh	Tue Feb 18 16:38:13 2014 +0400
+++ b/test/sun/net/www/protocol/jar/jarbug/run.sh	Wed Feb 26 07:43:38 2014 +0400
@@ -34,14 +34,17 @@
   SunOS | Linux | Darwin )
     PS=":"
     FS="/"
+    CHMOD="${FS}bin${FS}chmod"
     ;;
   Windows* )
     PS=";"
     FS="\\"
+    CHMOD="chmod"
     ;;
   CYGWIN* )
     PS=";"
     FS="/"
+    CHMOD="chmod"
     #
     # javac does not like /cygdrive produced by `pwd`.
     #
@@ -59,6 +62,7 @@
 mkdir -p ${DEST}${FS}jar1
 cd ${TESTSRC}${FS}etc${FS}jar1
 cp -r . ${DEST}${FS}jar1
+${CHMOD} -R u+w ${DEST}${FS}jar1
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \
     ${TESTSRC}${FS}src${FS}jar1${FS}LoadResourceBundle.java
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \