# HG changeset patch # User amurillo # Date 1467417037 25200 # Node ID 2dbd21fdb7a03cf7383d89b25cb134145224f852 # Parent 3e9ca73f58ca49e17a5fcdd3a47054bfb60a1070# Parent 44eb314f5b3808c638eaa59964a854d0b948bb04 Merge diff -r 44eb314f5b38 -r 2dbd21fdb7a0 .hgtags --- a/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -366,3 +366,4 @@ 18e5cdecb37a2f03ba74f6c8f022858bcbaacf56 jdk-9+121 7693aa00e131493ceb42b93305e2f014c9922a3b jdk-9+122 d53037a90c441cb528dc41c30827985de0e67c62 jdk-9+123 +2a5697a98620c4f40e4a1a71478464399b8878de jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 .hgtags-top-repo --- a/.hgtags-top-repo Fri Jun 24 15:06:50 2016 -0700 +++ b/.hgtags-top-repo Fri Jul 01 16:50:37 2016 -0700 @@ -366,3 +366,4 @@ cae471d3b87783e0a3deea658e1e1c84b2485b6c jdk-9+121 346be2df0f5b31d423807f53a719d1b9a67f3354 jdk-9+122 405d811c0d7b9b48ff718ae6c240b732f098c028 jdk-9+123 +f80c841ae2545eaf9acd2724bccc305d98cefbe2 jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 common/autoconf/generated-configure.sh --- a/common/autoconf/generated-configure.sh Fri Jun 24 15:06:50 2016 -0700 +++ b/common/autoconf/generated-configure.sh Fri Jul 01 16:50:37 2016 -0700 @@ -5094,7 +5094,7 @@ #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1466007828 +DATE_WHEN_GENERATED=1467039751 ############################################################################### # @@ -36621,7 +36621,6 @@ # Setup the assembler (AS) # if test "x$OPENJDK_TARGET_OS" = xsolaris; then - # FIXME: should this really be solaris, or solstudio? # Publish this variable in the help. @@ -37105,6 +37104,9 @@ fi fi + if test "x$AS" = x; then + as_fn_error $? "Solaris assembler (as) is required. Please install via \"pkg install pkg:/developer/assembler\"." "$LINENO" 5 + fi else # FIXME: is this correct for microsoft? AS="$CC -c" diff -r 44eb314f5b38 -r 2dbd21fdb7a0 common/autoconf/toolchain.m4 --- a/common/autoconf/toolchain.m4 Fri Jun 24 15:06:50 2016 -0700 +++ b/common/autoconf/toolchain.m4 Fri Jul 01 16:50:37 2016 -0700 @@ -597,9 +597,11 @@ # Setup the assembler (AS) # if test "x$OPENJDK_TARGET_OS" = xsolaris; then - # FIXME: should this really be solaris, or solstudio? BASIC_PATH_PROGS(AS, as) BASIC_FIXUP_EXECUTABLE(AS) + if test "x$AS" = x; then + AC_MSG_ERROR([Solaris assembler (as) is required. Please install via "pkg install pkg:/developer/assembler".]) + fi else # FIXME: is this correct for microsoft? AS="$CC -c" diff -r 44eb314f5b38 -r 2dbd21fdb7a0 common/bin/compare.sh --- a/common/bin/compare.sh Fri Jun 24 15:06:50 2016 -0700 +++ b/common/bin/compare.sh Fri Jul 01 16:50:37 2016 -0700 @@ -360,9 +360,11 @@ $RM $OTHER_FILE $THIS_FILE #Note that | doesn't work on mac sed. HTML_FILTER="$SED \ - -e 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}//g' \ + -e 's/20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}//g' \ + -e 's/20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}//g' \ -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \ - -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [0-9]\{4\} [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*//' + -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [0-9]\{4\} [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*//' \ + -e 's/from .*\.idl/\.idl/' \ " $CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE & $CAT $THIS_DIR/$f | eval "$HTML_FILTER" > $THIS_FILE & diff -r 44eb314f5b38 -r 2dbd21fdb7a0 corba/.hgtags --- a/corba/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/corba/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -366,3 +366,4 @@ 9a5fc5a27560ac272c1341f8f3838338fba49059 jdk-9+121 a39131aafc51a6fd8836e6ebe1b04458702ce7d6 jdk-9+122 e33a34cc551907617d8129c4faaf1a5a7e61d21c jdk-9+123 +45121d5afb9d5bfadab75378572ad96832e0809e jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java --- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Fri Jun 24 15:06:50 2016 -0700 +++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Fri Jul 01 16:50:37 2016 -0700 @@ -2230,7 +2230,7 @@ * REVISIT -- This code doesn't do what the comment says to when * getField() is null! */ - private void inputClassFields(Object o, Class cl, + private void inputClassFields(Object o, Class cl, ObjectStreamField[] fields, com.sun.org.omg.SendingContext.CodeBase sender) throws InvalidClassException, StreamCorruptedException, @@ -2239,6 +2239,8 @@ int primFields = fields.length - currentClassDesc.objFields; + // this will leave primitives in the inputstream + // should really consume and discard where necessary if (o != null) { for (int i = 0; i < primFields; ++i) { inputPrimitiveField(o, cl, fields[i]); @@ -2264,21 +2266,32 @@ } try { - Class fieldCl = fields[i].getClazz(); + Class fieldCl = fields[i].getClazz(); if ((objectValue != null) && (!fieldCl.isAssignableFrom( objectValue.getClass()))) { throw new IllegalArgumentException("Field mismatch"); } - Field classField = null; + Field declaredClassField = null; + final String inputStreamFieldName = fields[i].getName(); try { - classField = cl.getDeclaredField(fields[i].getName()); - } catch (NoSuchFieldException nsfEx) { - throw new IllegalArgumentException(nsfEx); + declaredClassField = getDeclaredField( cl, inputStreamFieldName); + } catch (PrivilegedActionException paEx) { + throw new IllegalArgumentException( + (NoSuchFieldException) paEx.getException()); } catch (SecurityException secEx) { - throw new IllegalArgumentException(secEx.getCause()); + throw new IllegalArgumentException(secEx); + } catch (NullPointerException npEx) { + continue; + } catch (NoSuchFieldException e) { + continue; } - Class declaredFieldClass = classField.getType(); + + if (declaredClassField == null) { + continue; + } + + Class declaredFieldClass = declaredClassField.getType(); // check input field type is a declared field type // input field is a subclass of the declared field @@ -2291,15 +2304,24 @@ } bridge.putObject( o, fields[i].getFieldID(), objectValue ) ; // reflective code: fields[i].getField().set( o, objectValue ) ; - } catch (IllegalArgumentException e) { - ClassCastException exc = new ClassCastException("Assigning instance of class " + - objectValue.getClass().getName() + - " to field " + - currentClassDesc.getName() + - '#' + - fields[i].getField().getName()); - exc.initCause( e ) ; - throw exc ; + } catch (IllegalArgumentException iaEx) { + String objectValueClassName = "null"; + String currentClassDescClassName = "null"; + String fieldName = "null"; + if (objectValue != null) { + objectValueClassName = objectValue.getClass().getName(); + } + if (currentClassDesc != null) { + currentClassDescClassName = currentClassDesc.getName(); + } + if (fields[i] != null && fields[i].getField() != null) { + fieldName = fields[i].getField().getName(); + } + ClassCastException ccEx = new ClassCastException( + "Assigning instance of class " + objectValueClassName + + " to field " + currentClassDescClassName + '#' + fieldName); + ccEx.initCause( iaEx ) ; + throw ccEx ; } } // end : for loop } @@ -2592,12 +2614,11 @@ throw cce ; } } - } - private static void setObjectField(Object o, Class c, String fieldName, Object v) { + private static void setObjectField(Object o, Class c, String fieldName, Object v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; Class fieldCl = fld.getType(); if(v != null && !fieldCl.isInstance(v)) { throw new Exception(); @@ -2617,10 +2638,10 @@ } } - private static void setBooleanField(Object o, Class c, String fieldName, boolean v) + private static void setBooleanField(Object o, Class c, String fieldName, boolean v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Boolean.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putBoolean( o, key, v ) ; @@ -2640,10 +2661,10 @@ } } - private static void setByteField(Object o, Class c, String fieldName, byte v) + private static void setByteField(Object o, Class c, String fieldName, byte v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Byte.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putByte( o, key, v ) ; @@ -2663,10 +2684,10 @@ } } - private static void setCharField(Object o, Class c, String fieldName, char v) + private static void setCharField(Object o, Class c, String fieldName, char v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Character.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putChar( o, key, v ) ; @@ -2686,10 +2707,10 @@ } } - private static void setShortField(Object o, Class c, String fieldName, short v) + private static void setShortField(Object o, Class c, String fieldName, short v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Short.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putShort( o, key, v ) ; @@ -2709,10 +2730,10 @@ } } - private static void setIntField(Object o, Class c, String fieldName, int v) + private static void setIntField(Object o, Class c, String fieldName, int v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Integer.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putInt( o, key, v ) ; @@ -2732,10 +2753,10 @@ } } - private static void setLongField(Object o, Class c, String fieldName, long v) + private static void setLongField(Object o, Class c, String fieldName, long v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Long.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putLong( o, key, v ) ; @@ -2755,10 +2776,10 @@ } } - private static void setFloatField(Object o, Class c, String fieldName, float v) + private static void setFloatField(Object o, Class c, String fieldName, float v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Float.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putFloat( o, key, v ) ; @@ -2778,10 +2799,10 @@ } } - private static void setDoubleField(Object o, Class c, String fieldName, double v) + private static void setDoubleField(Object o, Class c, String fieldName, double v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Double.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putDouble( o, key, v ) ; @@ -2801,6 +2822,22 @@ } } + + private static Field getDeclaredField(final Class c, + final String fieldName) + throws PrivilegedActionException, NoSuchFieldException, SecurityException { + if (System.getSecurityManager() == null) { + return c.getDeclaredField(fieldName); + } else { + return AccessController + .doPrivileged(new PrivilegedExceptionAction() { + public Field run() throws NoSuchFieldException { + return c.getDeclaredField(fieldName); + } + }); + } + } + /** * This class maintains a map of stream position to * an Object currently being deserialized. It is used @@ -2811,12 +2848,12 @@ */ static class ActiveRecursionManager { - private Map offsetToObjectMap; + private Map offsetToObjectMap; public ActiveRecursionManager() { // A hash map is unsynchronized and allows // null values - offsetToObjectMap = new HashMap(); + offsetToObjectMap = new HashMap<>(); } // Called right after allocating a new object. diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/.hgtags --- a/hotspot/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -526,3 +526,4 @@ 7e293105dbb0789a468655f81320c891f491f371 jdk-9+121 af6b4ad908e732d23021f12e8322b204433d5cf6 jdk-9+122 75f81e1fecfb444f34f357295fe06af60e2762d9 jdk-9+123 +479631362b4930be985245ea063d87d821a472eb jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/os/aix/vm/globals_aix.hpp --- a/hotspot/src/os/aix/vm/globals_aix.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/os/aix/vm/globals_aix.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -35,6 +35,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/os/bsd/vm/globals_bsd.hpp --- a/hotspot/src/os/bsd/vm/globals_bsd.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/os/bsd/vm/globals_bsd.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/os/linux/vm/globals_linux.hpp --- a/hotspot/src/os/linux/vm/globals_linux.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/os/linux/vm/globals_linux.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/os/solaris/vm/globals_solaris.hpp --- a/hotspot/src/os/solaris/vm/globals_solaris.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/os/solaris/vm/globals_solaris.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/os/windows/vm/globals_windows.hpp --- a/hotspot/src/os/windows/vm/globals_windows.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/os/windows/vm/globals_windows.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/c1/c1_globals.cpp --- a/hotspot/src/share/vm/c1/c1_globals.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/c1/c1_globals.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -30,6 +30,7 @@ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/c1/c1_globals.hpp --- a/hotspot/src/share/vm/c1/c1_globals.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/c1/c1_globals.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -65,6 +65,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ @@ -356,6 +357,7 @@ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/gc/g1/g1_globals.cpp --- a/hotspot/src/share/vm/gc/g1/g1_globals.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/gc/g1/g1_globals.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -30,6 +30,7 @@ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ MATERIALIZE_MANAGEABLE_FLAG, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/gc/g1/g1_globals.hpp --- a/hotspot/src/share/vm/gc/g1/g1_globals.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/gc/g1/g1_globals.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -36,6 +36,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ manageable, \ @@ -323,6 +324,7 @@ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ DECLARE_MANAGEABLE_FLAG, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/jvmci/jvmci_globals.cpp --- a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -32,6 +32,7 @@ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, IGNORE_RANGE, \ @@ -89,6 +90,7 @@ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_DIAGNOSTIC_FLAG_VALUE_CHANGED_CHECK_CODE, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -104,6 +106,7 @@ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_EXPERIMENTAL_FLAG_VALUE_CHANGED_CHECK_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -129,6 +132,7 @@ JVMCI_PRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \ JVMCI_PD_PRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_NOTPRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \ IGNORE_RANGE, \ @@ -168,6 +172,7 @@ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_DIAGNOSTIC_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -181,6 +186,7 @@ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_EXPERIMENTAL_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -206,6 +212,7 @@ JVMCI_PRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ JVMCI_PD_PRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_NOTPRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ IGNORE_RANGE, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/jvmci/jvmci_globals.hpp --- a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -37,6 +37,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ range, \ @@ -102,6 +103,7 @@ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/opto/c2_globals.cpp --- a/hotspot/src/share/vm/opto/c2_globals.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/opto/c2_globals.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -30,6 +30,7 @@ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/opto/c2_globals.hpp --- a/hotspot/src/share/vm/opto/c2_globals.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/opto/c2_globals.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -66,6 +66,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ range, \ @@ -203,7 +204,7 @@ "Map number of unrolls for main loop via " \ "Superword Level Parallelism analysis") \ \ - product_pd(bool, PostLoopMultiversioning, \ + diagnostic_pd(bool, PostLoopMultiversioning, \ "Multi versioned post loops to eliminate range checks") \ \ notproduct(bool, TraceSuperWordLoopUnrollAnalysis, false, \ @@ -764,6 +765,7 @@ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -211,6 +211,7 @@ #define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_PD_PRODUCT_FLAG(type, name, doc) ); emit_constraint_##type(#name +#define EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name @@ -233,6 +234,7 @@ EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, EMIT_CONSTRAINT_MANAGEABLE_FLAG, @@ -260,6 +262,7 @@ EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, IGNORE_RANGE, EMIT_CONSTRAINT_CHECK, @@ -272,6 +275,7 @@ EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, IGNORE_RANGE, @@ -285,6 +289,7 @@ EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, EMIT_CONSTRAINT_MANAGEABLE_FLAG, diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp --- a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -278,6 +278,7 @@ #define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_range_##type(#name #define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_range_##type(#name #define EMIT_RANGE_PD_PRODUCT_FLAG(type, name, doc) ); emit_range_##type(#name +#define EMIT_RANGE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_range_##type(#name #define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc) ); emit_range_##type(#name #define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_range_##type(#name #define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name @@ -299,6 +300,7 @@ EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_MANAGEABLE_FLAG, @@ -325,6 +327,7 @@ EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, @@ -338,6 +341,7 @@ EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, IGNORE_CONSTRAINT, @@ -350,6 +354,7 @@ EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, @@ -363,6 +368,7 @@ EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_MANAGEABLE_FLAG, diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp --- a/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -108,6 +108,7 @@ #define EMIT_WRITEABLE_PD_PRODUCT_FLAG(type, name, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_DEVELOPER_FLAG(type, name, value, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name @@ -126,6 +127,7 @@ EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, EMIT_WRITEABLE_MANAGEABLE_FLAG, @@ -152,6 +154,7 @@ EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, IGNORE_RANGE, @@ -165,6 +168,7 @@ EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, IGNORE_RANGE, IGNORE_CONSTRAINT, @@ -177,6 +181,7 @@ EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, IGNORE_RANGE, @@ -190,6 +195,7 @@ EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, EMIT_WRITEABLE_MANAGEABLE_FLAG, diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/runtime/globals.cpp --- a/hotspot/src/share/vm/runtime/globals.cpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/runtime/globals.cpp Fri Jul 01 16:50:37 2016 -0700 @@ -58,6 +58,7 @@ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ MATERIALIZE_MANAGEABLE_FLAG, \ @@ -72,6 +73,7 @@ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -650,6 +652,7 @@ #define RUNTIME_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT) }, #define RUNTIME_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define RUNTIME_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC) }, +#define RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_EXPERIMENTAL) }, #define RUNTIME_MANAGEABLE_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_MANAGEABLE) }, #define RUNTIME_PRODUCT_RW_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_READ_WRITE) }, @@ -660,6 +663,7 @@ #define JVMCI_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT) }, #define JVMCI_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define JVMCI_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DIAGNOSTIC) }, +#define JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define JVMCI_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_EXPERIMENTAL) }, #define JVMCI_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP) }, #define JVMCI_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, @@ -674,6 +678,7 @@ #define C1_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT) }, #define C1_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define C1_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC) }, +#define C1_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define C1_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP) }, #define C1_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, #define C1_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_NOT_PRODUCT) }, @@ -681,6 +686,7 @@ #define C2_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT) }, #define C2_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define C2_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC) }, +#define C2_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define C2_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_EXPERIMENTAL) }, #define C2_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP) }, #define C2_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, @@ -695,6 +701,7 @@ #define SHARK_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT) }, #define SHARK_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define SHARK_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DIAGNOSTIC) }, +#define SHARK_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define SHARK_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP) }, #define SHARK_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, #define SHARK_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_NOT_PRODUCT) }, @@ -705,6 +712,7 @@ RUNTIME_PRODUCT_FLAG_STRUCT, \ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ RUNTIME_MANAGEABLE_FLAG_STRUCT, \ @@ -718,6 +726,7 @@ RUNTIME_PRODUCT_FLAG_STRUCT, \ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -728,6 +737,7 @@ RUNTIME_PRODUCT_FLAG_STRUCT, \ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ RUNTIME_MANAGEABLE_FLAG_STRUCT, \ @@ -742,6 +752,7 @@ JVMCI_PRODUCT_FLAG_STRUCT, \ JVMCI_PD_PRODUCT_FLAG_STRUCT, \ JVMCI_DIAGNOSTIC_FLAG_STRUCT, \ + JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT, \ JVMCI_EXPERIMENTAL_FLAG_STRUCT, \ JVMCI_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ @@ -754,6 +765,7 @@ C1_PRODUCT_FLAG_STRUCT, \ C1_PD_PRODUCT_FLAG_STRUCT, \ C1_DIAGNOSTIC_FLAG_STRUCT, \ + C1_PD_DIAGNOSTIC_FLAG_STRUCT, \ C1_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -765,6 +777,7 @@ C2_PRODUCT_FLAG_STRUCT, \ C2_PD_PRODUCT_FLAG_STRUCT, \ C2_DIAGNOSTIC_FLAG_STRUCT, \ + C2_PD_DIAGNOSTIC_FLAG_STRUCT, \ C2_EXPERIMENTAL_FLAG_STRUCT, \ C2_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ @@ -777,6 +790,7 @@ SHARK_PRODUCT_FLAG_STRUCT, \ SHARK_PD_PRODUCT_FLAG_STRUCT, \ SHARK_DIAGNOSTIC_FLAG_STRUCT, \ + SHARK_PD_DIAGNOSTIC_FLAG_STRUCT, \ SHARK_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/runtime/globals.hpp --- a/hotspot/src/share/vm/runtime/globals.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/runtime/globals.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -644,6 +644,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ manageable, \ @@ -2529,7 +2530,7 @@ develop(bool, GenerateRangeChecks, true, \ "Generate range checks for array accesses") \ \ - develop_pd(bool, ImplicitNullChecks, \ + diagnostic_pd(bool, ImplicitNullChecks, \ "Generate code for implicit null checks") \ \ product_pd(bool, TrapBasedNullChecks, \ @@ -3163,7 +3164,7 @@ "Ratio of call site execution to caller method invocation") \ range(0, max_jint) \ \ - develop_pd(intx, InlineFrequencyCount, \ + diagnostic_pd(intx, InlineFrequencyCount, \ "Count of call site execution necessary to trigger frequent " \ "inlining") \ range(0, max_jint) \ @@ -4144,7 +4145,7 @@ "in the loaded class C. " \ "Check (3) is available only in debug builds.") \ \ - develop_pd(intx, InitArrayShortSize, \ + diagnostic_pd(intx, InitArrayShortSize, \ "Threshold small size (in bytes) for clearing arrays. " \ "Anything this size or smaller may get converted to discrete " \ "scalar stores.") \ @@ -4168,6 +4169,7 @@ #define DECLARE_PRODUCT_FLAG(type, name, value, doc) extern "C" type name; #define DECLARE_PD_PRODUCT_FLAG(type, name, doc) extern "C" type name; #define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc) extern "C" type name; +#define DECLARE_PD_DIAGNOSTIC_FLAG(type, name, doc) extern "C" type name; #define DECLARE_EXPERIMENTAL_FLAG(type, name, value, doc) extern "C" type name; #define DECLARE_MANAGEABLE_FLAG(type, name, value, doc) extern "C" type name; #define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc) extern "C" type name; @@ -4191,6 +4193,7 @@ #define MATERIALIZE_PRODUCT_FLAG(type, name, value, doc) type name = value; #define MATERIALIZE_PD_PRODUCT_FLAG(type, name, doc) type name = pd_##name; #define MATERIALIZE_DIAGNOSTIC_FLAG(type, name, value, doc) type name = value; +#define MATERIALIZE_PD_DIAGNOSTIC_FLAG(type, name, doc) type name = pd_##name; #define MATERIALIZE_EXPERIMENTAL_FLAG(type, name, value, doc) type name = value; #define MATERIALIZE_MANAGEABLE_FLAG(type, name, value, doc) type name = value; #define MATERIALIZE_PRODUCT_RW_FLAG(type, name, value, doc) type name = value; @@ -4221,6 +4224,7 @@ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ DECLARE_MANAGEABLE_FLAG, \ @@ -4235,6 +4239,7 @@ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/runtime/globals_extension.hpp --- a/hotspot/src/share/vm/runtime/globals_extension.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/runtime/globals_extension.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -49,6 +49,7 @@ #define RUNTIME_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define RUNTIME_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define RUNTIME_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define RUNTIME_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define RUNTIME_MANAGEABLE_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define RUNTIME_PRODUCT_RW_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), @@ -61,6 +62,7 @@ #define JVMCI_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define JVMCI_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define JVMCI_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define JVMCI_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define JVMCI_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), @@ -73,6 +75,7 @@ #define C1_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C1_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C1_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define C1_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C1_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C1_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C1_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), @@ -80,6 +83,7 @@ #define C2_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C2_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define C2_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C2_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), @@ -97,6 +101,7 @@ RUNTIME_PRODUCT_FLAG_MEMBER, \ RUNTIME_PD_PRODUCT_FLAG_MEMBER, \ RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER, \ RUNTIME_EXPERIMENTAL_FLAG_MEMBER, \ RUNTIME_NOTPRODUCT_FLAG_MEMBER, \ RUNTIME_MANAGEABLE_FLAG_MEMBER, \ @@ -110,6 +115,7 @@ RUNTIME_PRODUCT_FLAG_MEMBER, \ RUNTIME_PD_PRODUCT_FLAG_MEMBER, \ RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER, \ RUNTIME_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -120,6 +126,7 @@ RUNTIME_PRODUCT_FLAG_MEMBER, \ RUNTIME_PD_PRODUCT_FLAG_MEMBER, \ RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER, \ RUNTIME_EXPERIMENTAL_FLAG_MEMBER, \ RUNTIME_NOTPRODUCT_FLAG_MEMBER, \ RUNTIME_MANAGEABLE_FLAG_MEMBER, \ @@ -134,6 +141,7 @@ JVMCI_PRODUCT_FLAG_MEMBER, \ JVMCI_PD_PRODUCT_FLAG_MEMBER, \ JVMCI_DIAGNOSTIC_FLAG_MEMBER, \ + JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER, \ JVMCI_EXPERIMENTAL_FLAG_MEMBER, \ JVMCI_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ @@ -146,6 +154,7 @@ C1_PRODUCT_FLAG_MEMBER, \ C1_PD_PRODUCT_FLAG_MEMBER, \ C1_DIAGNOSTIC_FLAG_MEMBER, \ + C1_PD_DIAGNOSTIC_FLAG_MEMBER, \ C1_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -157,6 +166,7 @@ C2_PRODUCT_FLAG_MEMBER, \ C2_PD_PRODUCT_FLAG_MEMBER, \ C2_DIAGNOSTIC_FLAG_MEMBER, \ + C2_PD_DIAGNOSTIC_FLAG_MEMBER, \ C2_EXPERIMENTAL_FLAG_MEMBER, \ C2_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ @@ -182,6 +192,7 @@ #define RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), @@ -194,12 +205,14 @@ #define JVMCI_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define C1_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), @@ -213,6 +226,7 @@ #define C2_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define C2_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), @@ -230,6 +244,7 @@ RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, RUNTIME_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE, @@ -243,6 +258,7 @@ RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, IGNORE_CONSTRAINT, @@ -253,6 +269,7 @@ RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, RUNTIME_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE, @@ -267,6 +284,7 @@ JVMCI_PRODUCT_FLAG_MEMBER_WITH_TYPE, JVMCI_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, JVMCI_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, JVMCI_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, @@ -279,6 +297,7 @@ C1_PRODUCT_FLAG_MEMBER_WITH_TYPE, C1_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + C1_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, IGNORE_CONSTRAINT, @@ -290,6 +309,7 @@ C2_PRODUCT_FLAG_MEMBER_WITH_TYPE, C2_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, C2_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + C2_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, C2_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, C2_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, diff -r 44eb314f5b38 -r 2dbd21fdb7a0 hotspot/src/share/vm/shark/shark_globals.hpp --- a/hotspot/src/share/vm/shark/shark_globals.hpp Fri Jun 24 15:06:50 2016 -0700 +++ b/hotspot/src/share/vm/shark/shark_globals.hpp Fri Jul 01 16:50:37 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,7 +31,7 @@ # include "shark_globals_zero.hpp" #endif -#define SHARK_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct) \ +#define SHARK_FLAGS(develop, develop_pd, product, product_pd, diagnostic, diagnostic_pd, notproduct) \ \ product(intx, MaxNodeLimit, 65000, \ "Maximum number of nodes") \ @@ -69,6 +69,7 @@ "Runs LLVM verify over LLVM IR") \ -SHARK_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_NOTPRODUCT_FLAG) +SHARK_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_PD_DIAGNOSTIC_FLAG, + DECLARE_NOTPRODUCT_FLAG) #endif // SHARE_VM_SHARK_SHARK_GLOBALS_HPP diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jaxp/.hgtags --- a/jaxp/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/jaxp/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -366,3 +366,4 @@ a265b8116058c56179c321c38618570b780329be jdk-9+121 f8899b1884e2c4a000dbcc5b1a80954245fe462e jdk-9+122 3c19ab8742c196ac267b3d87e1d19ec3472c708d jdk-9+123 +e04a15153cc293f05fcd60bc98236f50e16af46a jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jaxws/.hgtags --- a/jaxws/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/jaxws/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -369,3 +369,4 @@ fb771fa3a986ccfcb00d743b1956b98c380d1dd8 jdk-9+121 342705d785ffd9e999991a3d4baae2eca58ea7c3 jdk-9+122 c42decd28bbfa817347112ed6053b5fbd30517a2 jdk-9+123 +1600da1665cd2cc127014e8c002b328ec33a9147 jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jaxws/src/java.xml.bind/share/classes/javax/xml/bind/ContextFinder.java --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/ContextFinder.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/ContextFinder.java Fri Jul 01 16:50:37 2016 -0700 @@ -193,7 +193,7 @@ try { Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class, Map.class); // any failure in invoking this method would be considered fatal - Object obj = instantiateProviderIfNecessary(m); + Object obj = instantiateProviderIfNecessary(spFactory); context = m.invoke(obj, contextPath, classLoader, properties); } catch (NoSuchMethodException ignored) { // it's not an error for the provider not to have this method. @@ -203,7 +203,7 @@ // try the old method that doesn't take properties. compatible with 1.0. // it is an error for an implementation not to have both forms of the createContext method. Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class); - Object obj = instantiateProviderIfNecessary(m); + Object obj = instantiateProviderIfNecessary(spFactory); // any failure in invoking this method would be considered fatal context = m.invoke(obj, contextPath, classLoader); } @@ -228,20 +228,20 @@ } } - private static Object instantiateProviderIfNecessary(Method m) throws JAXBException { - Class declaringClass = m.getDeclaringClass(); + private static Object instantiateProviderIfNecessary(Class implClass) throws JAXBException { try { - if (JAXBContextFactory.class.isAssignableFrom(declaringClass)) { + if (JAXBContextFactory.class.isAssignableFrom(implClass)) { return AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override public Object run() throws Exception { - return declaringClass.newInstance(); + return implClass.newInstance(); } }); } return null; - } catch (PrivilegedActionException e) { - throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, declaringClass, e), e); + } catch (PrivilegedActionException x) { + Throwable e = (x.getCause() == null) ? x : x.getCause(); + throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, implClass, e), e); } } @@ -271,7 +271,7 @@ try { Method m = spFactory.getMethod("createContext", Class[].class, Map.class); - Object obj = instantiateProviderIfNecessary(m); + Object obj = instantiateProviderIfNecessary(spFactory); Object context = m.invoke(obj, classes, properties); if (!(context instanceof JAXBContext)) { // the cast would fail, so generate an exception with a nice message @@ -392,7 +392,7 @@ /** - * first factoryId should be the preffered one, + * first factoryId should be the preferred one, * more of those can be provided to support backwards compatibility */ private static String classNameFromPackageProperties(ClassLoader classLoader, diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/.hgtags --- a/jdk/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -367,3 +367,4 @@ 981ae344923f09c46d8d1d5a3ed9fa71deafe0c6 jdk-9+122 c40c8739bcdc88892ff58ebee3fd8a3f287be94d jdk-9+123 7ff61c55b5c6c124592f09b18953222009a204a6 jdk-9+124 +073ab1d4edf5590cf1af7b6d819350c14e425c1a jdk-9+125 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/make/gensrc/GensrcMisc.gmk --- a/jdk/make/gensrc/GensrcMisc.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/make/gensrc/GensrcMisc.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -34,7 +34,11 @@ @@LAUNCHER_NAME@@ => $(LAUNCHER_NAME) ; \ @@RUNTIME_NAME@@ => $(RUNTIME_NAME) ; \ @@VERSION_SHORT@@ => $(VERSION_SHORT) ; \ - @@VERSION_STRING@@ => $(VERSION_STRING), \ + @@VERSION_STRING@@ => $(VERSION_STRING) ; \ + @@VERSION_NUMBER@@ => $(VERSION_NUMBER) ; \ + @@VERSION_PRE@@ => $(VERSION_PRE) ; \ + @@VERSION_BUILD@@ => $(VERSION_BUILD) ; \ + @@VERSION_OPT@@ => $(VERSION_OPT), \ )) GENSRC_JAVA_BASE += $(BUILD_VERSION_JAVA) diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/make/lib/NioLibraries.gmk --- a/jdk/make/lib/NioLibraries.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/make/lib/NioLibraries.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2016, 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 @@ -46,9 +46,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) BUILD_LIBNIO_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS) - BUILD_LIBNIO_EXFILES += \ - GioFileTypeDetector.c \ - # endif ifeq ($(OPENJDK_TARGET_OS), solaris) diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/make/mapfiles/libjava/mapfile-vers --- a/jdk/make/mapfiles/libjava/mapfile-vers Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/make/mapfiles/libjava/mapfile-vers Fri Jul 01 16:50:37 2016 -0700 @@ -56,6 +56,7 @@ JNU_ThrowArrayIndexOutOfBoundsException; JNU_ThrowByName; JNU_ThrowByNameWithLastError; + JNU_ThrowByNameWithMessageAndLastError; JNU_ThrowClassNotFoundException; JNU_ThrowIllegalAccessError; JNU_ThrowIllegalAccessException; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/make/mapfiles/libnio/mapfile-solaris --- a/jdk/make/mapfiles/libnio/mapfile-solaris Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/make/mapfiles/libnio/mapfile-solaris Fri Jul 01 16:50:37 2016 -0700 @@ -131,8 +131,6 @@ Java_sun_nio_ch_SolarisEventPort_port_1get; Java_sun_nio_ch_SolarisEventPort_port_1getn; Java_sun_nio_ch_SolarisEventPort_port_1send; - Java_sun_nio_fs_GioFileTypeDetector_initializeGio; - Java_sun_nio_fs_GioFileTypeDetector_probeGio; Java_sun_nio_fs_UnixNativeDispatcher_init; Java_sun_nio_fs_UnixNativeDispatcher_getcwd; Java_sun_nio_fs_UnixNativeDispatcher_strerror; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/linux/classes/sun/nio/fs/GioFileTypeDetector.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/linux/classes/sun/nio/fs/GioFileTypeDetector.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2008, 2015, 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.nio.fs; + +import java.nio.file.Path; +import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedAction; + +/** + * File type detector that uses the GNOME I/O library to guess the + * MIME type of a file. + */ + +public class GioFileTypeDetector + extends AbstractFileTypeDetector +{ + // true if GIO is available + private final boolean gioAvailable; + + public GioFileTypeDetector() { + gioAvailable = initializeGio(); + } + + @Override + public String implProbeContentType(Path obj) throws IOException { + if (!gioAvailable) + return null; + if (!(obj instanceof UnixPath)) + return null; + + UnixPath path = (UnixPath)obj; + NativeBuffer buffer = NativeBuffers.asNativeBuffer(path.getByteArrayForSysCalls()); + try { + // GIO may access file so need permission check + path.checkRead(); + byte[] type = probeGio(buffer.address()); + return (type == null) ? null : Util.toString(type); + } finally { + buffer.release(); + } + + } + + // GIO + private static native boolean initializeGio(); + // + // The probeGIO() method is synchronized to avert potential problems + // such as crashes due to a suspected lack of thread safety in GIO. + // + private static synchronized native byte[] probeGio(long pathAddress); + + static { + AccessController.doPrivileged(new PrivilegedAction<>() { + public Void run() { + System.loadLibrary("nio"); + return null; + }}); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/linux/native/libnio/fs/GioFileTypeDetector.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/linux/native/libnio/fs/GioFileTypeDetector.c Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2008, 2015, 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. + */ + +#include "jni.h" +#include "jni_util.h" +#include "jvm.h" +#include "jlong.h" + +#include +#include + +#ifdef __solaris__ +#include +#endif + +#if defined(__linux__) +#include +#endif + +/* + * For reference see for example the GFileInfo section at + * https://developer.gnome.org/gio/unstable/. + */ + +/* Definitions for GIO */ + +#define G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "standard::content-type" + +typedef void* gpointer; +typedef struct _GFile GFile; +typedef struct _GFileInfo GFileInfo; +typedef struct _GCancellable GCancellable; +typedef struct _GError GError; + +typedef enum { + G_FILE_QUERY_INFO_NONE = 0 +} GFileQueryInfoFlags; + +typedef void (*g_type_init_func)(void); +typedef void (*g_object_unref_func)(gpointer object); +typedef GFile* (*g_file_new_for_path_func)(const char* path); +typedef GFileInfo* (*g_file_query_info_func)(GFile *file, + const char *attributes, GFileQueryInfoFlags flags, + GCancellable *cancellable, GError **error); +typedef char* (*g_file_info_get_content_type_func)(GFileInfo *info); + +static g_type_init_func g_type_init; +static g_object_unref_func g_object_unref; +static g_file_new_for_path_func g_file_new_for_path; +static g_file_query_info_func g_file_query_info; +static g_file_info_get_content_type_func g_file_info_get_content_type; + + +#include "sun_nio_fs_GioFileTypeDetector.h" + + +JNIEXPORT jboolean JNICALL +Java_sun_nio_fs_GioFileTypeDetector_initializeGio + (JNIEnv* env, jclass this) +{ + void* gio_handle; + + gio_handle = dlopen("libgio-2.0.so", RTLD_LAZY); + if (gio_handle == NULL) { + gio_handle = dlopen("libgio-2.0.so.0", RTLD_LAZY); + if (gio_handle == NULL) { + return JNI_FALSE; + } + } + + g_type_init = (g_type_init_func)dlsym(gio_handle, "g_type_init"); + (*g_type_init)(); + + g_object_unref = (g_object_unref_func)dlsym(gio_handle, "g_object_unref"); + + g_file_new_for_path = + (g_file_new_for_path_func)dlsym(gio_handle, "g_file_new_for_path"); + + g_file_query_info = + (g_file_query_info_func)dlsym(gio_handle, "g_file_query_info"); + + g_file_info_get_content_type = (g_file_info_get_content_type_func) + dlsym(gio_handle, "g_file_info_get_content_type"); + + + if (g_type_init == NULL || + g_object_unref == NULL || + g_file_new_for_path == NULL || + g_file_query_info == NULL || + g_file_info_get_content_type == NULL) + { + dlclose(gio_handle); + return JNI_FALSE; + } + + (*g_type_init)(); + return JNI_TRUE; +} + +JNIEXPORT jbyteArray JNICALL +Java_sun_nio_fs_GioFileTypeDetector_probeGio + (JNIEnv* env, jclass this, jlong pathAddress) +{ + char* path = (char*)jlong_to_ptr(pathAddress); + GFile* gfile; + GFileInfo* gfileinfo; + jbyteArray result = NULL; + + gfile = (*g_file_new_for_path)(path); + gfileinfo = (*g_file_query_info)(gfile, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, + G_FILE_QUERY_INFO_NONE, NULL, NULL); + if (gfileinfo != NULL) { + const char* mime = (*g_file_info_get_content_type)(gfileinfo); + if (mime != NULL) { + jsize len = strlen(mime); + result = (*env)->NewByteArray(env, len); + if (result != NULL) { + (*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)mime); + } + } + (*g_object_unref)(gfileinfo); + } + (*g_object_unref)(gfile); + + return result; +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/macosx/native/libjava/java_props_macosx.c --- a/jdk/src/java.base/macosx/native/libjava/java_props_macosx.c Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/java.base/macosx/native/libjava/java_props_macosx.c Fri Jul 01 16:50:37 2016 -0700 @@ -182,7 +182,17 @@ // Copy out the char* osVersionCStr = strdup([nsVerStr UTF8String]); } - + // Fallback if running on pre-10.9 Mac OS + if (osVersionCStr == NULL) { + NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile : + @"/System/Library/CoreServices/SystemVersion.plist"]; + if (version != NULL) { + NSString *nsVerStr = [version objectForKey : @"ProductVersion"]; + if (nsVerStr != NULL) { + osVersionCStr = strdup([nsVerStr UTF8String]); + } + } + } if (osVersionCStr == NULL) { osVersionCStr = strdup("Unknown"); } @@ -190,7 +200,9 @@ } -static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) { +static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, + CFStringRef inHostKey, CFStringRef inPortKey, + CFStringRef *outProxyHost, int *ioProxyPort) { /* See if the proxy is enabled. */ CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey); if (cf_enabled == NULL) { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/lang/ApplicationShutdownHooks.java --- a/jdk/src/java.base/share/classes/java/lang/ApplicationShutdownHooks.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/java/lang/ApplicationShutdownHooks.java Fri Jul 01 16:50:37 2016 -0700 @@ -102,9 +102,13 @@ hook.start(); } for (Thread hook : threads) { - try { - hook.join(); - } catch (InterruptedException x) { } + while (true) { + try { + hook.join(); + break; + } catch (InterruptedException ignored) { + } + } } } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/lang/Runtime.java --- a/jdk/src/java.base/share/classes/java/lang/Runtime.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java Fri Jul 01 16:50:37 2016 -0700 @@ -27,8 +27,6 @@ import java.io.*; import java.math.BigInteger; -import java.util.AbstractList; -import java.util.Arrays; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -36,11 +34,9 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.RandomAccess; import java.util.StringTokenizer; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; -import sun.security.action.GetPropertyAction; /** * Every Java application has a single instance of class @@ -941,8 +937,9 @@ */ public static Version version() { if (version == null) { - version = Version.parse( - GetPropertyAction.privilegedGetProperty("java.runtime.version")); + version = new Version(VersionProps.versionNumbers(), + VersionProps.pre(), VersionProps.build(), + VersionProps.optional()); } return version; } @@ -1084,86 +1081,12 @@ private final Optional build; private final Optional optional; - - // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)? - // RE limits the format of version strings - // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))? - - private static final String VNUM - = "(?[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)"; - private static final String VNUM_GROUP = "VNUM"; - - private static final String PRE = "(?:-(?
[a-zA-Z0-9]+))?";
-        private static final String PRE_GROUP   = "PRE";
-
-        private static final String BUILD
-            = "(?:(?\\+)(?0|[1-9][0-9]*)?)?";
-        private static final String PLUS_GROUP  = "PLUS";
-        private static final String BUILD_GROUP = "BUILD";
-
-        private static final String OPT      = "(?:-(?[-a-zA-Z0-9.]+))?";
-        private static final String OPT_GROUP   = "OPT";
-
-        private static final String VSTR_FORMAT
-            = "^" + VNUM + PRE + BUILD + OPT + "$";
-        private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
-
-        /**
-         * Constructs a valid version string containing
-         * a version number followed by pre-release and
-         * build information.
-         *
-         * @param  s
-         *         A string to be interpreted as a version
-         *
-         * @throws  IllegalArgumentException
-         *          If the given string cannot be interpreted as a valid
-         *          version
-         *
-         * @throws  NullPointerException
-         *          If {@code s} is {@code null}
-         *
-         * @throws  NumberFormatException
-         *          If an element of the version number or the build number
-         *          cannot be represented as an {@link Integer}
-         */
-        private Version(String s) {
-            if (s == null)
-                throw new NullPointerException();
-
-            Matcher m = VSTR_PATTERN.matcher(s);
-            if (!m.matches())
-                throw new IllegalArgumentException("Invalid version string: '"
-                                                   + s + "'");
-
-            // $VNUM is a dot-separated list of integers of arbitrary length
-            List list = new ArrayList<>();
-            for (String i : m.group(VNUM_GROUP).split("\\."))
-                list.add(Integer.parseInt(i));
-            version = Collections.unmodifiableList(list);
-
-            pre = Optional.ofNullable(m.group(PRE_GROUP));
-
-            String b = m.group(BUILD_GROUP);
-            // $BUILD is an integer
-            build = (b == null)
-                ? Optional.empty()
-                : Optional.ofNullable(Integer.parseInt(b));
-
-            optional = Optional.ofNullable(m.group(OPT_GROUP));
-
-            // empty '+'
-            if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
-                if (optional.isPresent()) {
-                    if (pre.isPresent())
-                        throw new IllegalArgumentException("'+' found with"
-                            + " pre-release and optional components:'" + s
-                            + "'");
-                } else {
-                    throw new IllegalArgumentException("'+' found with neither"
-                        + " build or optional components: '" + s + "'");
-                }
-            }
+        Version(List version, Optional pre,
+                Optional build, Optional optional) {
+            this.version = Collections.unmodifiableList(version);
+            this.pre = pre;
+            this.build = build;
+            this.optional = optional;
         }
 
         /**
@@ -1189,7 +1112,7 @@
          * @return  The Version of the given string
          */
         public static Version parse(String s) {
-            return new Version(s);
+            return VersionBuilder.parse(s);
         }
 
         /**
@@ -1518,4 +1441,86 @@
         }
     }
 
+    private static class VersionBuilder {
+        // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)?
+        // RE limits the format of version strings
+        // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))?
+
+        private static final String VNUM
+            = "(?[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)";
+        private static final String VNUM_GROUP  = "VNUM";
+
+        private static final String PRE      = "(?:-(?
[a-zA-Z0-9]+))?";
+        private static final String PRE_GROUP   = "PRE";
+
+        private static final String BUILD
+            = "(?:(?\\+)(?0|[1-9][0-9]*)?)?";
+        private static final String PLUS_GROUP  = "PLUS";
+        private static final String BUILD_GROUP = "BUILD";
+
+        private static final String OPT      = "(?:-(?[-a-zA-Z0-9.]+))?";
+        private static final String OPT_GROUP   = "OPT";
+
+        private static final String VSTR_FORMAT
+            = "^" + VNUM + PRE + BUILD + OPT + "$";
+        private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
+
+        /**
+         * Constructs a valid version string containing
+         * a version number followed by pre-release and
+         * build information.
+         *
+         * @param  s
+         *         A string to be interpreted as a version
+         *
+         * @throws  IllegalArgumentException
+         *          If the given string cannot be interpreted as a valid
+         *          version
+         *
+         * @throws  NullPointerException
+         *          If {@code s} is {@code null}
+         *
+         * @throws  NumberFormatException
+         *          If an element of the version number or the build number
+         *          cannot be represented as an {@link Integer}
+         */
+        static Version parse(String s) {
+            if (s == null)
+                throw new NullPointerException();
+
+            Matcher m = VSTR_PATTERN.matcher(s);
+            if (!m.matches())
+                throw new IllegalArgumentException("Invalid version string: '"
+                                                   + s + "'");
+
+            // $VNUM is a dot-separated list of integers of arbitrary length
+            List version = new ArrayList<>();
+            for (String i : m.group(VNUM_GROUP).split("\\."))
+                version.add(Integer.parseInt(i));
+
+            Optional pre = Optional.ofNullable(m.group(PRE_GROUP));
+
+            String b = m.group(BUILD_GROUP);
+            // $BUILD is an integer
+            Optional build = (b == null)
+                ? Optional.empty()
+                : Optional.of(Integer.parseInt(b));
+
+            Optional optional = Optional.ofNullable(m.group(OPT_GROUP));
+
+            // empty '+'
+            if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
+                if (optional.isPresent()) {
+                    if (pre.isPresent())
+                        throw new IllegalArgumentException("'+' found with"
+                            + " pre-release and optional components:'" + s
+                            + "'");
+                } else {
+                    throw new IllegalArgumentException("'+' found with neither"
+                        + " build or optional components: '" + s + "'");
+                }
+            }
+            return new Version(version, pre, build, optional);
+        }
+    }
 }
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/lang/StringLatin1.java
--- a/jdk/src/java.base/share/classes/java/lang/StringLatin1.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StringLatin1.java	Fri Jul 01 16:50:37 2016 -0700
@@ -137,8 +137,8 @@
                 char c1 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(value, k));
                 char c2 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(other, k));
                 if (c1 != c2) {
-                    c1 = (char) CharacterDataLatin1.instance.toLowerCase(c1);
-                    c2 = (char) CharacterDataLatin1.instance.toLowerCase(c2);
+                    c1 = Character.toLowerCase(c1);
+                    c2 = Character.toLowerCase(c2);
                     if (c1 != c2) {
                         return c1 - c2;
                     }
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/lang/StringUTF16.java
--- a/jdk/src/java.base/share/classes/java/lang/StringUTF16.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StringUTF16.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -259,17 +259,7 @@
 
     @HotSpotIntrinsicCandidate
     public static int compareToLatin1(byte[] value, byte[] other) {
-        int len1 = length(value);
-        int len2 = StringLatin1.length(other);
-        int lim = Math.min(len1, len2);
-        for (int k = 0; k < lim; k++) {
-            char c1 = getChar(value, k);
-            char c2 = StringLatin1.getChar(other, k);
-            if (c1 != c2) {
-                return c1 - c2;
-            }
-        }
-        return len1 - len2;
+        return -StringLatin1.compareToUTF16(other, value);
     }
 
     public static int compareToCI(byte[] value, byte[] other) {
@@ -295,25 +285,7 @@
     }
 
     public static int compareToCI_Latin1(byte[] value, byte[] other) {
-        int len1 = length(value);
-        int len2 = StringLatin1.length(other);
-        int lim = Math.min(len1, len2);
-        for (int k = 0; k < lim; k++) {
-            char c1 = getChar(value, k);
-            char c2 = StringLatin1.getChar(other, k);
-            if (c1 != c2) {
-                c1 = Character.toUpperCase(c1);
-                c2 = Character.toUpperCase(c2);
-                if (c1 != c2) {
-                    c1 = Character.toLowerCase(c1);
-                    c2 = Character.toLowerCase(c2);
-                    if (c1 != c2) {
-                        return c1 - c2;
-                    }
-                }
-            }
-        }
-        return len1 - len2;
+        return -StringLatin1.compareToCI_UTF16(other, value);
     }
 
     public static int hashCode(byte[] value) {
@@ -566,24 +538,7 @@
     public static boolean regionMatchesCI_Latin1(byte[] value, int toffset,
                                                  byte[] other, int ooffset,
                                                  int len) {
-        int last = toffset + len;
-        while (toffset < last) {
-            char c1 = getChar(value, toffset++);
-            char c2 = (char)(other[ooffset++] & 0xff);
-            if (c1 == c2) {
-                continue;
-            }
-            char u1 = Character.toUpperCase(c1);
-            char u2 = Character.toUpperCase(c2);
-            if (u1 == u2) {
-                continue;
-            }
-            if (Character.toLowerCase(u1) == Character.toLowerCase(u2)) {
-                continue;
-            }
-            return false;
-        }
-        return true;
+        return StringLatin1.regionMatchesCI_UTF16(other, ooffset, value, toffset, len);
     }
 
     public static String toLowerCase(String str, byte[] value, Locale locale) {
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/lang/VersionProps.java.template
--- a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template	Fri Jul 01 16:50:37 2016 -0700
@@ -26,6 +26,9 @@
 package java.lang;
 
 import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
 
 class VersionProps {
 
@@ -42,6 +45,18 @@
     private static final String java_runtime_version =
         "@@VERSION_STRING@@";
 
+    private static final String VERSION_NUMBER =
+        "@@VERSION_NUMBER@@";
+
+    private static final String VERSION_BUILD =
+        "@@VERSION_BUILD@@";
+
+    private static final String VERSION_PRE =
+        "@@VERSION_PRE@@";
+
+    private static final String VERSION_OPT =
+        "@@VERSION_OPT@@";
+
     static {
         init();
     }
@@ -52,6 +67,44 @@
         System.setProperty("java.runtime.name", java_runtime_name);
     }
 
+    static List versionNumbers() {
+        List versionNumbers = new ArrayList<>(4);
+        int prevIndex = 0;
+        int index = VERSION_NUMBER.indexOf('.');
+        while (index > 0) {
+            versionNumbers.add(
+                    Integer.parseInt(VERSION_NUMBER, prevIndex, index, 10));
+            prevIndex = index + 1; // Skip the period
+            index = VERSION_NUMBER.indexOf('.', prevIndex);
+        }
+        versionNumbers.add(Integer.parseInt(VERSION_NUMBER,
+                prevIndex, VERSION_NUMBER.length(), 10));
+        return versionNumbers;
+    }
+
+    static Optional pre() {
+        return optionalOf(VERSION_PRE);
+    }
+
+    static Optional build() {
+        return VERSION_BUILD.isEmpty() ?
+                Optional.empty() :
+                Optional.of(Integer.parseInt(VERSION_BUILD));
+    }
+
+    static Optional optional() {
+        return optionalOf(VERSION_OPT);
+    }
+
+    // Treat empty strings as value not being present
+    private static Optional optionalOf(String value) {
+        if (!value.isEmpty()) {
+            return Optional.of(value);
+        } else {
+            return Optional.empty();
+        }
+    }
+
     /**
      * In case you were wondering this method is called by java -version.
      * Sad that it prints to stderr; would be nicer if default printed on
@@ -111,4 +164,4 @@
                    java_vm_info + ")");
     }
 
-}
\ No newline at end of file
+}
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1275,8 +1275,6 @@
             this.methodName = methodName;
             this.at = at;
 
-            // Assert method name is correctly derived from value name
-            assert methodName.equals(toMethodName(name()));
             // Assert that return type is correct
             // Otherwise, when disabled avoid using reflection
             assert at.returnType == getReturnType(methodName);
@@ -1311,16 +1309,6 @@
             throw new IllegalArgumentException("No AccessMode value for method name " + methodName);
         }
 
-        private static String toMethodName(String name) {
-            StringBuilder s = new StringBuilder(name.toLowerCase());
-            int i;
-            while ((i = s.indexOf("_")) !=  -1) {
-                s.deleteCharAt(i);
-                s.setCharAt(i, Character.toUpperCase(s.charAt(i)));
-            }
-            return s.toString();
-        }
-
         private static Class getReturnType(String name) {
             try {
                 Method m = VarHandle.class.getMethod(name, Object[].class);
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/Certificate.java
--- a/jdk/src/java.base/share/classes/java/security/Certificate.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/Certificate.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -60,9 +60,10 @@
  *             This Certificate interface is entirely deprecated and
  *             is here to allow for a smooth transition to the new
  *             package.
+ *             This class is subject to removal in a future version of Java SE.
  * @see java.security.cert.Certificate
  */
-@Deprecated
+@Deprecated(since="1.2", forRemoval=true)
 public interface Certificate {
 
     /**
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/Acl.java
--- a/jdk/src/java.base/share/classes/java/security/acl/Acl.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/Acl.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,9 +85,10 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
 
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public interface Acl extends Owner {
 
     /**
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/AclEntry.java
--- a/jdk/src/java.base/share/classes/java/security/acl/AclEntry.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/AclEntry.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -53,8 +53,9 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public interface AclEntry extends Cloneable {
 
     /**
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/AclNotFoundException.java
--- a/jdk/src/java.base/share/classes/java/security/acl/AclNotFoundException.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/AclNotFoundException.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -33,8 +33,9 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public class AclNotFoundException extends Exception {
 
     private static final long serialVersionUID = 5684295034092681791L;
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/Group.java
--- a/jdk/src/java.base/share/classes/java/security/acl/Group.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/Group.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -42,8 +42,9 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public interface Group extends Principal {
 
     /**
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/LastOwnerException.java
--- a/jdk/src/java.base/share/classes/java/security/acl/LastOwnerException.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/LastOwnerException.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,8 +35,9 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public class LastOwnerException extends Exception {
 
     private static final long serialVersionUID = -5141997548211140359L;
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/NotOwnerException.java
--- a/jdk/src/java.base/share/classes/java/security/acl/NotOwnerException.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/NotOwnerException.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,9 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public class NotOwnerException extends Exception {
 
     private static final long serialVersionUID = -5555597911163362399L;
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/Owner.java
--- a/jdk/src/java.base/share/classes/java/security/acl/Owner.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/Owner.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -38,8 +38,9 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public interface Owner {
 
     /**
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/Permission.java
--- a/jdk/src/java.base/share/classes/java/security/acl/Permission.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/Permission.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,9 @@
  *
  * @deprecated This package has been replaced by {@code java.security.Policy}
  *      and related classes since 1.2.
+ *      This class is subject to removal in a future version of Java SE.
  */
-@Deprecated
+@Deprecated(since="9", forRemoval=true)
 public interface Permission {
 
     /**
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/security/acl/package-info.java
--- a/jdk/src/java.base/share/classes/java/security/acl/package-info.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/security/acl/package-info.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -27,7 +27,8 @@
  * The classes and interfaces in this package have been deprecated. New
  * classes should not be added to this package. The {@code java.security}
  * package contains suitable replacements. See {@link java.security.Policy}
- * and related classes for details.
+ * and related classes for details. This package is subject to removal in a
+ * future version of Java SE.
  *
  * @since 1.1
  */
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/text/DateFormatSymbols.java
--- a/jdk/src/java.base/share/classes/java/text/DateFormatSymbols.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/text/DateFormatSymbols.java	Fri Jul 01 16:50:37 2016 -0700
@@ -221,7 +221,7 @@
      * 
      * The zone ID is not localized; it's one of the valid IDs of
      * the {@link java.util.TimeZone TimeZone} class that are not
-     * custom IDs.
+     * custom IDs.
      * All other entries are localized names.
      * @see java.util.TimeZone
      * @serial
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Fri Jul 01 16:50:37 2016 -0700
@@ -295,13 +295,13 @@
      * @throws IllegalStateException if the zip file has been closed
      */
     public ZipEntry getEntry(String name) {
-
         Objects.requireNonNull(name, "name");
         synchronized (this) {
             ensureOpen();
-            int pos = zsrc.getEntryPos(zc.getBytes(name), true);
+            byte[] bname = zc.getBytes(name);
+            int pos = zsrc.getEntryPos(bname, true);
             if (pos != -1) {
-                return getZipEntry(name, pos);
+                return getZipEntry(name, bname, pos);
             }
         }
         return null;
@@ -492,7 +492,7 @@
                     throw new NoSuchElementException();
                 }
                 // each "entry" has 3 ints in table entries
-                return getZipEntry(null, zsrc.getEntryPos(i++ * 3));
+                return getZipEntry(null, null, zsrc.getEntryPos(i++ * 3));
             }
         }
 
@@ -527,13 +527,17 @@
     }
 
     /* Checks ensureOpen() before invoke this method */
-    private ZipEntry getZipEntry(String name, int pos) {
+    private ZipEntry getZipEntry(String name, byte[] bname, int pos) {
         byte[] cen = zsrc.cen;
         int nlen = CENNAM(cen, pos);
         int elen = CENEXT(cen, pos);
         int clen = CENCOM(cen, pos);
         int flag = CENFLG(cen, pos);
-        if (name == null) {
+        if (name == null || bname.length != nlen) {
+            // to use the entry name stored in cen, if the passed in name is
+            // (1) null, invoked from iterator, or
+            // (2) not equal to the name stored, a slash is appended during
+            // getEntryPos() search.
             if (!zc.isUTF8() && (flag & EFS) != 0) {
                 name = zc.toStringUTF8(cen, pos + CENHDR, nlen);
             } else {
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/javax/crypto/Cipher.java
--- a/jdk/src/java.base/share/classes/javax/crypto/Cipher.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/Cipher.java	Fri Jul 01 16:50:37 2016 -0700
@@ -93,7 +93,7 @@
  * provide authenticity assurances for both confidential data and
  * Additional Associated Data (AAD) that is not encrypted.  (Please see
  *  RFC 5116  for more
- * information on AEAD and AEAD algorithms such as GCM/CCM.) Both
+ * information on AEAD and AAD algorithms such as GCM/CCM.) Both
  * confidential and AAD data can be used when calculating the
  * authentication tag (similar to a {@link Mac}).  This tag is appended
  * to the ciphertext during encryption, and is verified on decryption.
@@ -1186,7 +1186,7 @@
      * determined from the given key, or if the given key has a keysize that
      * exceeds the maximum allowable keysize (as determined from the
      * configured jurisdiction policy files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
@@ -1239,7 +1239,7 @@
      * determined from the given key, or if the given key has a keysize that
      * exceeds the maximum allowable keysize (as determined from the
      * configured jurisdiction policy files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
@@ -1325,7 +1325,7 @@
      * algorithm parameters imply a cryptographic strength that would exceed
      * the legal limits (as determined from the configured jurisdiction
      * policy files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
@@ -1386,7 +1386,7 @@
      * algorithm parameters imply a cryptographic strength that would exceed
      * the legal limits (as determined from the configured jurisdiction
      * policy files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
@@ -1468,7 +1468,7 @@
      * algorithm parameters imply a cryptographic strength that would exceed
      * the legal limits (as determined from the configured jurisdiction
      * policy files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
@@ -1529,7 +1529,7 @@
      * algorithm parameters imply a cryptographic strength that would exceed
      * the legal limits (as determined from the configured jurisdiction
      * policy files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
@@ -1616,7 +1616,7 @@
      * in the given certificate has a keysize that exceeds the maximum
      * allowable keysize (as determined by the configured jurisdiction policy
      * files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
@@ -1686,7 +1686,7 @@
      * in the given certificate has a keysize that exceeds the maximum
      * allowable keysize (as determined by the configured jurisdiction policy
      * files).
-     * @throws UnsupportedOperationException if (@code opmode} is
+     * @throws UnsupportedOperationException if {@code opmode} is
      * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
      * by the underlying {@code CipherSpi}.
      */
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/jdk/internal/jrtfs/ExplodedImage.java
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/ExplodedImage.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/ExplodedImage.java	Fri Jul 01 16:50:37 2016 -0700
@@ -25,6 +25,7 @@
 package jdk.internal.jrtfs;
 
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.file.DirectoryStream;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystemException;
@@ -138,6 +139,15 @@
             }
             return children;
         }
+
+        @Override
+        public long size() {
+            try {
+                return isDirectory() ? 0 : Files.size(path);
+            } catch (IOException ex) {
+                throw new UncheckedIOException(ex);
+            }
+        }
     }
 
     @Override
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java
--- a/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java	Fri Jul 01 16:50:37 2016 -0700
@@ -222,7 +222,8 @@
                 // Any files in META-INF/ will be indexed explicitly
                 if (fileName.equals("META-INF/") ||
                     fileName.equals(INDEX_NAME) ||
-                    fileName.equals(JarFile.MANIFEST_NAME))
+                    fileName.equals(JarFile.MANIFEST_NAME) ||
+                    fileName.startsWith("META-INF/versions/"))
                     continue;
 
                 if (!metaInfFilenames || !fileName.startsWith("META-INF/")) {
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Fri Jul 01 16:50:37 2016 -0700
@@ -60,6 +60,9 @@
 \                  limit the universe of observable modules\n\
 \    -listmods[:[,...]]\n\
 \                  list the observable modules and exit\n\
+\    --dry-run     create VM but do not execute main method.\n\
+\                  This --dry-run option may be useful for validating the\n\
+\                  command-line options such as the module system configuration.\n\
 \    -D=\n\
 \                  set a system property\n\
 \    -verbose:[class|gc|jni]\n\
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java
--- a/jdk/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -97,10 +97,11 @@
                 t.setDaemon(true);
                 return t;
             }
-        });
+        }, new ThreadPoolExecutor.DiscardPolicy());
         threadMgr.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
         threadMgr.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
         threadMgr.setKeepAliveTime(5000, TimeUnit.MILLISECONDS);
+        threadMgr.allowCoreThreadTimeOut(true);
         responseCache = Cache.newSoftMemoryCache(cacheCapacity, cacheLifetime);
     }
 
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/native/libjava/jni_util.c
--- a/jdk/src/java.base/share/native/libjava/jni_util.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/native/libjava/jni_util.c	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -147,9 +147,9 @@
     JNU_ThrowByName(env, "java/lang/InstantiationException", msg);
 }
 
-
-/* Throw an exception by name, using the string returned by
- * JVM_LastErrorString for the detail string.  If the last-error
+/*
+ * Throw an exception by name, using the string returned by
+ * getLastErrorString for the detail string. If the last-error
  * string is NULL, use the given default detail string.
  */
 JNIEXPORT void JNICALL
@@ -174,9 +174,64 @@
     }
 }
 
-/* Throw an IOException, using the last-error string for the detail
- * string.  If the last-error string is NULL, use the given default
- * detail string.
+/*
+ * Throw an exception by name, using a given message and the string
+ * returned by getLastErrorString to construct the detail string.
+ */
+JNIEXPORT void JNICALL
+JNU_ThrowByNameWithMessageAndLastError
+  (JNIEnv *env, const char *name, const char *message)
+{
+    char buf[256];
+    size_t n = getLastErrorString(buf, sizeof(buf));
+    size_t messagelen = message == NULL ? 0 : strlen(message);
+
+    if (n > 0) {
+        jstring s = JNU_NewStringPlatform(env, buf);
+        if (s != NULL) {
+            jobject x = NULL;
+            if (messagelen) {
+                jstring s2 = NULL;
+                size_t messageextlen = messagelen + 4;
+                char *str1 = (char *)malloc((messageextlen) * sizeof(char));
+                if (str1 == 0) {
+                    JNU_ThrowOutOfMemoryError(env, 0);
+                    return;
+                }
+                jio_snprintf(str1, messageextlen, " (%s)", message);
+                s2 = (*env)->NewStringUTF(env, str1);
+                free(str1);
+                if (s2 != NULL) {
+                    jstring s3 = JNU_CallMethodByName(
+                                     env, NULL, s, "concat",
+                                     "(Ljava/lang/String;)Ljava/lang/String;",
+                                     s2).l;
+                    (*env)->DeleteLocalRef(env, s2);
+                    if (s3 != NULL) {
+                        (*env)->DeleteLocalRef(env, s);
+                        s = s3;
+                    }
+                }
+            }
+            x = JNU_NewObjectByName(env, name, "(Ljava/lang/String;)V", s);
+            if (x != NULL) {
+                (*env)->Throw(env, x);
+            }
+        }
+    }
+
+    if (!(*env)->ExceptionOccurred(env)) {
+        if (messagelen) {
+            JNU_ThrowByName(env, name, message);
+        } else {
+            JNU_ThrowByName(env, name, "no further information");
+        }
+    }
+}
+
+/*
+ * Convenience method.
+ * Call JNU_ThrowByNameWithLastError for java.io.IOException.
  */
 JNIEXPORT void JNICALL
 JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail)
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/native/libjava/jni_util.h
--- a/jdk/src/java.base/share/native/libjava/jni_util.h	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/native/libjava/jni_util.h	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,15 +98,22 @@
 JNU_ThrowInstantiationException(JNIEnv *env, const char *msg);
 
 /* Throw an exception by name, using the string returned by
- * JVM_LastErrorString for the detail string.  If the last-error
+ * getLastErrorString for the detail string. If the last-error
  * string is NULL, use the given default detail string.
  */
 JNIEXPORT void JNICALL
 JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
-                             const char *defaultMessage);
+                             const char *defaultDetail);
+
+/* Throw an exception by name, using a given message and the string
+ * returned by getLastErrorString to construct the detail string.
+ */
+JNIEXPORT void JNICALL
+JNU_ThrowByNameWithMessageAndLastError
+  (JNIEnv *env, const char *name, const char *message);
 
 /* Throw an IOException, using the last-error string for the detail
- * string.  If the last-error string is NULL, use the given default
+ * string. If the last-error string is NULL, use the given default
  * detail string.
  */
 JNIEXPORT void JNICALL
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/share/native/libjli/java.c
--- a/jdk/src/java.base/share/native/libjli/java.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/share/native/libjli/java.c	Fri Jul 01 16:50:37 2016 -0700
@@ -68,6 +68,7 @@
 static jboolean showVersion = JNI_FALSE;  /* print but continue */
 static jboolean printUsage = JNI_FALSE;   /* print and exit*/
 static jboolean printXUsage = JNI_FALSE;  /* print and exit*/
+static jboolean dryRun = JNI_FALSE;       /* initialize VM and exit */
 static char     *showSettings = NULL;      /* print but continue */
 static char     *listModules = NULL;
 
@@ -489,14 +490,18 @@
     mainArgs = CreateApplicationArgs(env, argv, argc);
     CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
 
-    /* Invoke main method. */
-    (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
+    if (dryRun) {
+        ret = 0;
+    } else {
+        /* Invoke main method. */
+        (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
 
-    /*
-     * The launcher's exit code (in the absence of calls to
-     * System.exit) will be non-zero if main threw an exception.
-     */
-    ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
+        /*
+         * The launcher's exit code (in the absence of calls to
+         * System.exit) will be non-zero if main threw an exception.
+         */
+        ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
+    }
     LEAVE();
 }
 
@@ -1203,6 +1208,8 @@
             return JNI_TRUE;
         } else if (JLI_StrCmp(arg, "-showversion") == 0) {
             showVersion = JNI_TRUE;
+        } else if (JLI_StrCmp(arg, "--dry-run") == 0) {
+            dryRun = JNI_TRUE;
         } else if (JLI_StrCmp(arg, "-X") == 0) {
             printXUsage = JNI_TRUE;
             return JNI_TRUE;
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java
--- a/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, 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
@@ -88,8 +88,7 @@
             GetPropertyAction.privilegedGetProperty("user.home"), ".mime.types");
         Path etcMimeTypes = Paths.get("/etc/mime.types");
 
-        return chain(new GioFileTypeDetector(),
-                     new MimeTypesFileTypeDetector(userMimeTypes),
+        return chain(new MimeTypesFileTypeDetector(userMimeTypes),
                      new MimeTypesFileTypeDetector(etcMimeTypes));
     }
 }
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/unix/classes/sun/nio/fs/GioFileTypeDetector.java
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/GioFileTypeDetector.java	Fri Jun 24 15:06:50 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2008, 2015, 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.nio.fs;
-
-import java.nio.file.Path;
-import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * File type detector that uses the GNOME I/O library to guess the
- * MIME type of a file.
- */
-
-public class GioFileTypeDetector
-    extends AbstractFileTypeDetector
-{
-    // true if GIO is available
-    private final boolean gioAvailable;
-
-    public GioFileTypeDetector() {
-        gioAvailable = initializeGio();
-    }
-
-    @Override
-    public String implProbeContentType(Path obj) throws IOException {
-        if (!gioAvailable)
-            return null;
-        if (!(obj instanceof UnixPath))
-            return null;
-
-        UnixPath path = (UnixPath)obj;
-        NativeBuffer buffer = NativeBuffers.asNativeBuffer(path.getByteArrayForSysCalls());
-        try {
-            // GIO may access file so need permission check
-            path.checkRead();
-            byte[] type = probeGio(buffer.address());
-            return (type == null) ? null : Util.toString(type);
-        } finally {
-            buffer.release();
-        }
-
-    }
-
-    // GIO
-    private static native boolean initializeGio();
-    //
-    // The probeGIO() method is synchronized to avert potential problems
-    // such as crashes due to a suspected lack of thread safety in GIO.
-    //
-    private static synchronized native byte[] probeGio(long pathAddress);
-
-    static {
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
-    }
-}
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/unix/native/libnet/NetworkInterface.c
--- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c	Fri Jul 01 16:50:37 2016 -0700
@@ -621,8 +621,8 @@
     (*env)->ReleaseStringUTFChars(env, name, name_utf);
 
     if (ret < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGLIFFLAGS failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "getFlags() failed");
         return -1;
     }
 
@@ -1061,8 +1061,8 @@
         // If EPROTONOSUPPORT is returned it means we don't have
         // support for this proto so don't throw an exception.
         if (errno != EPROTONOSUPPORT) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "Socket creation failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Socket creation failed");
         }
         return -1;
     }
@@ -1087,13 +1087,13 @@
     if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
         if (errno == EPROTONOSUPPORT) {
             if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                             "IPV6 Socket creation failed");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                 return -1;
             }
         } else { // errno is not NOSUPPORT
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "IPV4 Socket creation failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
             return -1;
         }
     }
@@ -1122,15 +1122,15 @@
     // SIOCGIFCOUNT doesn't work
     ifc.ifc_buf = NULL;
     if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFCONF failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
         return ifs;
     }
 #elif defined(_AIX)
     ifc.ifc_buf = NULL;
     if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGSIZIFCONF failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGSIZIFCONF) failed");
         return ifs;
     }
 #endif /* __linux__ */
@@ -1142,8 +1142,8 @@
     siocgifconfRequest = CSIOCGIFCONF;
 #endif
     if (ioctl(sock, siocgifconfRequest, (char *)&ifc) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFCONF failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
         free(buf);
         return ifs;
     }
@@ -1268,8 +1268,8 @@
 
     ifc.ifc_buf = NULL;
     if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                    "ioctl SIOCGSIZIFCONF failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGSIZIFCONF) failed");
         return ifs;
     }
     bufsize = ifc.ifc_len;
@@ -1282,8 +1282,8 @@
     ifc.ifc_len = bufsize;
     ifc.ifc_buf = buf;
     if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl CSIOCGIFCONF failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
         free(buf);
         return ifs;
     }
@@ -1368,16 +1368,16 @@
 
     // Let's make sure the interface does have a broadcast address.
     if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2)  < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFFLAGS failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFFLAGS) failed");
         return ret;
     }
 
     if (if2.ifr_flags & IFF_BROADCAST) {
         // It does, let's retrieve it
         if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "ioctl SIOCGIFBRDADDR failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFBRDADDR) failed");
             return ret;
         }
 
@@ -1400,8 +1400,8 @@
     strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
 
     if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFNETMASK failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK) failed");
         return -1;
     }
 
@@ -1463,8 +1463,8 @@
     memset((char *)&ifr, 0, sizeof(ifr));
     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
     if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFHWADDR failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFHWADDR) failed");
         return -1;
     }
 
@@ -1493,8 +1493,8 @@
     }
 
     if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFMTU failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFMTU) failed");
         return -1;
     }
 
@@ -1535,15 +1535,15 @@
     if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
         if (errno == EPROTONOSUPPORT) {
             if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                             "IPV6 Socket creation failed");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                 return -1;
             }
 
             alreadyV6=1;
         } else { // errno is not NOSUPPORT
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "IPV4 Socket creation failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
             return -1;
         }
     }
@@ -1562,8 +1562,8 @@
         if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
             close(sock);
             if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                             "IPV6 Socket creation failed");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                 return -1;
             }
         }
@@ -1607,8 +1607,8 @@
     numifs.lifn_family = family;
     numifs.lifn_flags = 0;
     if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGLIFNUM failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNUM) failed");
         return ifs;
     }
 
@@ -1621,8 +1621,8 @@
     ifc.lifc_len = bufsize;
     ifc.lifc_buf = buf;
     if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGLIFCONF failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFCONF) failed");
         free(buf);
         return ifs;
     }
@@ -1689,16 +1689,16 @@
 
     // Let's make sure the interface does have a broadcast address
     if (ioctl(sock, SIOCGLIFFLAGS, (char *)&if2)  < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGLIFFLAGS failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFFLAGS) failed");
         return ret;
     }
 
     if (if2.lifr_flags & IFF_BROADCAST) {
         // It does, let's retrieve it
         if (ioctl(sock, SIOCGLIFBRDADDR, (char *)&if2) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "ioctl SIOCGLIFBRDADDR failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFBRDADDR) failed");
             return ret;
         }
 
@@ -1721,8 +1721,8 @@
     strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
 
     if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGLIFNETMASK failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNETMASK) failed");
         return -1;
     }
 
@@ -1764,8 +1764,8 @@
     msg.len = DL_PHYS_ADDR_REQ_SIZE;
 
     if (putmsg(fd, &msg, NULL, 0) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "putmsg failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "putmsg() failed");
         return -1;
     }
 
@@ -1775,8 +1775,8 @@
     msg.len = 0;
     msg.maxlen = sizeof (buf);
     if (getmsg(fd, &msg, NULL, &flags) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "getmsg failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "getmsg() failed");
         return -1;
     }
 
@@ -1860,8 +1860,8 @@
     strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
 
     if (ioctl(sock, SIOCGLIFMTU, (char *)&if2) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                    "ioctl SIOCGLIFMTU failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFMTU) failed");
         return -1;
     }
 
@@ -1900,13 +1900,13 @@
      if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
          if (errno == EPROTONOSUPPORT) {
               if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                              "IPV6 Socket creation failed");
+                 JNU_ThrowByNameWithMessageAndLastError
+                     (env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                  return -1;
               }
          } else { // errno is not NOSUPPORT
-             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                          "IPV4 Socket creation failed");
+             JNU_ThrowByNameWithMessageAndLastError
+                 (env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
              return -1;
          }
    }
@@ -1927,8 +1927,8 @@
     struct ifaddrs *ifa, *origifa;
 
     if (getifaddrs(&origifa) != 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "getifaddrs() function failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "getifaddrs() failed");
         return ifs;
     }
 
@@ -1997,8 +1997,8 @@
     struct in6_ifreq ifr6;
 
     if (getifaddrs(&origifa) != 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "getifaddrs() function failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "getifaddrs() failed");
         return ifs;
     }
 
@@ -2014,8 +2014,8 @@
                MIN(sizeof(ifr6.ifr_addr), ifa->ifa_addr->sa_len));
 
         if (ioctl(sock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "ioctl SIOCGIFNETMASK_IN6 failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK_IN6) failed");
             freeifaddrs(origifa);
             freeif(ifs);
             return NULL;
@@ -2075,16 +2075,16 @@
 
     // Make sure the interface does have a broadcast address
     if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFFLAGS failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFFLAGS) failed");
         return ret;
     }
 
     if (if2.ifr_flags & IFF_BROADCAST) {
         // It does, let's retrieve it
         if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "ioctl SIOCGIFBRDADDR failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFBRDADDR) failed");
             return ret;
         }
 
@@ -2107,8 +2107,8 @@
     strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
 
     if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFNETMASK failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK) failed");
         return -1;
     }
 
@@ -2156,8 +2156,8 @@
     strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
 
     if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "ioctl SIOCGIFMTU failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFMTU) failed");
         return -1;
     }
 
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Fri Jul 01 16:50:37 2016 -0700
@@ -221,8 +221,8 @@
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
                             "Bind failed");
         } else {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                            "Bind failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Bind failed");
         }
         return;
     }
@@ -233,8 +233,8 @@
          * that the system chose for us and store it in the Socket object.
          */
         if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                            "Error getting socket name");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return;
         }
 
@@ -469,7 +469,7 @@
             JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException",
                             "ICMP Port Unreachable");
         } else {
-            NET_ThrowByNameWithLastError(env, "java/io/IOException", "sendto failed");
+            JNU_ThrowIOExceptionWithLastError(env, "sendto failed");
         }
     }
 
@@ -520,7 +520,8 @@
             } else if (errno == ENOMEM) {
                  JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
             } else {
-                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
+                 JNU_ThrowByNameWithMessageAndLastError
+                     (env, JNU_JAVANETPKG "SocketException", "Peek failed");
             }
             return ret;
         }
@@ -544,7 +545,8 @@
             if (errno == EBADF) {
                  JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
             } else {
-                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
+                 JNU_ThrowByNameWithMessageAndLastError
+                     (env, JNU_JAVANETPKG "SocketException", "Peek failed");
             }
         }
         return 0;
@@ -616,7 +618,8 @@
             } else if (errno == EBADF) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
             } else {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Receive failed");
 #else
             } else {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@@ -681,7 +684,8 @@
             if (errno == EBADF) {
                  JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
             } else {
-                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
+                 JNU_ThrowByNameWithMessageAndLastError
+                     (env, JNU_JAVANETPKG "SocketException", "Receive failed");
             }
         }
     } else {
@@ -827,7 +831,8 @@
                     } else if (errno == EBADF) {
                          JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
                     } else {
-                        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
+                        JNU_ThrowByNameWithMessageAndLastError
+                            (env, JNU_JAVANETPKG "SocketException", "Receive failed");
 #else
                     } else {
                         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@@ -859,7 +864,8 @@
                 if (errno == EBADF) {
                      JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
                  } else {
-                     NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
+                     JNU_ThrowByNameWithMessageAndLastError
+                         (env, JNU_JAVANETPKG "SocketException", "Receive failed");
                  }
             }
         } else {
@@ -932,8 +938,8 @@
     }
 
     if ((fd = socket(domain, SOCK_DGRAM, 0)) == -1) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                       "Error creating socket");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error creating socket");
         return;
     }
 
@@ -1080,8 +1086,8 @@
 
     if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                    (const char*)&in, sizeof(in)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                       "Error setting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
     }
 }
 
@@ -1109,8 +1115,8 @@
                 "IPV6_MULTICAST_IF failed (interface has IPv4 "
                 "address only?)");
         } else {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                           "Error setting socket option");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
         }
         return;
     }
@@ -1129,8 +1135,8 @@
 
     if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                    (const char*)&in, sizeof(in)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                         "Error setting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
     }
 }
 
@@ -1256,8 +1262,10 @@
     on = (*env)->GetBooleanField(env, value, fid);
     loopback = (!on ? 1 : 0);
 
-    if (NET_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const void *)&loopback, sizeof(char)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
+    if (NET_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
+                       (const void *)&loopback, sizeof(char)) < 0) {
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
         return;
     }
 }
@@ -1280,8 +1288,10 @@
     on = (*env)->GetBooleanField(env, value, fid);
     loopback = (!on ? 1 : 0);
 
-    if (NET_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (const void *)&loopback, sizeof(int)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
+    if (NET_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
+                       (const void *)&loopback, sizeof(int)) < 0) {
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
         return;
     }
 
@@ -1420,7 +1430,8 @@
     }
 
     if (NET_SetSockOpt(fd, level, optname, (const void *)&optval, optlen) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
         return;
     }
 }
@@ -1483,8 +1494,8 @@
 
         if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                        (char *)inP, &len) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                             "Error getting socket option");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
             return NULL;
         }
 
@@ -1581,8 +1592,8 @@
 
         if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
                        (char*)&index, &len) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                           "Error getting socket option");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
             return NULL;
         }
 
@@ -1726,8 +1737,8 @@
         len = SOCKADDR_LEN;
 
         if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                           "Error getting socket name");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return NULL;
         }
         iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
@@ -1752,8 +1763,8 @@
     }
 
     if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                         "Error getting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
         return NULL;
     }
 
@@ -1805,8 +1816,8 @@
     char ittl = (char)ttl;
     if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ittl,
                    sizeof(ittl)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                       "Error setting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
     }
 }
 
@@ -1818,8 +1829,8 @@
     int ittl = (int)ttl;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
                    (char*)&ittl, sizeof(ittl)) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                       "Error setting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
     }
 }
 #endif
@@ -1901,8 +1912,8 @@
 
         if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
                        (char*)&ttl, &len) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "Error getting socket option");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
             return -1;
         }
         return (jint)ttl;
@@ -1913,8 +1924,8 @@
             socklen_t len = sizeof(ttl);
             if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
                            (char*)&ttl, &len) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                               "Error getting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
                 return -1;
             }
             return (jint)ttl;
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -476,7 +476,8 @@
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                             "Socket closed");
         } else {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "connect failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "connect failed");
         }
         return;
     }
@@ -498,8 +499,8 @@
          */
         socklen_t slen = SOCKADDR_LEN;
         if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                           "Error getting socket name");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
         } else {
             localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
             (*env)->SetIntField(env, this, psi_localportID, localport);
@@ -536,8 +537,9 @@
     }
 
     /* bind */
-    if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him, &len, JNI_TRUE) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him,
+                                  &len, JNI_TRUE) != 0) {
+        return;
     }
     setDefaultScopeID(env, (struct sockaddr *)&him);
 
@@ -547,8 +549,8 @@
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
                            "Bind failed");
         } else {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                           "Bind failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Bind failed");
         }
         return;
     }
@@ -563,8 +565,8 @@
          * that the system chose for us and store it in the Socket object.
          */
         if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                           "Error getting socket name");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return;
         }
         localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
@@ -580,8 +582,8 @@
  * Signature: (I)V
  */
 JNIEXPORT void JNICALL
-Java_java_net_PlainSocketImpl_socketListen (JNIEnv *env, jobject this,
-                                            jint count)
+Java_java_net_PlainSocketImpl_socketListen(JNIEnv *env, jobject this,
+                                           jint count)
 {
     /* this FileDescriptor fd field */
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
@@ -604,8 +606,8 @@
         count -= 1;
 
     if (listen(fd, count) == -1) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                       "Listen failed");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Listen failed");
     }
 }
 
@@ -684,7 +686,8 @@
             } else if (errno == ENOMEM) {
                JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
             } else {
-               NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
+               JNU_ThrowByNameWithMessageAndLastError
+                   (env, JNU_JAVANETPKG "SocketException", "Accept failed");
             }
             return;
         }
@@ -727,7 +730,8 @@
             if (errno == EBADF) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
             } else {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Accept failed");
             }
         }
         return;
@@ -781,8 +785,8 @@
         if (errno == ECONNRESET) {
             JNU_ThrowByName(env, "sun/net/ConnectionResetException", "");
         } else {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                         "ioctl FIONREAD failed");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "ioctl FIONREAD failed");
         }
     }
     return ret;
@@ -936,8 +940,8 @@
             return;
         }
 #endif /* __solaris__ */
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                      "Error setting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
     }
 }
 
@@ -981,8 +985,8 @@
         len = SOCKADDR_LEN;
 
         if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                             "Error getting socket name");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return -1;
         }
         iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
@@ -1014,8 +1018,8 @@
     }
 
     if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                      "Error getting socket option");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
         return -1;
     }
 
@@ -1063,6 +1067,6 @@
     }
     n = NET_Send(fd, (char *)&d, 1, MSG_OOB);
     if (n == -1) {
-        NET_ThrowByNameWithLastError(env, "java/io/IOException", "Write failed");
+        JNU_ThrowIOExceptionWithLastError(env, "Write failed");
     }
 }
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/unix/native/libnet/SocketInputStream.c
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -111,8 +111,8 @@
                 } else if (errno == ENOMEM) {
                     JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
                 } else {
-                    NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                                  "select/poll failed");
+                    JNU_ThrowByNameWithMessageAndLastError
+                        (env, JNU_JAVANETPKG "SocketException", "select/poll failed");
                 }
             }
             if (bufP != BUF) {
@@ -145,8 +145,8 @@
                      break;
 
                 default:
-                    NET_ThrowByNameWithLastError(env,
-                        JNU_JAVANETPKG "SocketException", "Read failed");
+                    JNU_ThrowByNameWithMessageAndLastError
+                        (env, JNU_JAVANETPKG "SocketException", "Read failed");
             }
         }
     } else {
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/unix/native/libnet/SocketOutputStream.c
--- a/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -114,8 +114,8 @@
                 JNU_ThrowByName(env, "sun/net/ConnectionResetException",
                     "Connection reset");
             } else {
-                NET_ThrowByNameWithLastError(env, "java/net/SocketException",
-                    "Write failed");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, "java/net/SocketException", "Write failed");
             }
             if (bufP != BUF) {
                 free(bufP);
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/unix/native/libnio/fs/GioFileTypeDetector.c
--- a/jdk/src/java.base/unix/native/libnio/fs/GioFileTypeDetector.c	Fri Jun 24 15:06:50 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2008, 2015, 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.
- */
-
-#include "jni.h"
-#include "jni_util.h"
-#include "jvm.h"
-#include "jlong.h"
-
-#include 
-#include 
-
-#ifdef __solaris__
-#include 
-#endif
-
-#if defined(__linux__)
-#include 
-#endif
-
-/*
- * For reference see for example the GFileInfo section at
- * https://developer.gnome.org/gio/unstable/.
- */
-
-/* Definitions for GIO */
-
-#define G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "standard::content-type"
-
-typedef void* gpointer;
-typedef struct _GFile GFile;
-typedef struct _GFileInfo GFileInfo;
-typedef struct _GCancellable GCancellable;
-typedef struct _GError GError;
-
-typedef enum {
-  G_FILE_QUERY_INFO_NONE = 0
-} GFileQueryInfoFlags;
-
-typedef void (*g_type_init_func)(void);
-typedef void (*g_object_unref_func)(gpointer object);
-typedef GFile* (*g_file_new_for_path_func)(const char* path);
-typedef GFileInfo* (*g_file_query_info_func)(GFile *file,
-    const char *attributes, GFileQueryInfoFlags flags,
-    GCancellable *cancellable, GError **error);
-typedef char* (*g_file_info_get_content_type_func)(GFileInfo *info);
-
-static g_type_init_func g_type_init;
-static g_object_unref_func g_object_unref;
-static g_file_new_for_path_func g_file_new_for_path;
-static g_file_query_info_func g_file_query_info;
-static g_file_info_get_content_type_func g_file_info_get_content_type;
-
-
-#include "sun_nio_fs_GioFileTypeDetector.h"
-
-
-JNIEXPORT jboolean JNICALL
-Java_sun_nio_fs_GioFileTypeDetector_initializeGio
-    (JNIEnv* env, jclass this)
-{
-    void* gio_handle;
-
-    gio_handle = dlopen("libgio-2.0.so", RTLD_LAZY);
-    if (gio_handle == NULL) {
-        gio_handle = dlopen("libgio-2.0.so.0", RTLD_LAZY);
-        if (gio_handle == NULL) {
-            return JNI_FALSE;
-        }
-    }
-
-    g_type_init = (g_type_init_func)dlsym(gio_handle, "g_type_init");
-    (*g_type_init)();
-
-    g_object_unref = (g_object_unref_func)dlsym(gio_handle, "g_object_unref");
-
-    g_file_new_for_path =
-        (g_file_new_for_path_func)dlsym(gio_handle, "g_file_new_for_path");
-
-    g_file_query_info =
-        (g_file_query_info_func)dlsym(gio_handle, "g_file_query_info");
-
-    g_file_info_get_content_type = (g_file_info_get_content_type_func)
-        dlsym(gio_handle, "g_file_info_get_content_type");
-
-
-    if (g_type_init == NULL ||
-        g_object_unref == NULL ||
-        g_file_new_for_path == NULL ||
-        g_file_query_info == NULL ||
-        g_file_info_get_content_type == NULL)
-    {
-        dlclose(gio_handle);
-        return JNI_FALSE;
-    }
-
-    (*g_type_init)();
-    return JNI_TRUE;
-}
-
-JNIEXPORT jbyteArray JNICALL
-Java_sun_nio_fs_GioFileTypeDetector_probeGio
-    (JNIEnv* env, jclass this, jlong pathAddress)
-{
-    char* path = (char*)jlong_to_ptr(pathAddress);
-    GFile* gfile;
-    GFileInfo* gfileinfo;
-    jbyteArray result = NULL;
-
-    gfile = (*g_file_new_for_path)(path);
-    gfileinfo = (*g_file_query_info)(gfile, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-        G_FILE_QUERY_INFO_NONE, NULL, NULL);
-    if (gfileinfo != NULL) {
-        const char* mime = (*g_file_info_get_content_type)(gfileinfo);
-        if (mime != NULL) {
-            jsize len = strlen(mime);
-            result = (*env)->NewByteArray(env, len);
-            if (result != NULL) {
-                (*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)mime);
-            }
-        }
-        (*g_object_unref)(gfileinfo);
-    }
-    (*g_object_unref)(gfile);
-
-    return result;
-}
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/windows/native/libjli/cmdtoargs.c
--- a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c	Fri Jul 01 16:50:37 2016 -0700
@@ -155,6 +155,7 @@
                 }
             }
             dest += copyCh(ch, dest);
+            slashes = 0;
             break;
 
         default:
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -1713,8 +1713,8 @@
             in.s_addr = htonl(getInetAddress_addr(env, value));
             if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                                (const char*)&in, sizeof(in)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                 "Error setting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
             }
             return;
         }
@@ -1741,7 +1741,7 @@
             }
             index = (*env)->GetIntField(env, value, ni_indexID);
 
-            if ( isAdapterIpv6Enabled(env, index) != 0 ) {
+            if (isAdapterIpv6Enabled(env, index) != 0) {
                 if (setsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
                                (const char*)&index, sizeof(index)) < 0) {
                     if (errno == EINVAL && index > 0) {
@@ -1749,8 +1749,8 @@
                             "IPV6_MULTICAST_IF failed (interface has IPv4 "
                             "address only?)");
                     } else {
-                        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                   "Error setting socket option");
+                        JNU_ThrowByNameWithMessageAndLastError
+                            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
                     }
                     return;
                 }
@@ -1758,13 +1758,13 @@
             /* If there are any IPv4 addresses on this interface then
              * repeat the operation on the IPv4 fd */
 
-            if (getInet4AddrFromIf (env, value, &in) < 0) {
+            if (getInet4AddrFromIf(env, value, &in) < 0) {
                 return;
             }
             if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                                (const char*)&in, sizeof(in)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                 "Error setting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
             }
             return;
         } else {
@@ -1781,8 +1781,8 @@
 
             if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                                (const char*)&in, sizeof(in)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                               "Error setting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
             }
             return;
         }
@@ -1932,8 +1932,8 @@
         int len = sizeof(struct in_addr);
         if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                            (char *)inP, &len) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                             "Error getting socket option");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
             return NULL;
         }
 
@@ -2056,8 +2056,8 @@
         {
             if (getsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
                                (char*)&index, &len) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                               "Error getting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
                 return NULL;
             }
         }
@@ -2288,8 +2288,8 @@
     }
 
     if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                       "Error getting socket name");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
         return NULL;
     }
     iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Fri Jul 01 16:50:37 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -1054,8 +1054,8 @@
         }
 
         if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                             "Error getting socket name");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return -1;
         }
         iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java	Fri Jul 01 16:50:37 2016 -0700
@@ -298,7 +298,7 @@
 
         ByteBuffer[] buffers = frame.getHeaderBlock();
         for (int i = 0; i < buffers.length; i++) {
-            hpackIn.decode(buffers[i], endOfHeaders, decoder);
+            hpackIn.decode(buffers[i], endOfHeaders && (i == buffers.length - 1), decoder);
         }
     }
 
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java
--- a/jdk/src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java	Fri Jul 01 16:50:37 2016 -0700
@@ -128,6 +128,7 @@
             this.chan = SocketChannel.open();
             int bufsize = client.getReceiveBufferSize();
             chan.setOption(StandardSocketOptions.SO_RCVBUF, bufsize);
+            chan.setOption(StandardSocketOptions.TCP_NODELAY, true);
         } catch (IOException e) {
             throw new InternalError(e);
         }
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.httpclient/share/classes/sun/net/httpclient/hpack/StringReader.java
--- a/jdk/src/java.httpclient/share/classes/sun/net/httpclient/hpack/StringReader.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.httpclient/share/classes/sun/net/httpclient/hpack/StringReader.java	Fri Jul 01 16:50:37 2016 -0700
@@ -78,6 +78,7 @@
             if (isLast) {
                 input.limit(input.position() + remainingLength);
             }
+            remainingLength -= Math.min(input.remaining(), remainingLength);
             if (huffman) {
                 huffmanReader.read(input, output, isLast);
             } else {
@@ -85,6 +86,7 @@
             }
             if (isLast) {
                 input.limit(oldLimit);
+                state = DONE;
             }
             return isLast;
         }
diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java
--- a/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java	Fri Jun 24 15:06:50 2016 -0700
+++ b/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java	Fri Jul 01 16:50:37 2016 -0700
@@ -94,6 +94,9 @@
  * 
  • <handler-name>.append * specifies whether the FileHandler should append onto * any existing files (defaults to false).
  • + *
  • <handler-name>.maxLocks + * specifies the maximum number of concurrent locks held by + * FileHandler (defaults to 100).
  • * *

    * For example, the properties for {@code FileHandler} would be: @@ -157,6 +160,7 @@ private FileChannel lockFileChannel; private File files[]; private static final int MAX_LOCKS = 100; + private int maxLocks = MAX_LOCKS; private static final Set locks = new HashSet<>(); /** @@ -235,6 +239,12 @@ setLevel(manager.getLevelProperty(cname + ".level", Level.ALL)); setFilter(manager.getFilterProperty(cname + ".filter", null)); setFormatter(manager.getFormatterProperty(cname + ".formatter", new XMLFormatter())); + // Initialize maxLocks from the logging.properties file. + // If invalid/no property is provided 100 will be used as a default value. + maxLocks = manager.getIntProperty(cname + ".maxLocks", MAX_LOCKS); + if(maxLocks <= 0) { + maxLocks = MAX_LOCKS; + } try { setEncoding(manager.getStringProperty(cname +".encoding", null)); } catch (Exception ex) { @@ -476,7 +486,7 @@ int unique = -1; for (;;) { unique++; - if (unique > MAX_LOCKS) { + if (unique > maxLocks) { throw new IOException("Couldn't get lock for " + pattern); } // Generate a lock file name from the "unique" int. diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/java.logging/share/conf/logging.properties --- a/jdk/src/java.logging/share/conf/logging.properties Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/java.logging/share/conf/logging.properties Fri Jul 01 16:50:37 2016 -0700 @@ -37,6 +37,10 @@ java.util.logging.FileHandler.pattern = %h/java%u.log java.util.logging.FileHandler.limit = 50000 java.util.logging.FileHandler.count = 1 +# Default number of locks FileHandler can obtain synchronously. +# This specifies maximum number of attempts to obtain lock file by FileHandler +# implemented by incrementing the unique field %u as per FileHandler API documentation. +java.util.logging.FileHandler.maxLocks = 100 java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter # Limit the message that are printed on the console to INFO and above. diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java Fri Jul 01 16:50:37 2016 -0700 @@ -48,6 +48,7 @@ import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.zip.*; import java.util.jar.*; import java.util.jar.Pack200.*; @@ -77,24 +78,82 @@ PrintStream out, err; String fname, mname, ename; String zname = ""; - String[] files; String rootjar = null; - // An entryName(path)->File map generated during "expand", it helps to + private static final int BASE_VERSION = 0; + + class Entry { + final String basename; + final String entryname; + final File file; + final boolean isDir; + + Entry(int version, File file) { + this.file = file; + String path = file.getPath(); + if (file.isDirectory()) { + isDir = true; + path = path.endsWith(File.separator) ? path : + path + File.separator; + } else { + isDir = false; + } + EntryName en = new EntryName(path, version); + basename = en.baseName; + entryname = en.entryName; + } + } + + class EntryName { + final String baseName; + final String entryName; + + EntryName(String name, int version) { + name = name.replace(File.separatorChar, '/'); + String matchPath = ""; + for (String path : pathsMap.get(version)) { + if (name.startsWith(path) + && (path.length() > matchPath.length())) { + matchPath = path; + } + } + name = safeName(name.substring(matchPath.length())); + // the old implementaton doesn't remove + // "./" if it was led by "/" (?) + if (name.startsWith("./")) { + name = name.substring(2); + } + this.baseName = name; + this.entryName = (version > BASE_VERSION) + ? VERSIONS_DIR + version + "/" + this.baseName + : this.baseName; + } + } + + // An entryName(path)->Entry map generated during "expand", it helps to // decide whether or not an existing entry in a jar file needs to be // replaced, during the "update" operation. - Map entryMap = new HashMap(); + Map entryMap = new HashMap<>(); - // All files need to be added/updated. - Set entries = new LinkedHashSet(); + // All entries need to be added/updated. + Map entries = new LinkedHashMap<>(); + // All packages. Set packages = new HashSet<>(); // All actual entries added, or existing, in the jar file ( excl manifest // and module-info.class ). Populated during create or update. Set jarEntries = new HashSet<>(); - // Directories specified by "-C" operation. - Set paths = new HashSet(); + // A paths Set for each version, where each Set contains directories + // specified by the "-C" operation. + Map> pathsMap = new HashMap<>(); + + // There's also a files array per version + Map filesMap = new HashMap<>(); + + // Do we think this is a multi-release jar? Set to true + // if --release option found followed by at least file + boolean isMultiRelease; /* * cflag: create @@ -241,10 +300,15 @@ if (ename != null) { addMainClass(manifest, ename); } + if (isMultiRelease) { + addMultiRelease(manifest); + } } Map moduleInfoPaths = new HashMap<>(); - expand(null, files, false, moduleInfoPaths); - + for (int version : filesMap.keySet()) { + String[] files = filesMap.get(version); + expand(null, files, false, moduleInfoPaths, version); + } Map moduleInfos = new LinkedHashMap<>(); if (!moduleInfoPaths.isEmpty()) { if (!checkModuleInfos(moduleInfoPaths)) @@ -348,7 +412,10 @@ (new FileInputStream(mname)) : null; Map moduleInfoPaths = new HashMap<>(); - expand(null, files, true, moduleInfoPaths); + for (int version : filesMap.keySet()) { + String[] files = filesMap.get(version); + expand(null, files, true, moduleInfoPaths, version); + } Map moduleInfos = new HashMap<>(); for (Map.Entry e : moduleInfoPaths.entrySet()) @@ -381,10 +448,11 @@ tmpFile.delete(); } } else if (tflag) { - replaceFSC(files); + replaceFSC(filesMap); // For the "list table contents" action, access using the // ZipFile class is always most efficient since only a // "one-finger" scan through the central directory is required. + String[] files = filesMapToFiles(filesMap); if (fname != null) { list(fname, files); } else { @@ -396,7 +464,7 @@ } } } else if (xflag) { - replaceFSC(files); + replaceFSC(filesMap); // For the extract action, when extracting all the entries, // access using the ZipInputStream class is most efficient, // since only a single sequential scan through the zip file is @@ -406,6 +474,8 @@ // "leading garbage", we fall back from the ZipInputStream // implementation to the ZipFile implementation, since only the // latter can handle it. + + String[] files = filesMapToFiles(filesMap); if (fname != null && files != null) { extract(fname, files); } else { @@ -421,6 +491,7 @@ } } } else if (iflag) { + String[] files = filesMap.get(BASE_VERSION); // base entries only, can be null genIndex(rootjar, files); } else if (printModuleDescriptor) { boolean found; @@ -449,6 +520,20 @@ return ok; } + private String[] filesMapToFiles(Map filesMap) { + if (filesMap.isEmpty()) return null; + return filesMap.entrySet() + .stream() + .flatMap(this::filesToEntryNames) + .toArray(String[]::new); + } + + Stream filesToEntryNames(Map.Entry fileEntries) { + int version = fileEntries.getKey(); + return Stream.of(fileEntries.getValue()) + .map(f -> (new EntryName(f, version)).entryName); + } + /** * Parses command line arguments. */ @@ -579,8 +664,10 @@ /* parse file arguments */ int n = args.length - count; if (n > 0) { + int version = BASE_VERSION; int k = 0; String[] nameBuf = new String[n]; + pathsMap.put(version, new HashSet<>()); try { for (int i = count; i < args.length; i++) { if (args[i].equals("-C")) { @@ -592,8 +679,33 @@ while (dir.indexOf("//") > -1) { dir = dir.replace("//", "/"); } - paths.add(dir.replace(File.separatorChar, '/')); + pathsMap.get(version).add(dir.replace(File.separatorChar, '/')); nameBuf[k++] = dir + args[++i]; + } else if (args[i].startsWith("--release")) { + int v = BASE_VERSION; + try { + v = Integer.valueOf(args[++i]); + } catch (NumberFormatException x) { + error(formatMsg("error.release.value.notnumber", args[i])); + // this will fall into the next error, thus returning false + } + if (v < 9) { + error(formatMsg("error.release.value.toosmall", String.valueOf(v))); + usageError(); + return false; + } + // associate the files, if any, with the previous version number + if (k > 0) { + String[] files = new String[k]; + System.arraycopy(nameBuf, 0, files, 0, k); + filesMap.put(version, files); + isMultiRelease = version > BASE_VERSION; + } + // reset the counters and start with the new version number + k = 0; + nameBuf = new String[n]; + version = v; + pathsMap.put(version, new HashSet<>()); } else { nameBuf[k++] = args[i]; } @@ -602,8 +714,13 @@ usageError(); return false; } - files = new String[k]; - System.arraycopy(nameBuf, 0, files, 0, k); + // associate remaining files, if any, with a version + if (k > 0) { + String[] files = new String[k]; + System.arraycopy(nameBuf, 0, files, 0, k); + filesMap.put(version, files); + isMultiRelease = version > BASE_VERSION; + } } else if (cflag && (mname == null)) { error(getMsg("error.bad.cflag")); usageError(); @@ -651,7 +768,8 @@ void expand(File dir, String[] files, boolean isUpdate, - Map moduleInfoPaths) + Map moduleInfoPaths, + int version) throws IOException { if (files == null) @@ -664,29 +782,29 @@ else f = new File(dir, files[i]); + Entry entry = new Entry(version, f); + String entryName = entry.entryname; + if (f.isFile()) { - String path = f.getPath(); - String entryName = entryName(path); if (entryName.endsWith(MODULE_INFO)) { moduleInfoPaths.put(entryName, f.toPath()); if (isUpdate) - entryMap.put(entryName, f); - } else if (entries.add(f)) { + entryMap.put(entryName, entry); + } else if (!entries.containsKey(entryName)) { + entries.put(entryName, entry); jarEntries.add(entryName); - if (path.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR)) - packages.add(toPackageName(entryName)); + if (entry.basename.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR)) + packages.add(toPackageName(entry.basename)); if (isUpdate) - entryMap.put(entryName, f); + entryMap.put(entryName, entry); } } else if (f.isDirectory()) { - if (entries.add(f)) { + if (!entries.containsKey(entryName)) { + entries.put(entryName, entry); if (isUpdate) { - String dirPath = f.getPath(); - dirPath = (dirPath.endsWith(File.separator)) ? dirPath : - (dirPath + File.separator); - entryMap.put(entryName(dirPath), f); + entryMap.put(entryName, entry); } - expand(f, f.list(), isUpdate, moduleInfoPaths); + expand(f, f.list(), isUpdate, moduleInfoPaths, version); } } else { error(formatMsg("error.nosuch.fileordir", String.valueOf(f))); @@ -740,8 +858,9 @@ in.transferTo(zos); zos.closeEntry(); } - for (File file: entries) { - addFile(zos, file); + for (String entryname : entries.keySet()) { + Entry entry = entries.get(entryname); + addFile(zos, entry); } zos.close(); } @@ -823,7 +942,7 @@ || (Mflag && isManifestEntry)) { continue; } else if (isManifestEntry && ((newManifest != null) || - (ename != null))) { + (ename != null) || isMultiRelease)) { foundManifest = true; if (newManifest != null) { // Don't read from the newManifest InputStream, as we @@ -862,21 +981,21 @@ zos.putNextEntry(e2); copy(zis, zos); } else { // replace with the new files - File f = entryMap.get(name); - addFile(zos, f); + Entry ent = entryMap.get(name); + addFile(zos, ent); entryMap.remove(name); - entries.remove(f); + entries.remove(name); } jarEntries.add(name); - if (name.endsWith(".class")) + if (name.endsWith(".class") && !(name.startsWith(VERSIONS_DIR))) packages.add(toPackageName(name)); } } // add the remaining new files - for (File f: entries) { - addFile(zos, f); + for (String entryname : entries.keySet()) { + addFile(zos, entries.get(entryname)); } if (!foundManifest) { if (newManifest != null) { @@ -961,6 +1080,9 @@ if (ename != null) { addMainClass(m, ename); } + if (isMultiRelease) { + addMultiRelease(m); + } ZipEntry e = new ZipEntry(MANIFEST_NAME); e.setTime(System.currentTimeMillis()); if (flag0) { @@ -1016,24 +1138,6 @@ return name; } - private String entryName(String name) { - name = name.replace(File.separatorChar, '/'); - String matchPath = ""; - for (String path : paths) { - if (name.startsWith(path) - && (path.length() > matchPath.length())) { - matchPath = path; - } - } - name = safeName(name.substring(matchPath.length())); - // the old implementaton doesn't remove - // "./" if it was led by "/" (?) - if (name.startsWith("./")) { - name = name.substring(2); - } - return name; - } - private void addVersion(Manifest m) { Attributes global = m.getMainAttributes(); if (global.getValue(Attributes.Name.MANIFEST_VERSION) == null) { @@ -1058,6 +1162,11 @@ global.put(Attributes.Name.MAIN_CLASS, mainApp); } + private void addMultiRelease(Manifest m) { + Attributes global = m.getMainAttributes(); + global.put(Attributes.Name.MULTI_RELEASE, "true"); + } + private boolean isAmbiguousMainClass(Manifest m) { if (ename != null) { Attributes global = m.getMainAttributes(); @@ -1073,14 +1182,10 @@ /** * Adds a new file entry to the ZIP output stream. */ - void addFile(ZipOutputStream zos, File file) throws IOException { - String name = file.getPath(); - boolean isDir = file.isDirectory(); - if (isDir) { - name = name.endsWith(File.separator) ? name : - (name + File.separator); - } - name = entryName(name); + void addFile(ZipOutputStream zos, Entry entry) throws IOException { + File file = entry.file; + String name = entry.entryname; + boolean isDir = entry.isDir; if (name.equals("") || name.equals(".") || name.equals(zname)) { return; @@ -1221,12 +1326,15 @@ os.updateEntry(e); } - void replaceFSC(String files[]) { - if (files != null) { - for (int i = 0; i < files.length; i++) { - files[i] = files[i].replace(File.separatorChar, '/'); + void replaceFSC(Map filesMap) { + filesMap.keySet().forEach(version -> { + String[] files = filesMap.get(version); + if (files != null) { + for (int i = 0; i < files.length; i++) { + files[i] = files[i].replace(File.separatorChar, '/'); + } } - } + }); } @SuppressWarnings("serial") @@ -1566,7 +1674,7 @@ /** * Print an error message; like something is broken */ - protected void error(String s) { + void error(String s) { err.println(s); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties Fri Jul 01 16:50:37 2016 -0700 @@ -63,24 +63,28 @@ error.module.descriptor.not.found=\ Module descriptor not found error.versioned.info.without.root=\ - module-info.class found in versioned section without module-info.class \ + module-info.class found in a versioned directory without module-info.class \ in the root error.versioned.info.name.notequal=\ - module-info.class in versioned section contains incorrect name + module-info.class in a versioned directory contains incorrect name error.versioned.info.requires.public=\ - module-info.class in versioned section contains additional requires public + module-info.class in a versioned directory contains additional requires public error.versioned.info.requires.added=\ - module-info.class in versioned section contains additional requires + module-info.class in a versioned directory contains additional requires error.versioned.info.requires.dropped=\ - module-info.class in versioned section contains missing requires + module-info.class in a versioned directory contains missing requires error.versioned.info.exports.notequal=\ - module-info.class in versioned section contains different exports + module-info.class in a versioned directory contains different exports error.versioned.info.provides.notequal=\ - module-info.class in versioned section contains different provides + module-info.class in a versioned directory contains different provides error.invalid.versioned.module.attribute=\ Invalid module descriptor attribute {0} error.missing.provider=\ Service provider not found: {0} +error.release.value.notnumber=\ + release {0} not valid +error.release.value.toosmall=\ + release {0} not valid, must be >= 9 out.added.manifest=\ added manifest out.added.module-info=\ @@ -109,7 +113,7 @@ usage.compat=\ \Compatibility Interface:\ \n\ -Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...\n\ +Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files] ...\n\ Options:\n\ \ \ -c create new archive\n\ \ \ -t list table of contents for archive\n\ @@ -141,7 +145,7 @@ Try `jar --help' for more information. main.help.preopt=\ -Usage: jar [OPTION...] [-C dir] files ...\n\ +Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files] ...\n\ jar creates an archive for classes and resources, and can manipulate or\n\ restore individual classes or resources from an archive.\n\ \n\ @@ -156,7 +160,9 @@ \ -C foo/ classes resources\n\ \ # Update an existing non-modular jar to a modular jar:\n\ \ jar --update --file foo.jar --main-class com.foo.Main --module-version 1.0\n\ -\ -C foo/ module-info.class +\ -C foo/ module-info.class\n\ +\ # Create a multi-release jar, placing some files in the META-INF/versions/9 directory:\n\ +\ jar --create --file mr.jar -C foo classes --release 9 -C foo9 classes main.help.opt.main=\ \ Main operation mode:\n main.help.opt.main.create=\ @@ -178,7 +184,9 @@ \ -C DIR Change to the specified directory and include the\n\ \ following file main.help.opt.any.file=\ -\ -f, --file=FILE The archive file name +\ -f, --file=FILE The archive file name\n\ +\ --release VERSION Places all following files in a versioned directory\n\ +\ of the jar (i.e. META-INF/versions/VERSION/) main.help.opt.any.verbose=\ \ -v, --verbose Generate verbose output on standard output main.help.opt.create.update=\ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java Fri Jul 01 16:50:37 2016 -0700 @@ -54,8 +54,8 @@ }, "--dir"), new Option(true, (task, option, arg) -> { - task.options.filters = arg; - }, "--filter"), + task.options.include = arg; + }, "--include"), new Option(false, (task, option, arg) -> { task.options.fullVersion = true; @@ -81,12 +81,12 @@ private static final FileSystem JRT_FILE_SYSTEM = Utils.jrtFileSystem(); private final OptionsValues options; - private final List> filterPredicates; + private final List> includePredicates; private PrintWriter log; JImageTask() { this.options = new OptionsValues(); - this.filterPredicates = new ArrayList<>(); + this.includePredicates = new ArrayList<>(); log = null; } @@ -98,7 +98,7 @@ static class OptionsValues { Task task = Task.LIST; String directory = "."; - String filters = ""; + String include = ""; boolean fullVersion; boolean help; boolean verbose; @@ -200,6 +200,8 @@ log.println(TASK_HELPER.getMessage("main.opt." + name)); } + + log.println(TASK_HELPER.getMessage("main.opt.footer")); } else { try { log.println(TASK_HELPER.getMessage("main.usage." + @@ -219,7 +221,7 @@ } } - processFilter(options.filters); + processInclude(options.include); return run() ? EXIT_OK : EXIT_ERROR; } catch (BadArgs e) { @@ -239,15 +241,15 @@ } } - private void processFilter(String filters) { - if (filters.isEmpty()) { + private void processInclude(String include) { + if (include.isEmpty()) { return; } - for (String filter : filters.split(",")) { + for (String filter : include.split(",")) { final PathMatcher matcher = Utils.getPathMatcher(JRT_FILE_SYSTEM, filter); Predicate predicate = (path) -> matcher.matches(JRT_FILE_SYSTEM.getPath(path)); - filterPredicates.add(predicate); + includePredicates.add(predicate); } } @@ -388,9 +390,9 @@ String oldModule = ""; for (String name : entryNames) { - boolean match = filterPredicates.isEmpty(); + boolean match = includePredicates.isEmpty(); - for (Predicate predicate : filterPredicates) { + for (Predicate predicate : includePredicates) { if (predicate.test(name)) { match = true; break; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties Fri Jul 01 16:50:37 2016 -0700 @@ -62,9 +62,19 @@ main.opt.dir=\ \ --dir Target directory for extract directive -main.opt.filter=\ -\ --filter Filter entries for list or extract\n\ -\ Ex. /java.base/*, */module-info.class +main.opt.include=\ +\ --include Pattern list for filtering list or extract entries. + +main.opt.footer=\ +\n\ +\For options requiring a , the value will be a comma\ +\ separated list of elements each using one the following forms:\n\ +\ \n\ +\ glob:\n\ +\ regex:\n\ +\ @ where filename is the name of a file containing patterns to be\ +\ used, one pattern per line\n\ + main.opt.fullversion=\ \ --fullversion Print full version information diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java Fri Jul 01 16:50:37 2016 -0700 @@ -32,10 +32,10 @@ import java.util.Map; import java.util.Objects; import java.util.Set; +import jdk.tools.jlink.internal.ExecutableImage; import jdk.tools.jlink.internal.JlinkTask; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.builder.ImageBuilder; import jdk.tools.jlink.internal.PluginRepository; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java Fri Jul 01 16:50:37 2016 -0700 @@ -57,7 +57,7 @@ import jdk.tools.jlink.internal.BasicImageWriter; import jdk.tools.jlink.internal.plugins.FileCopierPlugin; import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile; -import jdk.tools.jlink.plugin.ExecutableImage; +import jdk.tools.jlink.internal.ExecutableImage; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java Fri Jul 01 16:50:37 2016 -0700 @@ -27,7 +27,7 @@ import java.io.DataOutputStream; import java.util.Properties; -import jdk.tools.jlink.plugin.ExecutableImage; +import jdk.tools.jlink.internal.ExecutableImage; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModulePool; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016, 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 jdk.tools.jlink.internal; + +import java.util.Objects; +import jdk.tools.jlink.plugin.ModuleEntry; + +/** + * A LinkModuleEntry is the elementary unit of data inside an image. It is + * generally a file. e.g.: a java class file, a resource file, a shared library, + * ... + *
    + * A LinkModuleEntry is identified by a path of the form: + *

      + *
    • For jimage content: /{module name}/{package1}/.../{packageN}/{file + * name}
    • + *
    • For other files (shared lib, launchers, config, ...):/{module name}/ + * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}
    • + *
    + */ +abstract class AbstractModuleEntry implements ModuleEntry { + private final String path; + private final String module; + private final Type type; + + /** + * Create a new AbstractModuleEntry. + * + * @param module The module name. + * @param path The data path identifier. + * @param type The data type. + */ + AbstractModuleEntry(String module, String path, Type type) { + this.module = Objects.requireNonNull(module); + this.path = Objects.requireNonNull(path); + this.type = Objects.requireNonNull(type); + } + + @Override + public final String getModule() { + return module; + } + + @Override + public final String getPath() { + return path; + } + + @Override + public final Type getType() { + return type; + } + + @Override + public int hashCode() { + return Objects.hashCode(this.path); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof AbstractModuleEntry)) { + return false; + } + AbstractModuleEntry f = (AbstractModuleEntry) other; + return f.path.equals(path); + } + + @Override + public String toString() { + return getPath(); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java Fri Jul 01 16:50:37 2016 -0700 @@ -42,7 +42,6 @@ public abstract class Entry { public static enum EntryType { - MODULE_NAME, CLASS_OR_RESOURCE, NATIVE_LIB, @@ -57,14 +56,10 @@ private final String path; public Entry(Archive archive, String path, String name, EntryType type) { - Objects.requireNonNull(archive); - Objects.requireNonNull(path); - Objects.requireNonNull(name); - Objects.requireNonNull(type); - this.archive = archive; - this.path = path; - this.name = name; - this.type = type; + this.archive = Objects.requireNonNull(archive); + this.path = Objects.requireNonNull(path); + this.name = Objects.requireNonNull(name); + this.type = Objects.requireNonNull(type); } public Archive archive() { @@ -79,7 +74,7 @@ return type; } - /** + /* * Returns the name of this entry. */ public String name() { @@ -91,7 +86,7 @@ return "type " + type.name() + " path " + path; } - /** + /* * Returns the number of uncompressed bytes for this entry. */ public abstract long size(); @@ -99,17 +94,17 @@ public abstract InputStream stream() throws IOException; } - /** + /* * The module name. */ String moduleName(); - /** + /* * Returns the path to this module's content */ Path getPath(); - /** + /* * Stream of Entry. * The stream of entries needs to be closed after use * since it might cover lazy I/O based resources. @@ -117,12 +112,12 @@ */ Stream entries(); - /** + /* * Open the archive */ void open() throws IOException; - /** + /* * Close the archive */ void close() throws IOException; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2016, 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 jdk.tools.jlink.internal; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.util.Objects; +import jdk.tools.jlink.plugin.ModuleEntry; + +/** + * A ModuleEntry backed by a given Archive Entry. + */ +final class ArchiveEntryModuleEntry extends AbstractModuleEntry { + private final Archive.Entry entry; + + /** + * Create a new ArchiveModuleEntry. + * + * @param module The module name. + * @param path The data path identifier. + * @param entry The archive Entry. + */ + ArchiveEntryModuleEntry(String module, String path, Archive.Entry entry) { + super(module, path, getImageFileType(Objects.requireNonNull(entry))); + this.entry = entry; + } + + @Override + public InputStream stream() { + try { + return entry.stream(); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + @Override + public long getLength() { + return entry.size(); + } + + private static ModuleEntry.Type getImageFileType(Archive.Entry entry) { + switch(entry.type()) { + case CLASS_OR_RESOURCE: + return ModuleEntry.Type.CLASS_OR_RESOURCE; + case CONFIG: + return ModuleEntry.Type.CONFIG; + case NATIVE_CMD: + return ModuleEntry.Type.NATIVE_CMD; + case NATIVE_LIB: + return ModuleEntry.Type.NATIVE_LIB; + default: + return ModuleEntry.Type.OTHER; + } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java Fri Jul 01 16:50:37 2016 -0700 @@ -28,6 +28,7 @@ import java.nio.ByteOrder; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import jdk.internal.jimage.ImageHeader; import jdk.internal.jimage.ImageStream; import jdk.internal.jimage.ImageStringsReader; @@ -54,7 +55,7 @@ } public BasicImageWriter(ByteOrder byteOrder) { - this.byteOrder = byteOrder; + this.byteOrder = Objects.requireNonNull(byteOrder); this.input = new ArrayList<>(); this.strings = new ImageStringsWriter(); this.headerStream = new ImageStream(byteOrder); @@ -96,8 +97,8 @@ private void generatePerfectHash() { PerfectHashBuilder builder = new PerfectHashBuilder<>( - PerfectHashBuilder.Entry.class, // PerfectHashBuilder.Entry().getClass() - PerfectHashBuilder.Bucket.class); // PerfectHashBuilder.Bucket().getClass() + PerfectHashBuilder.Entry.class, + PerfectHashBuilder.Bucket.class); input.forEach((location) -> { builder.put(location.getFullName(), location); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016, 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 jdk.tools.jlink.internal; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UncheckedIOException; +import java.util.Objects; + +/** + * A ModuleEntry backed by a given byte[]. + */ +class ByteArrayModuleEntry extends AbstractModuleEntry { + private final byte[] buffer; + + /** + * Create a new ByteArrayModuleEntry. + * + * @param module The module name. + * @param path The data path identifier. + * @param type The data type. + * @param buf The byte buffer. + */ + ByteArrayModuleEntry(String module, String path, Type type, byte[] buffer) { + super(module, path, type); + this.buffer = Objects.requireNonNull(buffer); + } + + @Override + public byte[] getBytes() { + return buffer.clone(); + } + + @Override + public InputStream stream() { + return new ByteArrayInputStream(buffer); + } + + @Override + public void write(OutputStream out) { + try { + out.write(buffer); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + @Override + public long getLength() { + return buffer.length; + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java Fri Jul 01 16:50:37 2016 -0700 @@ -112,13 +112,11 @@ @Override public Stream entries() { - Stream ret = null; try { - ret = Files.walk(dirPath).map(this::toEntry).filter(n -> n != null); + return Files.walk(dirPath).map(this::toEntry).filter(n -> n != null); } catch (IOException ex) { throw new RuntimeException(ex); } - return ret; } private Archive.Entry toEntry(Path p) { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ExecutableImage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ExecutableImage.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015, 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 jdk.tools.jlink.internal; + +import java.nio.file.Path; +import java.util.List; +import java.util.Set; + +/** + * An executable runtime image. Contains the information about the executable + * image created. + */ +public interface ExecutableImage { + + /** + * Image home directory, + * + * @return The home directory. + */ + public Path getHome(); + + /** + * The names of the modules located in the image. + * + * @return The set of modules. + */ + public Set getModules(); + + /** + * The list of arguments required to execute the image. + * + * @return The list of arguments. + */ + public List getExecutionArgs(); + + /** + * Store new arguments required to execute the image. + * + * @param args Additional arguments + */ + public void storeLaunchArgs(List args); +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java Fri Jul 01 16:50:37 2016 -0700 @@ -25,10 +25,8 @@ package jdk.tools.jlink.internal; import java.io.BufferedOutputStream; -import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; @@ -45,9 +43,7 @@ import jdk.tools.jlink.internal.Archive.Entry; import jdk.tools.jlink.internal.Archive.Entry.EntryType; import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData; -import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.ModuleEntry; /** @@ -73,7 +69,7 @@ private final Map> entriesForModule = new HashMap<>(); private final ImagePluginStack plugins; private ImageFileCreator(ImagePluginStack plugins) { - this.plugins = plugins; + this.plugins = Objects.requireNonNull(plugins); } public static ExecutableImage create(Set archives, @@ -232,10 +228,9 @@ out.write(bytes, 0, bytes.length); // write module content - for (ModuleEntry res : content) { - byte[] buf = res.getBytes(); - out.write(buf, 0, buf.length); - } + content.stream().forEach((res) -> { + res.write(out); + }); tree.addContent(out); @@ -244,21 +239,6 @@ return resultResources; } - private static ModuleEntry.Type mapImageFileType(EntryType type) { - switch(type) { - case CONFIG: { - return ModuleEntry.Type.CONFIG; - } - case NATIVE_CMD: { - return ModuleEntry.Type.NATIVE_CMD; - } - case NATIVE_LIB: { - return ModuleEntry.Type.NATIVE_LIB; - } - } - return null; - } - private static ModulePoolImpl createPools(Set archives, Map> entriesForModule, ByteOrder byteOrder, @@ -278,54 +258,27 @@ for (Archive archive : archives) { String mn = archive.moduleName(); for (Entry entry : entriesForModule.get(mn)) { - + String path; if (entry.type() == EntryType.CLASS_OR_RESOURCE) { // Removal of "classes/" radical. - String path = entry.name(); - try (InputStream stream = entry.stream()) { - byte[] bytes = readAllBytes(stream); - if (path.endsWith("module-info.class")) { - path = "/" + path; - } else { - path = "/" + mn + "/" + path; - } - try { - resources.add(ModuleEntry.create(path, bytes)); - } catch (Exception ex) { - throw new IOException(ex); - } + path = entry.name(); + if (path.endsWith("module-info.class")) { + path = "/" + path; + } else { + path = "/" + mn + "/" + path; } } else { - try { - // Entry.path() contains the kind of file native, conf, bin, ... - // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg - resources.add(ModuleEntry.create(mn, - "/" + mn + "/" + entry.path(), mapImageFileType(entry.type()), - entry.stream(), entry.size())); - } catch (Exception ex) { - throw new IOException(ex); - } + // Entry.path() contains the kind of file native, conf, bin, ... + // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg + path = "/" + mn + "/" + entry.path(); } + + resources.add(new ArchiveEntryModuleEntry(mn, path, entry)); } } return resources; } - private static final int BUF_SIZE = 8192; - - private static byte[] readAllBytes(InputStream is) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buf = new byte[BUF_SIZE]; - while (true) { - int n = is.read(buf); - if (n < 0) { - break; - } - baos.write(buf, 0, n); - } - return baos.toByteArray(); - } - /** * Helper method that splits a Resource path onto 3 items: module, parent * and resource name. diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java Fri Jul 01 16:50:37 2016 -0700 @@ -32,33 +32,30 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.builder.ImageBuilder; import jdk.tools.jlink.Jlink; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.Plugin.Category; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.PostProcessorPlugin; -import jdk.tools.jlink.plugin.TransformerPlugin; /** * Plugins configuration. */ public final class ImagePluginConfiguration { - private static final List CATEGORIES_ORDER = new ArrayList<>(); + private static final List CATEGORIES_ORDER = new ArrayList<>(); static { - CATEGORIES_ORDER.add(Plugin.Category.FILTER); - CATEGORIES_ORDER.add(Plugin.Category.TRANSFORMER); - CATEGORIES_ORDER.add(Plugin.Category.MODULEINFO_TRANSFORMER); - CATEGORIES_ORDER.add(Plugin.Category.SORTER); - CATEGORIES_ORDER.add(Plugin.Category.COMPRESSOR); - CATEGORIES_ORDER.add(Plugin.Category.METAINFO_ADDER); - CATEGORIES_ORDER.add(Plugin.Category.VERIFIER); - CATEGORIES_ORDER.add(Plugin.Category.PROCESSOR); - CATEGORIES_ORDER.add(Plugin.Category.PACKAGER); + CATEGORIES_ORDER.add(Category.FILTER); + CATEGORIES_ORDER.add(Category.TRANSFORMER); + CATEGORIES_ORDER.add(Category.MODULEINFO_TRANSFORMER); + CATEGORIES_ORDER.add(Category.SORTER); + CATEGORIES_ORDER.add(Category.COMPRESSOR); + CATEGORIES_ORDER.add(Category.METAINFO_ADDER); + CATEGORIES_ORDER.add(Category.VERIFIER); + CATEGORIES_ORDER.add(Category.PROCESSOR); + CATEGORIES_ORDER.add(Category.PACKAGER); } private ImagePluginConfiguration() { @@ -72,8 +69,8 @@ if (pluginsConfiguration == null) { return new ImagePluginStack(); } - Map> plugins = new LinkedHashMap<>(); - for (Plugin.Category cat : CATEGORIES_ORDER) { + Map> plugins = new LinkedHashMap<>(); + for (Category cat : CATEGORIES_ORDER) { plugins.put(cat, new ArrayList<>()); } @@ -85,7 +82,7 @@ + " added more than once to stack "); } seen.add(plug.getName()); - Category category = Utils.getCategory(plug); + Category category = plug.getType(); if (category == null) { throw new PluginException("Invalid category for " + plug.getName()); @@ -94,26 +91,13 @@ lst.add(plug); } - List transformerPlugins = new ArrayList<>(); - List postProcessingPlugins = new ArrayList<>(); - for (Entry> entry : plugins.entrySet()) { + List orderedPlugins = new ArrayList<>(); + plugins.entrySet().stream().forEach((entry) -> { // Sort according to plugin constraints - List orderedPlugins = PluginOrderingGraph.sort(entry.getValue()); - Category category = entry.getKey(); - for (Plugin p : orderedPlugins) { - if (category.isPostProcessor()) { - @SuppressWarnings("unchecked") - PostProcessorPlugin pp = (PostProcessorPlugin) p; - postProcessingPlugins.add(pp); - } else { - @SuppressWarnings("unchecked") - TransformerPlugin trans = (TransformerPlugin) p; - transformerPlugins.add(trans); - } - } - } + orderedPlugins.addAll(PluginOrderingGraph.sort(entry.getValue())); + }); Plugin lastSorter = null; - for (Plugin plugin : transformerPlugins) { + for (Plugin plugin : orderedPlugins) { if (plugin.getName().equals(pluginsConfiguration.getLastSorterPluginName())) { lastSorter = plugin; break; @@ -145,7 +129,6 @@ }; } - return new ImagePluginStack(builder, transformerPlugins, - lastSorter, postProcessingPlugins); + return new ImagePluginStack(builder, orderedPlugins, lastSorter); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,7 +24,6 @@ */ package jdk.tools.jlink.internal; -import java.io.ByteArrayInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.module.ModuleDescriptor; @@ -45,14 +44,11 @@ import jdk.internal.jimage.decompressor.Decompressor; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.builder.ImageBuilder; -import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.LinkModule; import jdk.tools.jlink.plugin.ModuleEntry; -import jdk.tools.jlink.plugin.PostProcessorPlugin; /** * Plugins Stack. Plugins entry point to apply transformations onto resources @@ -96,7 +92,7 @@ public CheckOrderResourcePool(ByteOrder order, List orderedList, StringTable table) { super(order, table); - this.orderedList = orderedList; + this.orderedList = Objects.requireNonNull(orderedList); } /** @@ -119,7 +115,6 @@ private int currentid = 0; private final Map stringsUsage = new HashMap<>(); - private final Map stringsMap = new HashMap<>(); private final Map reverseMap = new HashMap<>(); @@ -161,47 +156,40 @@ } } + private final ImageBuilder imageBuilder; private final Plugin lastSorter; - private final List contentPlugins = new ArrayList<>(); - private final List postProcessingPlugins = new ArrayList<>(); + private final List plugins = new ArrayList<>(); private final List resourcePrevisitors = new ArrayList<>(); - private final ImageBuilder imageBuilder; public ImagePluginStack() { - this(null, Collections.emptyList(), null, - Collections.emptyList()); + this(null, Collections.emptyList(), null); } public ImagePluginStack(ImageBuilder imageBuilder, - List contentPlugins, - Plugin lastSorter, - List postprocessingPlugins) { - Objects.requireNonNull(contentPlugins); + List plugins, + Plugin lastSorter) { + this.imageBuilder = Objects.requireNonNull(imageBuilder); this.lastSorter = lastSorter; - for (TransformerPlugin p : contentPlugins) { + this.plugins.addAll(Objects.requireNonNull(plugins)); + plugins.stream().forEach((p) -> { Objects.requireNonNull(p); if (p instanceof ResourcePrevisitor) { resourcePrevisitors.add((ResourcePrevisitor) p); } - this.contentPlugins.add(p); - } - for (PostProcessorPlugin p : postprocessingPlugins) { - Objects.requireNonNull(p); - this.postProcessingPlugins.add(p); - } - this.imageBuilder = imageBuilder; + }); } public void operate(ImageProvider provider) throws Exception { ExecutableImage img = provider.retrieve(this); List arguments = new ArrayList<>(); - for (PostProcessorPlugin plugin : postProcessingPlugins) { - List lst = plugin.process(img); - if (lst != null) { - arguments.addAll(lst); - } - } + plugins.stream() + .filter(PostProcessor.class::isInstance) + .map((plugin) -> ((PostProcessor)plugin).process(img)) + .filter((lst) -> (lst != null)) + .forEach((lst) -> { + arguments.addAll(lst); + }); img.storeLaunchArgs(arguments); } @@ -230,19 +218,19 @@ resources.getStringTable()); } PreVisitStrings previsit = new PreVisitStrings(); - for (ResourcePrevisitor p : resourcePrevisitors) { + resourcePrevisitors.stream().forEach((p) -> { p.previsit(resources, previsit); - } + }); // Store the strings resulting from the previsit. List sorted = previsit.getSortedStrings(); - for (String s : sorted) { + sorted.stream().forEach((s) -> { resources.getStringTable().addString(s); - } + }); ModulePoolImpl current = resources; List frozenOrder = null; - for (TransformerPlugin p : contentPlugins) { + for (Plugin p : plugins) { current.setReadOnly(); ModulePoolImpl output = null; if (p == lastSorter) { @@ -443,9 +431,7 @@ byte[] bytes = decompressor.decompressResource(getByteOrder(), (int offset) -> pool.getStringTable().getString(offset), res.getBytes()); - res = ModuleEntry.create(res.getPath(), - new ByteArrayInputStream(bytes), - bytes.length); + res = res.create(bytes); } catch (IOException ex) { throw new PluginException(ex); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java Fri Jul 01 16:50:37 2016 -0700 @@ -113,8 +113,7 @@ private final boolean isEmpty; PackageReference(String name, boolean isEmpty) { - Objects.requireNonNull(name); - this.name = name; + this.name = Objects.requireNonNull(name); this.isEmpty = isEmpty; } @@ -132,12 +131,8 @@ private void addReference(String name, boolean isEmpty) { PackageReference ref = references.get(name); - if (ref == null) { + if (ref == null || ref.isEmpty) { references.put(name, new PackageReference(name, isEmpty)); - } else { - if (ref.isEmpty) { // replace with new one incase non empty. - references.put(name, new PackageReference(name, isEmpty)); - } } } @@ -267,8 +262,7 @@ } // Validate that the packages are well formed. for (Node n : packages.children.values()) { - PackageNode pkg = (PackageNode) n; - pkg.validate(); + ((PackageNode)n).validate(); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java Fri Jul 01 16:50:37 2016 -0700 @@ -44,9 +44,15 @@ // Reserve 0 offset for empty string. int offset = addString(""); - assert offset == 0 : "Empty string not zero offset"; + if (offset != 0) { + throw new InternalError("Empty string not offset zero"); + } + // Reserve 1 offset for frequently used ".class". - addString("class"); + offset = addString("class"); + if (offset != 1) { + throw new InternalError("'class' string not offset one"); + } } private int addString(final String string) { @@ -76,7 +82,9 @@ public String get(int offset) { ByteBuffer buffer = stream.getBuffer(); int capacity = buffer.capacity(); - assert 0 <= offset && offset < capacity : "String buffer offset out of range"; + if (offset < 0 || offset >= capacity) { + throw new InternalError("String buffer offset out of range"); + } int zero = NOT_FOUND; for (int i = offset; i < capacity; i++) { if (buffer.get(i) == '\0') { @@ -84,7 +92,9 @@ break; } } - assert zero != NOT_FOUND; + if (zero == NOT_FOUND) { + throw new InternalError("String zero terminator not found"); + } int length = zero - offset; byte[] bytes = new byte[length]; int mark = buffer.position(); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java Fri Jul 01 16:50:37 2016 -0700 @@ -30,8 +30,6 @@ import java.io.UncheckedIOException; import java.nio.file.Path; import java.util.Objects; -import java.util.function.Consumer; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -53,8 +51,8 @@ JarEntry(String path, String name, EntryType type, ZipFile file, ZipEntry entry) { super(JarArchive.this, path, name, type); - this.entry = entry; - this.file = file; + this.entry = Objects.requireNonNull(entry); + this.file = Objects.requireNonNull(file); size = entry.getSize(); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Fri Jul 01 16:50:37 2016 -0700 @@ -49,7 +49,6 @@ import jdk.tools.jlink.internal.TaskHelper.Option; import jdk.tools.jlink.internal.TaskHelper.OptionsHelper; import jdk.tools.jlink.internal.ImagePluginStack.ImageProvider; -import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.Jlink.JlinkConfiguration; import jdk.tools.jlink.Jlink.PluginsConfiguration; import jdk.tools.jlink.plugin.PluginException; @@ -82,7 +81,7 @@ private static final TaskHelper taskHelper = new TaskHelper(JLINK_BUNDLE); - static Option[] recognizedOptions = { + private static final Option[] recognizedOptions = { new Option(false, (task, opt, arg) -> { task.options.help = true; }, "--help"), @@ -176,7 +175,7 @@ int run(String[] args) { if (log == null) { - setLog(new PrintWriter(System.err, true)); + setLog(new PrintWriter(System.out, true)); } try { optionsHelper.handleOptions(this, args); @@ -184,8 +183,8 @@ optionsHelper.showHelp(PROGNAME); return EXIT_OK; } - if (optionsHelper.listPlugins()) { - optionsHelper.listPlugins(true); + if (optionsHelper.shouldListPlugins()) { + optionsHelper.listPlugins(); return EXIT_OK; } if (options.version || options.fullVersion) { @@ -325,7 +324,6 @@ Set limitMods, Set addMods) { - ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0])); // jmods are located at link-time diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java Fri Jul 01 16:50:37 2016 -0700 @@ -25,7 +25,6 @@ package jdk.tools.jlink.internal; -import jdk.tools.jlink.internal.JarArchive; import java.nio.file.Path; import java.util.Objects; import jdk.tools.jlink.internal.Archive.Entry.EntryType; @@ -35,7 +34,7 @@ */ public class JmodArchive extends JarArchive { - private static final String JMOD_EXT = ".jmod"; + private static final String JMOD_EXT = ".jmod"; private static final String MODULE_NAME = "module"; private static final String MODULE_INFO = "module-info.class"; private static final String CLASSES = "classes"; @@ -46,8 +45,9 @@ public JmodArchive(String mn, Path jmod) { super(mn, jmod); String filename = Objects.requireNonNull(jmod.getFileName()).toString(); - if (!filename.endsWith(JMOD_EXT)) + if (!filename.endsWith(JMOD_EXT)) { throw new UnsupportedOperationException("Unsupported format: " + filename); + } } @Override @@ -65,7 +65,6 @@ case MODULE_NAME: return EntryType.MODULE_NAME; default: - //throw new InternalError("unexpected entry: " + name + " " + zipfile.toString()); //TODO throw new InternalError("unexpected entry: " + section); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java Fri Jul 01 16:50:37 2016 -0700 @@ -39,8 +39,9 @@ public ModularJarArchive(String mn, Path jmod) { super(mn, jmod); String filename = Objects.requireNonNull(jmod.getFileName()).toString(); - if (!filename.endsWith(JAR_EXT)) + if (!filename.endsWith(JAR_EXT)) { throw new UnsupportedOperationException("Unsupported format: " + filename); + } } @Override diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016, 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 jdk.tools.jlink.internal; + +import java.nio.file.Path; +import java.util.Objects; +import jdk.tools.jlink.plugin.ModuleEntry; + +public final class ModuleEntryFactory { + private ModuleEntryFactory() {} + + public static ModuleEntry create(String path, + ModuleEntry.Type type, byte[] content) { + return new ByteArrayModuleEntry(moduleFrom(path), path, type, content); + } + + public static ModuleEntry create(String path, + ModuleEntry.Type type, Path file) { + return new PathModuleEntry(moduleFrom(path), path, type, file); + } + + public static ModuleEntry create(ModuleEntry original, byte[] content) { + return new ByteArrayModuleEntry(original.getModule(), + original.getPath(), original.getType(), content); + } + + public static ModuleEntry create(ModuleEntry original, Path file) { + return new PathModuleEntry(original.getModule(), + original.getPath(), original.getType(), file); + } + + private static String moduleFrom(String path) { + Objects.requireNonNull(path); + if (path.isEmpty() || path.charAt(0) != '/') { + throw new IllegalArgumentException(path + " must start with /"); + } + String noRoot = path.substring(1); + int idx = noRoot.indexOf('/'); + if (idx == -1) { + throw new IllegalArgumentException("/ missing after module: " + path); + } + return noRoot.substring(0, idx); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java Fri Jun 24 15:06:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2016, 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 jdk.tools.jlink.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.util.Objects; -import jdk.tools.jlink.plugin.ModuleEntry; - -/** - * A LinkModuleEntry is the elementary unit of data inside an image. It is - * generally a file. e.g.: a java class file, a resource file, a shared library, - * ... - *
    - * A LinkModuleEntry is identified by a path of the form: - *
      - *
    • For jimage content: /{module name}/{package1}/.../{packageN}/{file - * name}
    • - *
    • For other files (shared lib, launchers, config, ...):/{module name}/ - * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}
    • - *
    - */ -public class ModuleEntryImpl implements ModuleEntry { - - private final Type type; - private final String path; - private final String module; - private final long length; - private final InputStream stream; - private byte[] buffer; - - /** - * Create a new LinkModuleEntry. - * - * @param module The module name. - * @param path The data path identifier. - * @param type The data type. - * @param stream The data content stream. - * @param length The stream length. - */ - public ModuleEntryImpl(String module, String path, Type type, InputStream stream, long length) { - Objects.requireNonNull(module); - Objects.requireNonNull(path); - Objects.requireNonNull(type); - Objects.requireNonNull(stream); - this.path = path; - this.type = type; - this.module = module; - this.stream = stream; - this.length = length; - } - - /** - * The LinkModuleEntry module name. - * - * @return The module name. - */ - @Override - public final String getModule() { - return module; - } - - /** - * The LinkModuleEntry path. - * - * @return The module path. - */ - @Override - public final String getPath() { - return path; - } - - /** - * The LinkModuleEntry's type. - * - * @return The data type. - */ - @Override - public final Type getType() { - return type; - } - - /** - * The LinkModuleEntry content as an array of byte. - * - * @return An Array of bytes. - */ - @Override - public byte[] getBytes() { - if (buffer == null) { - try (InputStream is = stream) { - buffer = is.readAllBytes(); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - } - return buffer; - } - - /** - * The LinkModuleEntry content length. - * - * @return The length. - */ - @Override - public long getLength() { - return length; - } - - /** - * The LinkModuleEntry stream. - * - * @return The module data stream. - */ - @Override - public InputStream stream() { - return stream; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 89 * hash + Objects.hashCode(this.path); - return hash; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof ModuleEntryImpl)) { - return false; - } - ModuleEntryImpl f = (ModuleEntryImpl) other; - return f.path.equals(path); - } - - @Override - public String toString() { - return getPath(); - } -} \ No newline at end of file diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,8 +24,6 @@ */ package jdk.tools.jlink.internal; -import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.lang.module.ModuleDescriptor; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -95,7 +93,7 @@ @Override public void add(ModuleEntry data) { if (isReadOnly()) { - throw new PluginException("LinkConfiguration is readonly"); + throw new PluginException("ModulePool is readonly"); } Objects.requireNonNull(data); if (!data.getModule().equals(name)) { @@ -168,8 +166,8 @@ } public ModulePoolImpl(ByteOrder order, StringTable table) { - this.order = order; - this.table = table; + this.order = Objects.requireNonNull(order); + this.table = Objects.requireNonNull(table); } /** @@ -180,7 +178,7 @@ @Override public void add(ModuleEntry data) { if (isReadOnly()) { - throw new PluginException("LinkConfiguration is readonly"); + throw new PluginException("ModulePool is readonly"); } Objects.requireNonNull(data); if (resources.get(data.getPath()) != null) { @@ -215,7 +213,7 @@ } /** - * The stream of modules contained in this LinkConfiguration. + * The stream of modules contained in this ModulePool. * * @return The stream of modules. */ @@ -225,7 +223,7 @@ } /** - * Return the number of LinkModule count in this LinkConfiguration. + * Return the number of LinkModule count in this ModulePool. * * @return the module count. */ @@ -235,7 +233,7 @@ } /** - * Get all ModuleEntry contained in this LinkConfiguration instance. + * Get all ModuleEntry contained in this ModulePool instance. * * @return The stream of LinkModuleEntries. */ @@ -245,7 +243,7 @@ } /** - * Return the number of ModuleEntry count in this LinkConfiguration. + * Return the number of ModuleEntry count in this ModulePool. * * @return the entry count. */ @@ -267,7 +265,7 @@ } /** - * Check if the LinkConfiguration contains the given ModuleEntry. + * Check if the ModulePool contains the given ModuleEntry. * * @param data The module data to check existence for. * @return The module data or null if not found. @@ -279,7 +277,7 @@ } /** - * Check if the LinkConfiguration contains some content at all. + * Check if the ModulePool contains some content at all. * * @return True, no content, false otherwise. */ @@ -289,16 +287,16 @@ } /** - * Visit each ModuleEntry in this LinkConfiguration to transform it and - * copy the transformed ModuleEntry to the output LinkConfiguration. + * Visit each ModuleEntry in this ModulePool to transform it and + * copy the transformed ModuleEntry to the output ModulePool. * * @param transform The function called for each ModuleEntry found in - * the LinkConfiguration. The transform function should return a + * the ModulePool. The transform function should return a * ModuleEntry instance which will be added to the output or it should * return null if the passed ModuleEntry is to be ignored for the * output. * - * @param output The LinkConfiguration to be filled with Visitor returned + * @param output The ModulePool to be filled with Visitor returned * ModuleEntry. */ @Override @@ -351,14 +349,13 @@ /** * A resource that has been compressed. */ - public static final class CompressedModuleData extends ModuleEntryImpl { + public static final class CompressedModuleData extends ByteArrayModuleEntry { final long uncompressed_size; private CompressedModuleData(String module, String path, - InputStream stream, long size, - long uncompressed_size) { - super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, stream, size); + byte[] content, long uncompressed_size) { + super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, content); this.uncompressed_size = uncompressed_size; } @@ -413,8 +410,7 @@ CompressedModuleData compressedResource = new CompressedModuleData(original.getModule(), original.getPath(), - new ByteArrayInputStream(contentWithHeader), - contentWithHeader.length, uncompressed_size); + contentWithHeader, uncompressed_size); return compressedResource; } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016, 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 "Classfile" 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 jdk.tools.jlink.internal; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Objects; + +/** + * A ModuleEntry backed by a given nio Path. + */ +public class PathModuleEntry extends AbstractModuleEntry { + private final Path file; + + /** + * Create a new PathModuleEntry. + * + * @param module The module name. + * @param path The path for the resource content. + * @param type The data type. + * @param file The data file identifier. + */ + public PathModuleEntry(String module, String path, Type type, Path file) { + super(module, path, type); + this.file = Objects.requireNonNull(file); + if (!Files.isRegularFile(file)) { + throw new IllegalArgumentException(file + " not a file"); + } + } + + @Override + public final InputStream stream() { + try { + return Files.newInputStream(file); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + @Override + public final long getLength() { + try { + return Files.size(file); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java Fri Jul 01 16:50:37 2016 -0700 @@ -34,8 +34,6 @@ import java.util.ServiceLoader; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.PostProcessorPlugin; -import jdk.tools.jlink.plugin.TransformerPlugin; /** * @@ -59,17 +57,7 @@ */ public static Plugin getPlugin(String name, Layer pluginsLayer) { - Plugin tp = getPlugin(TransformerPlugin.class, name, pluginsLayer); - Plugin ppp = getPlugin(PostProcessorPlugin.class, name, pluginsLayer); - - // We should not have a transformer plugin and a post processor plugin - // of the same name. That kind of duplicate is detected here. - if (tp != null && ppp != null) { - throw new PluginException("Multiple plugin " - + "for the name " + name); - } - - return tp != null? tp : ppp; + return getPlugin(Plugin.class, name, pluginsLayer); } /** @@ -112,10 +100,7 @@ } public static List getPlugins(Layer pluginsLayer) { - List plugins = new ArrayList<>(); - plugins.addAll(getPlugins(TransformerPlugin.class, pluginsLayer)); - plugins.addAll(getPlugins(PostProcessorPlugin.class, pluginsLayer)); - return plugins; + return getPlugins(Plugin.class, pluginsLayer); } private static T getPlugin(Class clazz, String name, @@ -138,10 +123,10 @@ } /** - * The post processors accessible in the current context. + * The plugins accessible in the current context. * * @param pluginsLayer - * @return The list of post processors. + * @return The list of plugins. */ private static List getPlugins(Class clazz, Layer pluginsLayer) { Objects.requireNonNull(pluginsLayer); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PostProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PostProcessor.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015, 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 jdk.tools.jlink.internal; + +import java.util.List; + +/** + * Plugin wishing to post-proces must implement this interface. PostProcessors + * are called once the image has been generated and is executable. + **/ +public interface PostProcessor { + + /** + * Post process an image. + * + * @param image The executable image. + * @return The list of arguments to add to launchers (if any). + */ + public List process(ExecutableImage image); +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java Fri Jul 01 16:50:37 2016 -0700 @@ -42,7 +42,6 @@ * @param resources Read only resources. * @param strings StringTable instance. Add string to the StringTable to track string * usage. - * @throws PluginException */ public void previsit(ModulePool resources, StringTable strings); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java Fri Jul 01 16:50:37 2016 -0700 @@ -428,7 +428,7 @@ return opt.hasArg; } - public boolean listPlugins() { + public boolean shouldListPlugins() { return pluginOptions.listPlugins; } @@ -570,24 +570,19 @@ log.println(bundleHelper.getMessage("main.command.files")); } - public void listPlugins(boolean showsImageBuilder) { + public void listPlugins() { log.println("\n" + bundleHelper.getMessage("main.extended.help")); List pluginList = PluginRepository. getPlugins(pluginOptions.pluginsLayer); - for (Plugin plugin : Utils. - getSortedPreProcessors(pluginList)) { - showPlugin(plugin, log, showsImageBuilder); + for (Plugin plugin : Utils.getSortedPlugins(pluginList)) { + showPlugin(plugin, log); } - if (showsImageBuilder) { - for (Plugin plugin : Utils.getSortedPostProcessors(pluginList)) { - showPlugin(plugin, log, showsImageBuilder); - } - } + log.println("\n" + bundleHelper.getMessage("main.extended.help.footer")); } - private void showPlugin(Plugin plugin, PrintWriter log, boolean showsImageBuilder) { - if (showsPlugin(plugin, showsImageBuilder)) { + private void showPlugin(Plugin plugin, PrintWriter log) { + if (showsPlugin(plugin)) { log.println("\n" + bundleHelper.getMessage("main.plugin.name") + ": " + plugin.getName()); @@ -597,7 +592,7 @@ + ": " + plugin.getClass().getName()); log.println(bundleHelper.getMessage("main.plugin.module") + ": " + plugin.getClass().getModule().getName()); - Category category = Utils.getCategory(plugin); + Category category = plugin.getType(); log.println(bundleHelper.getMessage("main.plugin.category") + ": " + category.getName()); log.println(bundleHelper.getMessage("main.plugin.state") @@ -720,14 +715,8 @@ } } - // Display all plugins or pre processors only. - private static boolean showsPlugin(Plugin plugin, boolean showsImageBuilder) { - if (!Utils.isDisabled(plugin) && plugin.getOption() != null) { - if (Utils.isPostProcessor(plugin) && !showsImageBuilder) { - return false; - } - return true; - } - return false; + // Display all plugins + private static boolean showsPlugin(Plugin plugin) { + return (!Utils.isDisabled(plugin) && plugin.getOption() != null); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java Fri Jul 01 16:50:37 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.Plugin.Category; @@ -56,51 +55,10 @@ .collect(Collectors.toList()); } - public static boolean isPostProcessor(Plugin provider) { - return provider.getType().isPostProcessor(); - } - public static boolean isPreProcessor(Plugin provider) { - return !isPostProcessor(provider); - } - - public static Category getCategory(Plugin provider) { - return provider.getType(); - } - - public static List getPreProcessors(List plugins) { + public static List getSortedPlugins(List plugins) { List res = new ArrayList<>(); - for (Plugin p : plugins) { - if (isPreProcessor(p)) { - res.add(p); - } - } - return res; - } - - public static List getPostProcessors(List plugins) { - List res = new ArrayList<>(); - for (Plugin p : plugins) { - if (isPostProcessor(p)) { - res.add(p); - } - } - return res; - } - - public static List getSortedPostProcessors(List plugins) { - List res = getPostProcessors(plugins); - res.sort(new Comparator() { - @Override - public int compare(Plugin o1, Plugin o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - return res; - } - - public static List getSortedPreProcessors(List plugins) { - List res = getPreProcessors(plugins); + res.addAll(plugins); res.sort(new Comparator() { @Override public int compare(Plugin o1, Plugin o2) { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java Fri Jul 01 16:50:37 2016 -0700 @@ -127,7 +127,7 @@ jlink.build(jlinkConfig, pluginConfig); } - /** + /* * Returns a ModuleFinder that limits observability to the given root * modules, their transitive dependences, plus a set of other modules. */ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,12 +24,11 @@ */ package jdk.tools.jlink.internal.plugins; -import java.util.Collections; import java.util.Map; import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.internal.ImagePluginStack; import jdk.tools.jlink.internal.ResourcePrevisitor; import jdk.tools.jlink.internal.StringTable; @@ -38,7 +37,7 @@ * * ZIP and String Sharing compression plugin */ -public final class DefaultCompressPlugin implements TransformerPlugin, ResourcePrevisitor { +public final class DefaultCompressPlugin implements Plugin, ResourcePrevisitor { public static final String NAME = "compress"; public static final String FILTER = "filter"; public static final String LEVEL_0 = "0"; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,20 +24,17 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.UncheckedIOException; -import java.util.Collections; import java.util.Map; import java.util.function.Predicate; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.ModuleEntry; -import jdk.tools.jlink.internal.Utils; /** * * Exclude files plugin */ -public final class ExcludeFilesPlugin implements TransformerPlugin { +public final class ExcludeFilesPlugin implements Plugin { public static final String NAME = "exclude-files"; private Predicate predicate; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,10 +24,9 @@ */ package jdk.tools.jlink.internal.plugins; -import java.util.Collections; import java.util.Map; import java.util.function.Predicate; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; @@ -35,7 +34,7 @@ * * Exclude resources plugin */ -public final class ExcludePlugin implements TransformerPlugin { +public final class ExcludePlugin implements Plugin { public static final String NAME = "exclude-resources"; private Predicate predicate; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -25,19 +25,17 @@ package jdk.tools.jlink.internal.plugins; import java.io.BufferedReader; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; -import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.TreeSet; import java.util.function.Predicate; import java.util.stream.Collectors; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; @@ -46,7 +44,7 @@ * * Exclude VM plugin */ -public final class ExcludeVMPlugin implements TransformerPlugin { +public final class ExcludeVMPlugin implements Plugin { private static final class JvmComparator implements Comparator { @@ -244,10 +242,7 @@ byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8); - return ModuleEntry.create(orig.getModule(), - orig.getPath(), - orig.getType(), - new ByteArrayInputStream(content), content.length); + return orig.create(content); } private static String jvmlib() { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -26,7 +26,6 @@ import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.UncheckedIOException; import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; @@ -35,22 +34,21 @@ import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; -import jdk.tools.jlink.internal.ModuleEntryImpl; +import jdk.tools.jlink.internal.PathModuleEntry; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.internal.Utils; /** * * Copy files to image from various locations. */ -public class FileCopierPlugin implements TransformerPlugin { +public class FileCopierPlugin implements Plugin { public static final String NAME = "copy-files"; @@ -66,13 +64,13 @@ /** * Symbolic link to another path. */ - public static abstract class SymImageFile extends ModuleEntryImpl { + public static abstract class SymImageFile extends PathModuleEntry { private final String targetPath; public SymImageFile(String targetPath, String module, String path, - ModuleEntry.Type type, InputStream stream, long size) { - super(module, path, type, stream, size); + ModuleEntry.Type type, Path file) { + super(module, path, type, file); this.targetPath = targetPath; } @@ -85,23 +83,7 @@ public SymImageFileImpl(String targetPath, Path file, String module, String path, ModuleEntry.Type type) { - super(targetPath, module, path, type, newStream(file), length(file)); - } - } - - private static long length(Path file) { - try { - return Files.size(file); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - private static InputStream newStream(Path file) { - try { - return Files.newInputStream(file); - } catch (IOException ex) { - throw new UncheckedIOException(ex); + super(targetPath, module, path, type, file); } } @@ -175,9 +157,9 @@ Objects.requireNonNull(pool); Objects.requireNonNull(file); Objects.requireNonNull(path); - ModuleEntry impl = ModuleEntry.create(FAKE_MODULE, + ModuleEntry impl = ModuleEntry.create( "/" + FAKE_MODULE + "/other/" + path, - ModuleEntry.Type.OTHER, newStream(file), length(file)); + ModuleEntry.Type.OTHER, file); try { pool.add(impl); } catch (Exception ex) { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,10 +24,8 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.ByteArrayInputStream; import java.lang.reflect.Method; import java.util.Arrays; -import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Map; @@ -36,12 +34,12 @@ import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; /** * Plugin to generate java.lang.invoke classes. */ -public final class GenerateJLIClassesPlugin implements TransformerPlugin { +public final class GenerateJLIClassesPlugin implements Plugin { private static final String NAME = "generate-jli-classes"; @@ -171,10 +169,9 @@ byte[] bytes = result.getValue(); // Add class to pool - ModuleEntry ndata = ModuleEntry.create(data.getModule(), + ModuleEntry ndata = ModuleEntry.create( "/java.base/" + className + ".class", - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(bytes), bytes.length); + bytes); if (!out.contains(ndata)) { out.add(ndata); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,10 +24,8 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.IllformedLocaleException; import java.util.Locale; import java.util.List; @@ -46,7 +44,7 @@ import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; /** * Plugin to explicitly specify the locale data included in jdk.localedata @@ -70,7 +68,7 @@ * start with at least one white space character, e.g., " ar ar-EG ..." * ^ */ -public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePrevisitor { +public final class IncludeLocalesPlugin implements Plugin, ResourcePrevisitor { public static final String NAME = "include-locales"; private static final String MODULENAME = "jdk.localedata"; @@ -123,9 +121,7 @@ if (Arrays.stream(cr.getInterfaces()) .anyMatch(i -> i.contains(METAINFONAME)) && stripUnsupportedLocales(bytes, cr)) { - resource = ModuleEntry.create(MODULENAME, path, - resource.getType(), - new ByteArrayInputStream(bytes), bytes.length); + resource = resource.create(bytes); } } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -30,7 +30,6 @@ import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -30,23 +30,21 @@ import java.nio.file.Files; import java.nio.file.PathMatcher; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.function.ToIntFunction; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.internal.Utils; /** * * Order Resources plugin */ -public final class OrderResourcesPlugin implements TransformerPlugin { +public final class OrderResourcesPlugin implements Plugin { public static final String NAME = "order-resources"; private static final FileSystem JRT_FILE_SYSTEM = Utils.jrtFileSystem(); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -26,7 +26,6 @@ import java.io.FileInputStream; import java.io.IOException; -import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; @@ -37,12 +36,12 @@ import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.Plugin.Category; import jdk.tools.jlink.plugin.Plugin.State; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; /** * This plugin adds/deletes information for 'release' file. */ -public final class ReleaseInfoPlugin implements TransformerPlugin { +public final class ReleaseInfoPlugin implements Plugin { // option name public static final String NAME = "release-info"; public static final String KEYS = "keys"; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -46,7 +46,6 @@ import java.io.InputStream; import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -57,7 +56,7 @@ import jdk.internal.jimage.decompressor.SignatureParser; import jdk.internal.jimage.decompressor.StringSharingDecompressor; import jdk.tools.jlink.internal.ModulePoolImpl; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; @@ -69,7 +68,7 @@ * A Plugin that stores the image classes constant pool UTF_8 entries into the * Image StringsTable. */ -public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisitor { +public class StringSharingPlugin implements Plugin, ResourcePrevisitor { public static final String NAME = "compact-cp"; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,21 +24,18 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.ByteArrayInputStream; -import java.util.Arrays; -import java.util.Collections; import java.util.function.Predicate; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; /** * * Strip debug attributes plugin */ -public final class StripDebugPlugin implements TransformerPlugin { +public final class StripDebugPlugin implements Plugin { public static final String NAME = "strip-debug"; private final Predicate predicate; @@ -75,7 +72,7 @@ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); reader.accept(writer, ClassReader.SKIP_DEBUG); byte[] content = writer.toByteArray(); - res = ModuleEntry.create(path, new ByteArrayInputStream(content), content.length); + res = resource.create(content); } } } else if (predicate.test(res.getPath())) { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,16 +24,15 @@ */ package jdk.tools.jlink.internal.plugins; -import java.util.Collections; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; /** * * Strip Native Commands plugin */ -public final class StripNativeCommandsPlugin implements TransformerPlugin { +public final class StripNativeCommandsPlugin implements Plugin { public static final String NAME = "strip-native-commands"; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -52,7 +52,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin.Builder.*; import jdk.tools.jlink.plugin.ModuleEntry; @@ -67,7 +67,7 @@ * @see java.lang.module.SystemModuleFinder * @see SystemModules */ -public final class SystemModuleDescriptorPlugin implements TransformerPlugin { +public final class SystemModuleDescriptorPlugin implements Plugin { private static final JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess(); // TODO: packager has the dependency on the plugin name @@ -139,11 +139,7 @@ ModuleInfoRewriter minfoWriter = new ModuleInfoRewriter(bain, mbuilder.conceals()); // replace with the overridden version - data = ModuleEntry.create(data.getModule(), - data.getPath(), - data.getType(), - minfoWriter.stream(), - minfoWriter.size()); + data = data.create(minfoWriter.getBytes()); } out.add(data); } catch (IOException e) { @@ -158,12 +154,7 @@ return; if (builder.isOverriddenClass(data.getPath())) { byte[] bytes = cwriter.toByteArray(); - ModuleEntry ndata = - ModuleEntry.create(data.getModule(), - data.getPath(), - data.getType(), - new ByteArrayInputStream(bytes), - bytes.length); + ModuleEntry ndata = data.create(bytes); out.add(ndata); } else { out.add(data); @@ -183,8 +174,8 @@ this.extender.write(this); } - InputStream stream() { - return new ByteArrayInputStream(buf); + byte[] getBytes() { + return buf; } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -28,20 +28,19 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; -import java.util.Collections; import java.util.Map; import java.util.function.Predicate; import java.util.zip.Deflater; import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; /** * * ZIP Compression plugin */ -public final class ZipPlugin implements TransformerPlugin { +public final class ZipPlugin implements Plugin { public static final String NAME = "zip"; private Predicate predicate; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -25,7 +25,7 @@ package jdk.tools.jlink.internal.plugins.asm; import java.util.Objects; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.internal.ModulePoolImpl; @@ -35,7 +35,7 @@ * resources. * */ -public abstract class AsmPlugin implements TransformerPlugin { +public abstract class AsmPlugin implements Plugin { public AsmPlugin() { } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java Fri Jul 01 16:50:37 2016 -0700 @@ -93,8 +93,7 @@ } byte[] content = writer.toByteArray(); - ModuleEntry res = ModuleEntry.create(path, - new ByteArrayInputStream(content), content.length); + ModuleEntry res = ModuleEntry.create(path, content); transformedClasses.put(className, res); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java Fri Jul 01 16:50:37 2016 -0700 @@ -76,9 +76,7 @@ @Override public int hashCode() { - int hash = 3; - hash = 79 * hash + Objects.hashCode(this.firstInstruction); - return hash; + return Objects.hashCode(this.firstInstruction); } @Override @@ -214,9 +212,7 @@ @Override public int hashCode() { - int hash = 3; - hash = 89 * hash + this.getIndex(); - return hash; + return this.getIndex(); } @Override diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java Fri Jun 24 15:06:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015, 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 jdk.tools.jlink.plugin; - -import java.nio.file.Path; -import java.util.List; -import java.util.Set; - -/** - * An executable runtime image. Contains the information about the executable - * image created. - */ -public interface ExecutableImage { - - /** - * Image home directory, - * - * @return The home directory. - */ - public Path getHome(); - - /** - * The names of the modules located in the image. - * - * @return The set of modules. - */ - public Set getModules(); - - /** - * The list of arguments required to execute the image. - * - * @return The list of arguments. - */ - public List getExecutionArgs(); - - /** - * Store new arguments required to execute the image. - * - * @param args Additional arguments - */ - public void storeLaunchArgs(List args); -} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java Fri Jul 01 16:50:37 2016 -0700 @@ -26,16 +26,18 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.Objects; -import jdk.tools.jlink.internal.ImageFileCreator; -import jdk.tools.jlink.internal.ModuleEntryImpl; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import jdk.tools.jlink.internal.ModuleEntryFactory; /** - * A LinkModuleEntry is the elementary unit of data inside an image. It is - * generally a file. e.g.: a java class file, a resource file, a shared library, - * ... + * A ModuleEntry is the elementary unit of data inside an image. It is + * generally a file. e.g.: a java class file, a resource file, a shared library. *
    - * A LinkModuleEntry is identified by a path of the form: + * A ModuleEntry is identified by a path of the form: *
      *
    • For jimage content: /{module name}/{package1}/.../{packageN}/{file * name}
    • @@ -63,93 +65,133 @@ OTHER } /** - * The LinkModuleEntry module name. + * The ModuleEntry module name. * * @return The module name. */ public String getModule(); /** - * The LinkModuleEntry path. + * The ModuleEntry path. * * @return The module path. */ public String getPath(); /** - * The LinkModuleEntry's type. + * The ModuleEntry's type. * * @return The data type. */ public Type getType(); /** - * The LinkModuleEntry content as an array of byte. + * The ModuleEntry content as an array of bytes. * * @return An Array of bytes. */ - public byte[] getBytes(); + public default byte[] getBytes() { + try (InputStream is = stream()) { + return is.readAllBytes(); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } /** - * The LinkModuleEntry content length. + * The ModuleEntry content length. * * @return The length. */ public long getLength(); /** - * The LinkModuleEntry stream. + * The ModuleEntry stream. * * @return The module data stream. */ public InputStream stream(); + /** + * Write the content of this ModuleEntry to stream. + * + * @param out the output stream + */ + public default void write(OutputStream out) { + try { + out.write(getBytes()); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } /** - * Create a LinkModuleEntry located inside a jimage file. Such - * LinkModuleEntry has a Type being equals to CLASS_OR_RESOURCE. + * Create a ModuleEntry with new content but other information + * copied from this ModuleEntry. * - * @param path The complete resource path (contains the module radical). - * @param content The resource content. - * @param size The content size. - * @return A new LinkModuleEntry. + * @param content The new resource content. + * @return A new ModuleEntry. */ - public static ModuleEntry create(String path, InputStream content, long size) { - Objects.requireNonNull(path); - Objects.requireNonNull(content); - String[] split = ImageFileCreator.splitPath(path); - String module = split[0]; - return new ModuleEntryImpl(module, path, Type.CLASS_OR_RESOURCE, content, size); + public default ModuleEntry create(byte[] content) { + return ModuleEntryFactory.create(this, content); } /** - * Create a LinkModuleEntry for a file that will be located inside a jimage - * file. + * Create a ModuleEntry with new content but other information + * copied from this ModuleEntry. + * + * @param file The new resource content. + * @return A new ModuleEntry. + */ + public default ModuleEntry create(Path file) { + return ModuleEntryFactory.create(this, file); + } + + /** + * Create a ModuleEntry for a resource of the given type. + * + * @param path The resource path. + * @param type The ModuleEntry type. + * @param content The resource content. + * @return A new ModuleEntry. + */ + public static ModuleEntry create(String path, + ModuleEntry.Type type, byte[] content) { + return ModuleEntryFactory.create(path, type, content); + } + + /** + * Create a ModuleEntry for a resource of type {@link Type#CLASS_OR_RESOURCE}. * * @param path The resource path. * @param content The resource content. - * @return A new LinkModuleEntry. + * @return A new ModuleEntry. */ public static ModuleEntry create(String path, byte[] content) { - return create(path, new ByteArrayInputStream(content), - content.length); + return create(path, Type.CLASS_OR_RESOURCE, content); } /** - * Create a LinkModuleEntry for a file that will be located outside a jimage - * file. + * Create a ModuleEntry for a resource of the given type. * - * @param module The module in which this files is located. - * @param path The file path locator (doesn't contain the module name). - * @param type The LinkModuleEntry type. - * @param content The file content. - * @param size The content size. - * @return A new LinkModuleEntry. + * @param path The resource path. + * @param type The ModuleEntry type. + * @param file The resource file. + * @return A new ModuleEntry. */ - public static ModuleEntry create(String module, String path, ModuleEntry.Type type, - InputStream content, long size) { - Objects.requireNonNull(path); - Objects.requireNonNull(content); - return new ModuleEntryImpl(module, path, type, content, size); + public static ModuleEntry create(String path, + ModuleEntry.Type type, Path file) { + return ModuleEntryFactory.create(path, type, file); + } + + /** + * Create a ModuleEntry for a resource of type {@link Type#CLASS_OR_RESOURCE}. + * + * @param path The resource path. + * @param file The resource file. + * @return A new ModuleEntry. + */ + public static ModuleEntry create(String path, Path file) { + return create(path, Type.CLASS_OR_RESOURCE, file); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -57,29 +57,19 @@ SORTER("SORTER"), COMPRESSOR("COMPRESSOR"), METAINFO_ADDER("METAINFO_ADDER"), - VERIFIER("VERIFIER", true), - PROCESSOR("PROCESSOR", true), - PACKAGER("PACKAGER", true); + VERIFIER("VERIFIER"), + PROCESSOR("PROCESSOR"), + PACKAGER("PACKAGER"); private final String name; - private final boolean postProcessor; - - Category(String name, boolean postProcessor) { - this.name = name; - this.postProcessor = postProcessor; - } Category(String name) { - this(name, false); + this.name = name; } public String getName() { return name; } - - public boolean isPostProcessor() { - return postProcessor; - } } /** @@ -209,4 +199,15 @@ */ public default void configure(Map config) { } + + /** + * Visit the content of the modules that are composing the image. + * + * @param in Read only content. + * @param out The pool to fill with content. This pool must contain + * the result of the visit. + * + * @throws PluginException + */ + public void visit(ModulePool in, ModulePool out); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PostProcessorPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PostProcessorPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015, 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 jdk.tools.jlink.plugin; - -import java.util.List; - -/** - * Implement this interface to develop a PostProcessor plugin. - * PostProcessor plugins are called once the image has been generated and is executable. - **/ -public interface PostProcessorPlugin extends Plugin { - - /** - * Post process an image. - * - * @param image The executable image. - * @return The list of arguments to add to launchers (if any). - */ - public List process(ExecutableImage image); -} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015, 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 jdk.tools.jlink.plugin; - - -/** - * Implement this interface to develop a Transformer plugin. - * TransformerPlugin are called during image creation. This kind of plugin aims to - * modify the content of the runtime image. - */ -public interface TransformerPlugin extends Plugin { - /** - * Visit the content of the modules that are composing the image. - * - * @param in Read only content. - * @param out The pool to fill with content. This pool must contain - * the result of the visit. - * - * @throws PluginException - */ - public void visit(ModulePool in, ModulePool out); -} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties Fri Jul 01 16:50:37 2016 -0700 @@ -29,7 +29,7 @@ main.usage=\ Usage: {0} --modulepath --addmods --output \n\ -Possible options include: +\Possible options include: error.prefix=Error: warn.prefix=Warning: @@ -68,7 +68,18 @@ Include your program and the following diagnostic in your report. Thank you. main.extended.help=\ -List of available plugins: +\List of available plugins: + +main.extended.help.footer=\ +\For options requiring a , the value will be a comma\ +\ separated list of elements each using one the following forms:\n\ +\ \n\ +\ glob:\n\ +\ regex:\n\ +\ @ where filename is the name of a file containing patterns to be\ +\ used, one pattern per line\n\ +\n\ + err.unknown.byte.order:unknown byte order {0} err.output.must.be.specified:--output must be specified diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties Fri Jul 01 16:50:37 2016 -0700 @@ -37,15 +37,16 @@ Class optimization. Warning: This plugin is experimental.\n\ An optional can be specified to log applied optimizations. -compress.argument=<0|1|2>[:filter=] +compress.argument=<0|1|2>[:filter=] compress.description=\ Compress all resources in the output image.\n\ Level 0: constant string sharing\n\ Level 1: ZIP\n\ Level 2: both.\n\ -An optional filter can be specified to list the pattern of files to be filtered.\n\ -Use ^ for negation. e.g.: *Exception.class,*Error.class,^/java.base/java/lang/* +An optional filter can be specified to list the pattern of\n\ +files to be included. + compact-cp.argument= @@ -59,15 +60,15 @@ If files to copy are not absolute path, JDK home dir is used.\n\ e.g.: jrt-fs.jar,LICENSE,/home/me/myfile.txt=somewehere/conf.txt -exclude-files.argument= +exclude-files.argument= of files to exclude exclude-files.description=\ -Specify files to exclude. e.g.: *.diz, /java.base/native/client/* +Specify files to exclude. e.g.: **.java,glob:/java.base/native/client/** -exclude-resources.argument= +exclude-resources.argument= resources to exclude exclude-resources.description=\ -Specify resources to exclude. e.g.: *.jcov, */META-INF/* +Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/** generate-jli-classes.argument= @@ -78,10 +79,11 @@ onoff.argument= -order-resources.argument= +order-resources.argument= of paths in priority order. If a @file\n\ +is specified, then each line should be an exact match for the path to be ordered order-resources.description=\ -Order resources. e.g.: */module-info.class,/java.base/java/lang/* +Order resources. e.g.: **/module-info.class,@classlist,/java.base/java/lang/** strip-debug.description=\ Strip debug information from the output image diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Fri Jul 01 16:50:37 2016 -0700 @@ -1085,7 +1085,7 @@ @Override public Class valueType() { return Pattern.class; } - @Override public String valuePattern() { return "pattern"; } + @Override public String valuePattern() { return "regex-pattern"; } } static class PathMatcherConverter implements ValueConverter { @@ -1100,7 +1100,7 @@ @Override public Class valueType() { return PathMatcher.class; } - @Override public String valuePattern() { return "pattern"; } + @Override public String valuePattern() { return "pattern-list"; } } /* Support for @ in jmod help */ @@ -1145,7 +1145,7 @@ String content = super.format(all); StringBuilder builder = new StringBuilder(); - builder.append("\n").append(" Main operation modes:\n "); + builder.append(getMessage("main.opt.mode")).append("\n "); builder.append(getMessage("main.opt.mode.create")).append("\n "); builder.append(getMessage("main.opt.mode.list")).append("\n "); builder.append(getMessage("main.opt.mode.describe")).append("\n "); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties Fri Jul 01 16:50:37 2016 -0700 @@ -28,11 +28,13 @@ use --help for a list of possible options main.usage=\ -Usage: {0} (create|list|describe|hash) +Usage: {0} (create|list|describe|hash) \n\ error.prefix=Error: warn.prefix=Warning: +main.opt.mode=\ +\Main operation modes: main.opt.mode.create=\ \create - Creates a new jmod archive main.opt.mode.list=\ @@ -49,7 +51,9 @@ main.opt.cmds=Location of native commands main.opt.config=Location of user-editable config files main.opt.dry-run=Dry run of hash mode -main.opt.exclude=Exclude files, given as a PATTERN +main.opt.exclude=Exclude files matching the supplied comma separated pattern\ +\ list, each element using one the following forms: ,\ +\ glob: or regex: main.opt.module-version= Module version main.opt.main-class=Main class main.opt.main-class.arg=class-name @@ -61,7 +65,7 @@ main.opt.os-version.arg=os-version main.opt.modulepath=Module path main.opt.hash-modules=Compute and record hashes to tie a packaged module\ -\ with modules matching the given pattern and depending upon it directly\ +\ with modules matching the given and depending upon it directly\ \ or indirectly. The hashes are recorded in the JMOD file being created, or\ \ a JMOD file or modular JAR on the module path specified the jmod hash command. diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/src/jdk.jlink/share/classes/module-info.java --- a/jdk/src/jdk.jlink/share/classes/module-info.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/module-info.java Fri Jul 01 16:50:37 2016 -0700 @@ -29,20 +29,19 @@ requires jdk.internal.opt; requires jdk.jdeps; - uses jdk.tools.jlink.plugin.TransformerPlugin; - uses jdk.tools.jlink.plugin.PostProcessorPlugin; + uses jdk.tools.jlink.plugin.Plugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludePlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.StripNativeCommandsPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.OrderResourcesPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.DefaultCompressPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.OptimizationPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludePlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripNativeCommandsPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.OrderResourcesPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.DefaultCompressPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.OptimizationPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin; } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/ProblemList.txt --- a/jdk/test/ProblemList.txt Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/ProblemList.txt Fri Jul 01 16:50:37 2016 -0700 @@ -167,6 +167,10 @@ java/net/DatagramSocket/SendDatagramToBadAddress.java 7143960 macosx-all +java/net/httpclient/http2/BasicTest.java 8157408 linux-all +java/net/httpclient/http2/ErrorTest.java 8158127 solaris-all,windows-all +java/net/httpclient/http2/TLSConnection.java 8157482 macosx-all + ############################################################################ # jdk_nio @@ -339,9 +343,6 @@ # jdk_time -java/time/test/java/time/TestClock_System.java 8158128 solaris-all - - ############################################################################ # jdk_util diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/TEST.groups --- a/jdk/test/TEST.groups Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/TEST.groups Fri Jul 01 16:50:37 2016 -0700 @@ -27,7 +27,6 @@ tier1 = \ :jdk_lang \ - -java/lang/ProcessHandle/TreeTest.java \ :jdk_util \ -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ @@ -38,7 +37,6 @@ tools/pack200 tier2 = \ - java/lang/ProcessHandle/TreeTest.java \ java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ :jdk_io \ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/lang/ProcessHandle/TreeTest.java --- a/jdk/test/java/lang/ProcessHandle/TreeTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/java/lang/ProcessHandle/TreeTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -50,7 +50,6 @@ * @build jdk.test.lib.Utils * @run testng/othervm TreeTest * @summary Test counting and JavaChild.spawning and counting of Processes. - * @key intermittent * @author Roger Riggs */ public class TreeTest extends ProcessUtil { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016, 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 8154017 + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @summary Shutdown hooks are racing against shutdown sequence, + if System.exit()-calling thread is interrupted + * @run main ShutdownInterruptedMain exec + */ + +import jdk.testlibrary.OutputAnalyzer; +import static jdk.testlibrary.ProcessTools.createJavaProcessBuilder; +import static jdk.testlibrary.ProcessTools.executeProcess; + +public class ShutdownInterruptedMain { + + public static void main(String[] args) throws Exception { + if (args.length > 0) { + ProcessBuilder pb = createJavaProcessBuilder(true, "ShutdownInterruptedMain"); + OutputAnalyzer output = executeProcess(pb); + output.shouldContain("Shutdown Hook"); + output.shouldHaveExitValue(0); + return; + } + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + // Wait for the race to unfold: + try { + Thread.sleep(5_000); + } catch (InterruptedException e) {} + System.out.println("Shutdown Hook"); + System.out.flush(); + } + }); + Thread.currentThread().interrupt(); + System.exit(0); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/lang/String/CompareIC.java --- a/jdk/test/java/lang/String/CompareIC.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/java/lang/String/CompareIC.java Fri Jul 01 16:50:37 2016 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 4124769 + * @bug 4124769 8160312 * @summary Test ignore-case comparison * */ @@ -45,6 +45,10 @@ comparer.testTriplet(test1, test2, test3); test2 = test2.toLowerCase(); comparer.testTriplet(test1, test2, test3); + + // toLowerCase -> non-latin1 + if ("\u00b5".compareToIgnoreCase("X") < 0) + throw new RuntimeException("Comparison failure1"); } private void testTriplet(String one, String two, String three) diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessModeMethodNames.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessModeMethodNames.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 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 + * @run testng VarHandleTestAccessModeMethodNames + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.invoke.VarHandle; +import java.util.stream.Stream; + +import static org.testng.Assert.assertEquals; + +public class VarHandleTestAccessModeMethodNames { + + @DataProvider + public static Object[][] accessModesProvider() { + return Stream.of(VarHandle.AccessMode.values()). + map(am -> new Object[]{am}). + toArray(Object[][]::new); + } + + + @Test(dataProvider = "accessModesProvider") + public void testMethodName(VarHandle.AccessMode am) { + assertEquals(am.methodName(), toMethodName(am.name())); + } + + private static String toMethodName(String name) { + StringBuilder s = new StringBuilder(name.toLowerCase()); + int i; + while ((i = s.indexOf("_")) != -1) { + s.deleteCharAt(i); + s.setCharAt(i, Character.toUpperCase(s.charAt(i))); + } + return s.toString(); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/DecoderTest.java --- a/jdk/test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/DecoderTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/DecoderTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -27,14 +27,20 @@ import java.io.UncheckedIOException; import java.net.ProtocolException; import java.nio.ByteBuffer; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.function.Supplier; import java.util.stream.Collectors; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static sun.net.httpclient.hpack.TestHelper.*; +// +// Tests whose names start with "testX" are the ones captured from real HPACK +// use cases +// public final class DecoderTest { // @@ -138,6 +144,23 @@ // @formatter:on } + @Test + public void example5AllSplits() { + // @formatter:off + testAllSplits( + "8286 8441 0f77 7777 2e65 7861 6d70 6c65\n" + + "2e63 6f6d", + + "[ 1] (s = 57) :authority: www.example.com\n" + + " Table size: 57", + + ":method: GET\n" + + ":scheme: http\n" + + ":path: /\n" + + ":authority: www.example.com"); + // @formatter:on + } + // // http://tools.ietf.org/html/rfc7541#appendix-C.4 // @@ -334,6 +357,45 @@ // @formatter:on } + @Test + public void testX1() { + // Supplier of a decoder with a particular state + Supplier s = () -> { + Decoder d = new Decoder(4096); + // @formatter:off + test(d, "88 76 92 ca 54 a7 d7 f4 fa ec af ed 6d da 61 d7 bb 1e ad ff" + + "df 61 97 c3 61 be 94 13 4a 65 b6 a5 04 00 b8 a0 5a b8 db 77" + + "1b 71 4c 5a 37 ff 0f 0d 84 08 00 00 03", + + "[ 1] (s = 65) date: Fri, 24 Jun 2016 14:55:56 GMT\n" + + "[ 2] (s = 59) server: Jetty(9.3.z-SNAPSHOT)\n" + + " Table size: 124", + + ":status: 200\n" + + "server: Jetty(9.3.z-SNAPSHOT)\n" + + "date: Fri, 24 Jun 2016 14:55:56 GMT\n" + + "content-length: 100000" + ); + // @formatter:on + return d; + }; + // For all splits of the following data fed to the supplied decoder we + // must get what's expected + // @formatter:off + testAllSplits(s, + "88 bf be 0f 0d 84 08 00 00 03", + + "[ 1] (s = 65) date: Fri, 24 Jun 2016 14:55:56 GMT\n" + + "[ 2] (s = 59) server: Jetty(9.3.z-SNAPSHOT)\n" + + " Table size: 124", + + ":status: 200\n" + + "server: Jetty(9.3.z-SNAPSHOT)\n" + + "date: Fri, 24 Jun 2016 14:55:56 GMT\n" + + "content-length: 100000"); + // @formatter:on + } + // // This test is missing in the spec // @@ -567,6 +629,38 @@ test(new Decoder(4096), hexdump, headerTable, headerList); } + private static void testAllSplits(String hexdump, + String expectedHeaderTable, + String expectedHeaderList) { + testAllSplits(() -> new Decoder(256), hexdump, expectedHeaderTable, expectedHeaderList); + } + + private static void testAllSplits(Supplier supplier, String hexdump, + String expectedHeaderTable, String expectedHeaderList) { + ByteBuffer source = SpecHelper.toBytes(hexdump); + + BuffersTestingKit.forEachSplit(source, iterable -> { + List actual = new LinkedList<>(); + Iterator i = iterable.iterator(); + if (!i.hasNext()) { + return; + } + Decoder d = supplier.get(); + do { + ByteBuffer n = i.next(); + d.decode(n, !i.hasNext(), (name, value) -> { + if (value == null) { + actual.add(name.toString()); + } else { + actual.add(name + ": " + value); + } + }); + } while (i.hasNext()); + assertEquals(d.getTable().getStateString(), expectedHeaderTable); + assertEquals(actual.stream().collect(Collectors.joining("\n")), expectedHeaderList); + }); + } + // // Sometimes we need to keep the same decoder along several runs, // as it models the same connection diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/EncoderTest.java --- a/jdk/test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/EncoderTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/EncoderTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,17 +24,23 @@ import org.testng.annotations.Test; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; +import java.util.function.Consumer; import java.util.function.Function; +import static sun.net.httpclient.hpack.BuffersTestingKit.concat; +import static sun.net.httpclient.hpack.BuffersTestingKit.forEachSplit; +import static sun.net.httpclient.hpack.SpecHelper.toHexdump; +import static sun.net.httpclient.hpack.TestHelper.assertVoidThrows; import static java.util.Arrays.asList; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import static sun.net.httpclient.hpack.SpecHelper.toHexdump; -import static sun.net.httpclient.hpack.TestHelper.assertVoidThrows; // TODO: map textual representation of commands from the spec to actual // calls to encoder (actually, this is a good idea for decoder as well) @@ -198,6 +204,61 @@ // @formatter:on } + @Test + public void example5AllSplits() { + + List> actions = new LinkedList<>(); + actions.add(e -> e.indexed(2)); + actions.add(e -> e.indexed(6)); + actions.add(e -> e.indexed(4)); + actions.add(e -> e.literalWithIndexing(1, "www.example.com", false)); + + encodeAllSplits( + actions, + + "8286 8441 0f77 7777 2e65 7861 6d70 6c65\n" + + "2e63 6f6d", + + "[ 1] (s = 57) :authority: www.example.com\n" + + " Table size: 57"); + } + + private static void encodeAllSplits(Iterable> consumers, + String expectedHexdump, + String expectedTableState) { + ByteBuffer buffer = SpecHelper.toBytes(expectedHexdump); + erase(buffer); // Zeroed buffer of size needed to hold the encoding + forEachSplit(buffer, iterable -> { + List copy = new LinkedList<>(); + iterable.forEach(b -> copy.add(ByteBuffer.allocate(b.remaining()))); + Iterator output = copy.iterator(); + if (!output.hasNext()) { + throw new IllegalStateException("No buffers to encode to"); + } + Encoder e = newCustomEncoder(256); // FIXME: pull up (as a parameter) + drainInitialUpdate(e); + boolean encoded; + ByteBuffer b = output.next(); + for (Consumer c : consumers) { + c.accept(e); + do { + encoded = e.encode(b); + if (!encoded) { + if (output.hasNext()) { + b = output.next(); + } else { + throw new IllegalStateException("No room for encoding"); + } + } + } + while (!encoded); + } + copy.forEach(Buffer::flip); + ByteBuffer data = concat(copy); + test(e, data, expectedHexdump, expectedTableState); + }); + } + // // http://tools.ietf.org/html/rfc7541#appendix-C.4 // @@ -620,4 +681,12 @@ b.flip(); } while (!done); } + + private static void erase(ByteBuffer buffer) { + buffer.clear(); + while (buffer.hasRemaining()) { + buffer.put((byte) 0); + } + buffer.clear(); + } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/nio/file/WatchService/DeleteInterference.java --- a/jdk/test/java/nio/file/WatchService/DeleteInterference.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/java/nio/file/WatchService/DeleteInterference.java Fri Jul 01 16:50:37 2016 -0700 @@ -49,7 +49,7 @@ * directory. */ public static void main(String[] args) throws Exception { - Path dir = Files.createTempDirectory("work"); + Path dir = Files.createTempDirectory("DeleteInterference"); ExecutorService pool = Executors.newCachedThreadPool(); try { Future task1 = pool.submit(() -> openAndCloseWatcher(dir)); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/nio/file/WatchService/LotsOfCancels.java --- a/jdk/test/java/nio/file/WatchService/LotsOfCancels.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/java/nio/file/WatchService/LotsOfCancels.java Fri Jul 01 16:50:37 2016 -0700 @@ -50,7 +50,7 @@ // one to bash on cancel, the other to poll the events ExecutorService pool = Executors.newCachedThreadPool(); try { - Path top = Files.createTempDirectory("work"); + Path top = Files.createTempDirectory("LotsOfCancels"); top.toFile().deleteOnExit(); for (int i=1; i<=16; i++) { Path dir = Files.createDirectory(top.resolve("dir-" + i)); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/util/logging/FileHandlerMaxLocksTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2016, 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 8153955 + * @summary test the FileHandler's new property + * "java.util.logging.FileHandler.maxLocks" which will be present in + * "logging.properties" file with default value of 100. This property can be + * overriden by specifying this property in the custom config file. + * @library /lib/testlibrary + * @build jdk.testlibrary.FileUtils + * @author rpatil + * @run main/othervm FileHandlerMaxLocksTest + */ +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.FileHandler; +import jdk.testlibrary.FileUtils; + +public class FileHandlerMaxLocksTest { + + private static final String LOGGER_DIR = "logger-dir"; + private static final String MAX_LOCK_PROPERTY = "java.util.logging.FileHandler.maxLocks = 200"; + private static final String CONFIG_FILE_NAME = "logging.properties"; + + public static void main(String[] args) throws Exception { + File loggerDir = createLoggerDir(); + String configFilePath = loggerDir.getPath() + File.separator + CONFIG_FILE_NAME; + File configFile = new File(configFilePath); + createFile(configFile, false); + System.setProperty("java.util.logging.config.file", configFilePath); + List fileHandlers = new ArrayList<>(); + try (FileWriter writer = new FileWriter(configFile)) { + writer.write(MAX_LOCK_PROPERTY); + writer.flush(); + // 200 raises the default limit of 100, we try 102 times + for (int i = 0; i < 102; i++) { + fileHandlers.add(new FileHandler(loggerDir.getPath() + File.separator + "test_%u.log")); + } + } catch (IOException ie) { + throw new RuntimeException("Test Failed: " + ie.getMessage()); + } finally { + for (FileHandler fh : fileHandlers) { + fh.close(); + } + FileUtils.deleteFileTreeWithRetry(Paths.get(loggerDir.getPath())); + } + } + + /** + * Create a writable directory in user directory for the test + * + * @return writable directory created that needs to be deleted when done + * @throws RuntimeException + */ + private static File createLoggerDir() throws RuntimeException { + String userDir = System.getProperty("user.dir", "."); + File loggerDir = new File(userDir, LOGGER_DIR); + if (!createFile(loggerDir, true)) { + throw new RuntimeException("Test failed: unable to create" + + " writable working directory " + + loggerDir.getAbsolutePath()); + } + // System.out.println("Created Logger Directory: " + loggerDir.getPath()); + return loggerDir; + } + + /** + * @param newFile File to be created + * @param makeDirectory is File to be created is directory + * @return true if file already exists or creation succeeded + */ + private static boolean createFile(File newFile, boolean makeDirectory) { + if (newFile.exists()) { + return true; + } + if (makeDirectory) { + return newFile.mkdir(); + } else { + try { + return newFile.createNewFile(); + } catch (IOException ie) { + System.err.println("Not able to create file: " + newFile + + ", IOException: " + ie.getMessage()); + return false; + } + } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/java/util/zip/ZipFile/ReadZip.java --- a/jdk/test/java/util/zip/ZipFile/ReadZip.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/java/util/zip/ZipFile/ReadZip.java Fri Jul 01 16:50:37 2016 -0700 @@ -22,7 +22,7 @@ */ /* @test - @bug 4241361 4842702 4985614 6646605 5032358 6923692 + @bug 4241361 4842702 4985614 6646605 5032358 6923692 6233323 8144977 @summary Make sure we can read a zip file. @key randomness */ @@ -105,6 +105,40 @@ newZip.delete(); } + // Read directory entry + try { + try (FileOutputStream fos = new FileOutputStream(newZip); + ZipOutputStream zos = new ZipOutputStream(fos)) + { + ZipEntry ze = new ZipEntry("directory/"); + zos.putNextEntry(ze); + zos.closeEntry(); + } + try (ZipFile zf = new ZipFile(newZip)) { + ZipEntry ze = zf.getEntry("directory/"); + if (ze == null || !ze.isDirectory()) + throw new RuntimeException("read entry \"directory/\" failed"); + try (InputStream is = zf.getInputStream(ze)) { + is.available(); + } catch (Exception x) { + x.printStackTrace(); + } + + ze = zf.getEntry("directory"); + if (ze == null || !ze.isDirectory()) + throw new RuntimeException("read entry \"directory\" failed"); + try (InputStream is = zf.getInputStream(ze)) { + is.available(); + } catch (Exception x) { + x.printStackTrace(); + } + } + } finally { + newZip.delete(); + } + + + // Throw a FNF exception when read a non-existing zip file try { unreached (new ZipFile( new File(System.getProperty("test.src", "."), diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java --- a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java Fri Jul 01 16:50:37 2016 -0700 @@ -510,25 +510,27 @@ sslc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); SSLServerSocketFactory sslssf = sslc.getServerSocketFactory(); - SSLServerSocket sslServerSocket = - (SSLServerSocket) sslssf.createServerSocket(serverPort); - serverPort = sslServerSocket.getLocalPort(); + try (SSLServerSocket sslServerSocket = + (SSLServerSocket) sslssf.createServerSocket(serverPort)) { - /* - * Signal Client, we're ready for his connect. - */ - serverReady = true; + serverPort = sslServerSocket.getLocalPort(); + + /* + * Signal Client, we're ready for his connect. + */ + serverReady = true; - try (SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream()) { - int numberIn = sslIS.read(); - int numberSent = 85; - log("Server received number: " + numberIn); - sslOS.write(numberSent); - sslOS.flush(); - log("Server sent number: " + numberSent); + try (SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); + InputStream sslIS = sslSocket.getInputStream(); + OutputStream sslOS = sslSocket.getOutputStream()) { + int numberIn = sslIS.read(); + int numberSent = 85; + log("Server received number: " + numberIn); + sslOS.write(numberSent); + sslOS.flush(); + log("Server sent number: " + numberSent); + } } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, 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.security.Permission; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.Map; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBContextFactory; +import javax.xml.bind.JAXBException; + +/** + * @test + * @bug 8150173 + * @summary Verifies that a factory which inherit its createContext method + * from an abstract subclass of JAXBContextFactory can be instantiated. + * @compile -addmods java.xml.bind JAXBContextWithAbstractFactory.java + * @run main/othervm -addmods java.xml.bind JAXBContextWithAbstractFactory + */ +public class JAXBContextWithAbstractFactory { + private static JAXBContext tmp; + + public static abstract class FactoryBase implements JAXBContextFactory { + @Override + public JAXBContext createContext(Class[] classesToBeBound, + Map properties) throws JAXBException { + return tmp; + } + + @Override + public JAXBContext createContext(String contextPath, + ClassLoader classLoader, Map properties) + throws JAXBException { + return tmp; + } + } + + public static class Factory extends FactoryBase {} + + // test both without and then with a security manager as the code path + // can be different when System.getSecurityManager() != null; + public static void main(String[] args) throws JAXBException { + System.out.println("\nWithout security manager\n"); + test(); + + System.out.println("\nWith security manager\n"); + Policy.setPolicy(new Policy() { + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + return true; // allow all + } + }); + System.setSecurityManager(new SecurityManager()); + test(); + } + + public static void test() throws JAXBException { + System.clearProperty(JAXBContext.JAXB_CONTEXT_FACTORY); + System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = " + + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY, "")); + System.out.println("Calling " + + "JAXBContext.newInstance(JAXBContextWithAbstractFactory.class)"); + tmp = JAXBContext.newInstance(JAXBContextWithAbstractFactory.class); + System.setProperty(JAXBContext.JAXB_CONTEXT_FACTORY, + "JAXBContextWithAbstractFactory$Factory"); + System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = " + + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY)); + System.out.println("Calling " + + "JAXBContext.newInstance(JAXBContextWithAbstractFactory.class)"); + JAXBContext ctxt = JAXBContext.newInstance(JAXBContextWithAbstractFactory.class); + System.out.println("Successfully loaded JAXBcontext: " + + System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName()); + if (ctxt != tmp) { + throw new RuntimeException("Wrong JAXBContext instance" + + "\n\texpected: " + + System.identityHashCode(tmp) + "@" + tmp.getClass().getName() + + "\n\tactual: " + + System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName()); + } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2016, 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.security.Permission; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.Map; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.Validator; + +/** + * @test + * @bug 8150173 + * @summary Verifies that a JAXBContext can be created with a legacy + * factory class that has static createContext methods. + * @compile -addmods java.xml.bind JAXBContextWithLegacyFactory.java + * @run main/othervm -addmods java.xml.bind JAXBContextWithLegacyFactory + */ +public class JAXBContextWithLegacyFactory { + private static JAXBContext tmp; + + public static class JAXBContextImpl extends JAXBContext { + public final Class creator; + JAXBContextImpl(Class creator) { + this.creator = creator; + } + + @Override + public Unmarshaller createUnmarshaller() throws JAXBException { + return tmp.createUnmarshaller(); + } + + @Override + public Marshaller createMarshaller() throws JAXBException { + return tmp.createMarshaller(); + } + + @Override + public Validator createValidator() throws JAXBException { + return tmp.createValidator(); + } + } + + public static abstract class FactoryBase { + public static JAXBContext createContext(Class[] classesToBeBound, + Map properties) throws JAXBException { + return new JAXBContextImpl(FactoryBase.class); + } + + public static JAXBContext createContext(String contextPath, + ClassLoader classLoader, Map properties) + throws JAXBException { + return new JAXBContextImpl(FactoryBase.class); + } + } + + public static class Factory1 extends FactoryBase {} + + public static class Factory2 extends FactoryBase { + public static JAXBContext createContext(Class[] classesToBeBound, + Map properties) throws JAXBException { + return new JAXBContextImpl(Factory2.class); + } + + public static JAXBContext createContext(String contextPath, + ClassLoader classLoader, Map properties) + throws JAXBException { + return new JAXBContextImpl(Factory2.class); + } + } + + // test both without and then with a security manager as the code path + // can be different when System.getSecurityManager() != null; + public static void main(String[] args) throws JAXBException { + System.out.println("\nWithout security manager\n"); + test(FactoryBase.class, FactoryBase.class); + test(Factory1.class, FactoryBase.class); + test(Factory2.class, Factory2.class); + + System.out.println("\nWith security manager\n"); + Policy.setPolicy(new Policy() { + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + return true; // allow all + } + }); + System.setSecurityManager(new SecurityManager()); + test(FactoryBase.class, FactoryBase.class); + test(Factory1.class, FactoryBase.class); + test(Factory2.class, Factory2.class); + } + + public static void test(Class factoryClass, Class creatorClass) throws JAXBException { + System.clearProperty(JAXBContext.JAXB_CONTEXT_FACTORY); + System.out.println("** Testing with Factory Class: " + factoryClass.getName()); + System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = " + + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY, "")); + System.out.println("Calling " + + "JAXBContext.newInstance(JAXBContextWithLegacyFactory.class)"); + tmp = JAXBContext.newInstance(JAXBContextWithLegacyFactory.class); + System.setProperty(JAXBContext.JAXB_CONTEXT_FACTORY, + factoryClass.getName()); + System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = " + + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY)); + System.out.println("Calling " + + "JAXBContext.newInstance(JAXBContextWithLegacyFactory.class)"); + JAXBContext ctxt = JAXBContext.newInstance(JAXBContextWithLegacyFactory.class); + System.out.println("Successfully loaded JAXBcontext: " + + System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName()); + if (ctxt.getClass() != JAXBContextImpl.class) { + throw new RuntimeException("Wrong JAXBContext class" + + "\n\texpected: " + + System.identityHashCode(tmp) + "@" + JAXBContextImpl.class.getName() + + "\n\tactual: " + + System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName()); + } + if (((JAXBContextImpl)ctxt).creator != creatorClass) { + throw new RuntimeException("Wrong Factory class" + + "\n\texpected: " + + System.identityHashCode(tmp) + "@" + creatorClass.getName() + + "\n\tactual: " + + System.identityHashCode(ctxt) + "@" + ((JAXBContextImpl)ctxt).creator.getName()); + } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2016, 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.security.Permission; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.Map; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBContextFactory; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.Validator; + +/** + * @test + * @bug 8150173 + * @summary Verifies that a factory which inherit its createContext method + * from a concrete subclass of JAXBContextFactory is be instantiated. + * @compile -addmods java.xml.bind JAXBContextWithSubclassedFactory.java + * @run main/othervm -addmods java.xml.bind JAXBContextWithSubclassedFactory + */ +public class JAXBContextWithSubclassedFactory { + static JAXBContext tmp; + + public static class JAXBContextImpl extends JAXBContext { + public final Class creator; + JAXBContextImpl(Class creator) { + this.creator = creator; + } + + @Override + public Unmarshaller createUnmarshaller() throws JAXBException { + return tmp.createUnmarshaller(); + } + + @Override + public Marshaller createMarshaller() throws JAXBException { + return tmp.createMarshaller(); + } + + @Override + public Validator createValidator() throws JAXBException { + return tmp.createValidator(); + } + } + + public static class FactoryBase implements JAXBContextFactory { + + @Override + public JAXBContext createContext(Class[] classesToBeBound, + Map properties) throws JAXBException { + return new JAXBContextImpl(this.getClass()); + } + + @Override + public JAXBContext createContext(String contextPath, + ClassLoader classLoader, Map properties) + throws JAXBException { + return new JAXBContextImpl(this.getClass()); + } + } + + public static class NonFactoryBase { + + public JAXBContext createContext(Class[] classesToBeBound, + Map properties) throws JAXBException { + return new JAXBContextImpl(this.getClass()); + } + + public JAXBContext createContext(String contextPath, + ClassLoader classLoader, Map properties) + throws JAXBException { + return new JAXBContextImpl(this.getClass()); + } + } + + public static class Factory1 extends FactoryBase {} + public static class Factory2 extends NonFactoryBase implements JAXBContextFactory {} + + // test both without and then with a security manager as the code path + // can be different when System.getSecurityManager() != null; + public static void main(String[] args) throws JAXBException { + System.out.println("\nWithout security manager\n"); + test(FactoryBase.class); + test(Factory1.class); + test(Factory2.class); + + System.out.println("\nWith security manager\n"); + Policy.setPolicy(new Policy() { + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + return true; // allow all + } + }); + System.setSecurityManager(new SecurityManager()); + test(FactoryBase.class); + test(Factory1.class); + test(Factory2.class); + } + + public static void test(Class factoryClass) throws JAXBException { + System.clearProperty(JAXBContext.JAXB_CONTEXT_FACTORY); + System.out.println("** Testing with Factory Class: " + factoryClass.getName()); + System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = " + + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY, "")); + System.out.println("Calling " + + "JAXBContext.newInstance(JAXBContextWithSubclassedFactory.class)"); + tmp = JAXBContext.newInstance(JAXBContextWithSubclassedFactory.class); + System.setProperty(JAXBContext.JAXB_CONTEXT_FACTORY, + factoryClass.getName()); + System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = " + + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY)); + System.out.println("Calling " + + "JAXBContext.newInstance(JAXBContextWithSubclassedFactory.class)"); + JAXBContext ctxt = JAXBContext.newInstance(JAXBContextWithSubclassedFactory.class); + System.out.println("Successfully loaded JAXBcontext: " + + System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName()); + if (ctxt.getClass() != JAXBContextImpl.class) { + throw new RuntimeException("Wrong JAXBContext class" + + "\n\texpected: " + + System.identityHashCode(tmp) + "@" + JAXBContextImpl.class.getName() + + "\n\tactual: " + + System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName()); + } + if (((JAXBContextImpl)ctxt).creator != factoryClass) { + throw new RuntimeException("Wrong Factory class" + + "\n\texpected: " + + System.identityHashCode(tmp) + "@" + factoryClass.getName() + + "\n\tactual: " + + System.identityHashCode(ctxt) + "@" + ((JAXBContextImpl)ctxt).creator.getName()); + } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/jdk/internal/jrtfs/Basic.java --- a/jdk/test/jdk/internal/jrtfs/Basic.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/jdk/internal/jrtfs/Basic.java Fri Jul 01 16:50:37 2016 -0700 @@ -715,5 +715,14 @@ assertTrue(childCount != 0); assertEquals(dirPrefixOkayCount, childCount); } + + @Test + public void objectClassSizeTest() throws Exception { + String path = "/modules/java.base/java/lang/Object.class"; + FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/")); + Path classFile = fs.getPath(path); + + assertTrue(Files.size(classFile) > 0L); + } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/sun/security/tools/jarsigner/TimestampCheck.java --- a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java Fri Jul 01 16:50:37 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -39,6 +39,7 @@ import java.util.Calendar; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.Locale; import sun.security.pkcs.ContentInfo; import sun.security.pkcs.PKCS7; @@ -371,7 +372,7 @@ static void jarsigner(String cmd, int path, boolean expected) throws Exception { System.err.println("Test " + path); - Process p = Runtime.getRuntime().exec(String.format(cmd, path, path)); + Process p = Runtime.getRuntime().exec(String.format(Locale.ROOT,cmd, path, path)); BufferedReader reader = new BufferedReader( new InputStreamReader(p.getErrorStream())); while (true) { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/sun/security/tools/keytool/standard.sh --- a/jdk/test/sun/security/tools/keytool/standard.sh Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/sun/security/tools/keytool/standard.sh Fri Jul 01 16:50:37 2016 -0700 @@ -25,7 +25,8 @@ # @summary (almost) all keytool behaviors # @author Weijun Wang # @run shell/timeout=600 standard.sh -# +# @key intermittent + # This test is always excecuted. # # set a few environment variables so that the shell-script can run stand-alone diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/sun/util/locale/provider/Bug8038436.java --- a/jdk/test/sun/util/locale/provider/Bug8038436.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/sun/util/locale/provider/Bug8038436.java Fri Jul 01 16:50:37 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,24 +23,25 @@ /* * @test - * @bug 8038436 + * @bug 8038436 8158504 * @summary Test for changes in 8038436 * @modules java.base/sun.util.locale.provider * java.base/sun.util.spi * @compile -XDignore.symbol.file Bug8038436.java - * @run main/othervm Bug8038436 -Djava.ext.dirs=foo security - * @run main/othervm Bug8038436 -Djava.locale.providers=JRE availlocs + * @run main/othervm -limitmods java.base Bug8038436 security + * @run main/othervm -Djava.locale.providers=COMPAT Bug8038436 availlocs */ import java.security.*; -import java.text.*; import java.util.*; import java.util.stream.*; import sun.util.locale.provider.*; public class Bug8038436 { public static void main(String[] args) { - switch (args[1]) { + + switch (args[0]) { + case "security": securityTests(); break; @@ -50,6 +51,7 @@ default: throw new RuntimeException("no test was specified."); } + } private static void securityTests() { @@ -67,12 +69,14 @@ /* * Check only English/ROOT locales are returned if the jdk.localedata - * module is not installed (implied by "java.ext.dirs" set to "foo"). + * module is not loaded (implied by "-limitmods java.base"). */ - if (Arrays.asList(Locale.getAvailableLocales()) - .stream() - .anyMatch(l -> l != Locale.ROOT && l.getLanguage() != "en")) { - throw new RuntimeException("non English locale(s) included in available locales"); + List nonEnglishLocales= (Arrays.stream(Locale.getAvailableLocales()) + .filter(l -> (l != Locale.ROOT && !(l.getLanguage() == "en" && (l.getCountry() == "US" || l.getCountry() == "" )))) + .collect(Collectors.toList())); + + if (!nonEnglishLocales.isEmpty()) { + throw new RuntimeException("non English locale(s)" + nonEnglishLocales + " included in available locales"); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jar/compat/CLICompatibility.java --- a/jdk/test/tools/jar/compat/CLICompatibility.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jar/compat/CLICompatibility.java Fri Jul 01 16:50:37 2016 -0700 @@ -415,14 +415,14 @@ jar("-h") .assertSuccess() .resultChecker(r -> - assertTrue(r.output.startsWith("Usage: jar [OPTION...] [-C dir] files"), + assertTrue(r.output.startsWith("Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files]"), "Failed, got [" + r.output + "]") ); jar("--help") .assertSuccess() .resultChecker(r -> - assertTrue(r.output.startsWith("Usage: jar [OPTION...] [-C dir] files"), + assertTrue(r.output.startsWith("Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files]"), "Failed, got [" + r.output + "]") ); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jar/multiRelease/Basic.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/jar/multiRelease/Basic.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2016, 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 + * @library /test/lib/share/classes + * @modules java.base/jdk.internal.misc + * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Platform + * @run testng Basic + */ + +import static org.testng.Assert.*; + +import org.testng.annotations.*; + +import java.io.*; +import java.nio.file.*; +import java.nio.file.attribute.*; +import java.util.*; +import java.util.function.Consumer; +import java.util.jar.*; +import java.util.stream.Stream; +import java.util.zip.*; + +import jdk.test.lib.JDKToolFinder; + +import static java.lang.String.format; +import static java.lang.System.out; + +public class Basic { + private final String src = System.getProperty("test.src", "."); + private final String usr = System.getProperty("user.dir", "."); + + @Test + // create a regular, non-multi-release jar + public void test00() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, false); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"} + ); + + compare(jarfile, names); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // create a multi-release jar + public void test01() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".", + "--release", "10", "-C", classes.resolve("v10").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v9", "version", "Version.class"}, + + "META-INF/versions/10/version/Version.class", + new String[] {"v10", "version", "Version.class"} + ); + + compare(jarfile, names); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // update a regular jar to a multi-release jar + public void test02() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, false); + + jar("uf", jarfile, "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v9", "version", "Version.class"} + ); + + compare(jarfile, names); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // replace a base entry and a versioned entry + public void test03() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v9", "version", "Version.class"} + ); + + compare(jarfile, names); + + // write the v9 version/Version.class entry in base and the v10 + // version/Version.class entry in versions/9 section + jar("uf", jarfile, "-C", classes.resolve("v9").toString(), "version", + "--release", "9", "-C", classes.resolve("v10").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"v9", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v10", "version", "Version.class"} + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + /* + * Test Infrastructure + */ + private void compile(String test) throws IOException { + Path classes = Paths.get(usr, "classes", "base"); + Files.createDirectories(classes); + Path source = Paths.get(src, "data", test, "base", "version"); + javac(classes, source.resolve("Main.java"), source.resolve("Version.java")); + + classes = Paths.get(usr, "classes", "v9"); + Files.createDirectories(classes); + source = Paths.get(src, "data", test, "v9", "version"); + javac(classes, source.resolve("Version.java")); + + classes = Paths.get(usr, "classes", "v10"); + Files.createDirectories(classes); + source = Paths.get(src, "data", test, "v10", "version"); + javac(classes, source.resolve("Version.java")); + } + + private void checkMultiRelease(String jarFile, boolean expected) throws IOException { + try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ, + JarFile.Release.RUNTIME)) { + assertEquals(jf.isMultiRelease(), expected); + } + } + + // compares the bytes found in the jar entries with the bytes found in the + // corresponding data files used to create the entries + private void compare(String jarfile, Map names) throws IOException { + try (JarFile jf = new JarFile(jarfile)) { + for (String name : names.keySet()) { + Path path = Paths.get("classes", names.get(name)); + byte[] b1 = Files.readAllBytes(path); + byte[] b2; + JarEntry je = jf.getJarEntry(name); + try (InputStream is = jf.getInputStream(je)) { + b2 = is.readAllBytes(); + } + assertEquals(b1,b2); + } + } + } + + private void delete(String name) throws IOException { + Files.delete(Paths.get(usr, name)); + } + + private void deleteDir(Path dir) throws IOException { + Files.walkFileTree(dir, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } + + /* + * The following methods were taken from modular jar and other jar tests + */ + + void javac(Path dest, Path... sourceFiles) throws IOException { + String javac = JDKToolFinder.getJDKTool("javac"); + + List commands = new ArrayList<>(); + commands.add(javac); + commands.add("-d"); + commands.add(dest.toString()); + Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x)); + + quickFail(run(new ProcessBuilder(commands))); + } + + Result jarWithStdin(File stdinSource, String... args) { + String jar = JDKToolFinder.getJDKTool("jar"); + List commands = new ArrayList<>(); + commands.add(jar); + Stream.of(args).forEach(x -> commands.add(x)); + ProcessBuilder p = new ProcessBuilder(commands); + if (stdinSource != null) + p.redirectInput(stdinSource); + return run(p); + } + + Result jar(String... args) { + return jarWithStdin(null, args); + } + + void quickFail(Result r) { + if (r.ec != 0) + throw new RuntimeException(r.output); + } + + Result run(ProcessBuilder pb) { + Process p; + out.printf("Running: %s%n", pb.command()); + try { + p = pb.start(); + } catch (IOException e) { + throw new RuntimeException( + format("Couldn't start process '%s'", pb.command()), e); + } + + String output; + try { + output = toString(p.getInputStream(), p.getErrorStream()); + } catch (IOException e) { + throw new RuntimeException( + format("Couldn't read process output '%s'", pb.command()), e); + } + + try { + p.waitFor(); + } catch (InterruptedException e) { + throw new RuntimeException( + format("Process hasn't finished '%s'", pb.command()), e); + } + return new Result(p.exitValue(), output); + } + + String toString(InputStream in1, InputStream in2) throws IOException { + try (ByteArrayOutputStream dst = new ByteArrayOutputStream(); + InputStream concatenated = new SequenceInputStream(in1, in2)) { + concatenated.transferTo(dst); + return new String(dst.toByteArray(), "UTF-8"); + } + } + + static class Result { + final int ec; + final String output; + + private Result(int ec, String output) { + this.ec = ec; + this.output = output; + } + Result assertSuccess() { + assertTrue(ec == 0, format("ec: %d, output: %s", ec, output)); + return this; + } + Result assertFailure() { + assertTrue(ec != 0, format("ec: %d, output: %s", ec, output)); + return this; + } + Result resultChecker(Consumer r) { r.accept(this); return this; } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jar/multiRelease/data/test01/base/version/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/jar/multiRelease/data/test01/base/version/Main.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,8 @@ +package version; + +public class Main { + public static void main(String[] args) { + Version v = new Version(); + System.out.println("I am running on version " + v.getVersion()); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jar/multiRelease/data/test01/base/version/Version.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/jar/multiRelease/data/test01/base/version/Version.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,13 @@ +package version; + +public class Version { + public int getVersion() { + return 8; + } + + protected void doNothing() { + } + + private void reallyDoNothing() { + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jar/multiRelease/data/test01/v10/version/Version.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/jar/multiRelease/data/test01/v10/version/Version.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,13 @@ +package version; + +public class Version { + public int getVersion() { + return 10; + } + + protected void doNothing() { + } + + private void someName() { + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jar/multiRelease/data/test01/v9/version/Version.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/jar/multiRelease/data/test01/v9/version/Version.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,13 @@ +package version; + +public class Version { + public int getVersion() { + return 9; + } + + protected void doNothing() { + } + + private void anyName() { + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/DefaultProviderTest.java --- a/jdk/test/tools/jlink/DefaultProviderTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/DefaultProviderTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -33,7 +33,6 @@ import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; import tests.Helper; /* @@ -60,7 +59,7 @@ expectedOptions.put("option2", "value2"); } - private static class Custom implements TransformerPlugin { + private static class Custom implements Plugin { private boolean enabled = true; @Override diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/ImageFileCreatorTest.java --- a/jdk/test/tools/jlink/ImageFileCreatorTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/ImageFileCreatorTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -37,7 +37,7 @@ import jdk.tools.jlink.internal.Archive; import jdk.tools.jlink.internal.ImageFileCreator; import jdk.tools.jlink.internal.ImagePluginStack; -import jdk.tools.jlink.plugin.ExecutableImage; +import jdk.tools.jlink.internal.ExecutableImage; import jdk.tools.jlink.builder.ImageBuilder; import jdk.tools.jlink.plugin.ModulePool; @@ -220,7 +220,7 @@ }; ImagePluginStack stack = new ImagePluginStack(noopBuilder, Collections.emptyList(), - null, Collections.emptyList()); + null); ImageFileCreator.create(archives, ByteOrder.nativeOrder(), stack); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/ImageFilePoolTest.java --- a/jdk/test/tools/jlink/ImageFilePoolTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/ImageFilePoolTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -33,7 +33,7 @@ import java.io.ByteArrayInputStream; import java.util.Optional; import java.util.function.Function; -import jdk.tools.jlink.internal.ModuleEntryImpl; +import jdk.tools.jlink.internal.ModuleEntryFactory; import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; @@ -54,7 +54,7 @@ ModulePool input = new ModulePoolImpl(); for (int i = 0; i < 1000; ++i) { String module = "module" + (i / 100); - input.add(new InMemoryImageFile(module, "/" + module + "/java/class" + i, + input.add(newInMemoryImageFile("/" + module + "/java/class" + i, ModuleEntry.Type.CONFIG, "class" + i)); } if (input.getEntryCount() != 1000) { @@ -94,11 +94,11 @@ switch (index) { case 0: ++amountAfter; - return new InMemoryImageFile(file.getModule(), file.getPath() + SUFFIX, + return newInMemoryImageFile(file.getPath() + SUFFIX, file.getType(), file.getPath()); case 1: ++amountAfter; - return new InMemoryImageFile(file.getModule(), file.getPath(), + return newInMemoryImageFile(file.getPath(), file.getType(), file.getPath()); } return null; @@ -130,28 +130,27 @@ if (input.findEntry("unknown").isPresent()) { throw new AssertionError("ImageFileModulePool does not return null for unknown file"); } - if (input.contains(new InMemoryImageFile("", "unknown", ModuleEntry.Type.CONFIG, "unknown"))) { - throw new AssertionError("'contain' returns true for unknown file"); + if (input.contains(newInMemoryImageFile("/unknown/foo", ModuleEntry.Type.CONFIG, "unknown"))) { + throw new AssertionError("'contain' returns true for /unknown/foo file"); } - input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, "")); + input.add(newInMemoryImageFile("/aaa/bbb", ModuleEntry.Type.CONFIG, "")); try { - input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, "")); + input.add(newInMemoryImageFile("/aaa/bbb", ModuleEntry.Type.CONFIG, "")); throw new AssertionError("Exception expected"); } catch (Exception e) { // expected } input.setReadOnly(); try { - input.add(new InMemoryImageFile("", "/aaa/ccc", ModuleEntry.Type.CONFIG, "")); + input.add(newInMemoryImageFile("/aaa/ccc", ModuleEntry.Type.CONFIG, "")); throw new AssertionError("Exception expected"); } catch (Exception e) { // expected } } - private static class InMemoryImageFile extends ModuleEntryImpl { - public InMemoryImageFile(String module, String path, ModuleEntry.Type type, String content) { - super(module, path, type, new ByteArrayInputStream(content.getBytes()), content.getBytes().length); - } + private static ModuleEntry newInMemoryImageFile(String path, + ModuleEntry.Type type, String content) { + return ModuleEntryFactory.create(path, type, content.getBytes()); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/IntegrationTest.java --- a/jdk/test/tools/jlink/IntegrationTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/IntegrationTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -34,17 +34,17 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Function; import jdk.tools.jlink.Jlink; import jdk.tools.jlink.Jlink.JlinkConfiguration; import jdk.tools.jlink.Jlink.PluginsConfiguration; import jdk.tools.jlink.builder.DefaultImageBuilder; -import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.PostProcessorPlugin; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; +import jdk.tools.jlink.internal.ExecutableImage; +import jdk.tools.jlink.internal.PostProcessor; import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin; import jdk.tools.jlink.internal.plugins.StripDebugPlugin; -import jdk.tools.jlink.plugin.Plugin; import tests.Helper; import tests.JImageGenerator; @@ -70,7 +70,7 @@ private static final List ordered = new ArrayList<>(); - public static class MyPostProcessor implements PostProcessorPlugin { + public static class MyPostProcessor implements PostProcessor, Plugin { public static final String NAME = "mypostprocessor"; @@ -98,9 +98,14 @@ public void configure(Map config) { throw new UnsupportedOperationException("Shouldn't be called"); } + + @Override + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy(Function.identity(), out); + } } - public static class MyPlugin1 implements TransformerPlugin { + public static class MyPlugin1 implements Plugin { Integer index; Set after; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/JLinkOptionsTest.java --- a/jdk/test/tools/jlink/JLinkOptionsTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/JLinkOptionsTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -26,7 +26,7 @@ import java.util.Set; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.internal.PluginRepository; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import tests.Helper; @@ -46,7 +46,7 @@ */ public class JLinkOptionsTest { - private static class TestPlugin implements TransformerPlugin { + private static class TestPlugin implements Plugin { private final String name; private final String option; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/JLinkPostProcessingTest.java --- a/jdk/test/tools/jlink/JLinkPostProcessingTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/JLinkPostProcessingTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -28,10 +28,13 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Function; +import jdk.tools.jlink.plugin.Plugin; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.internal.PluginRepository; -import jdk.tools.jlink.plugin.ExecutableImage; -import jdk.tools.jlink.plugin.PostProcessorPlugin; +import jdk.tools.jlink.internal.PostProcessor; +import jdk.tools.jlink.internal.ExecutableImage; import tests.Helper; /* @@ -50,7 +53,7 @@ */ public class JLinkPostProcessingTest { - private static class PPPlugin implements PostProcessorPlugin { + private static class PPPlugin implements PostProcessor, Plugin { private static ExecutableImage called; private static final String NAME = "pp"; @@ -68,6 +71,11 @@ } @Override + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy(Function.identity(), out); + } + + @Override public String getName() { return NAME; } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/JLinkTest.java --- a/jdk/test/tools/jlink/JLinkTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/JLinkTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.lang.module.ModuleDescriptor; import java.lang.reflect.Layer; import java.nio.file.Files; import java.nio.file.Path; @@ -51,9 +52,20 @@ * jdk.jlink/jdk.tools.jimage * jdk.compiler * @build tests.* - * @run main/othervm -verbose:gc -Xmx1g JLinkTest + * @run main/othervm -Xmx1g JLinkTest */ public class JLinkTest { + // number of built-in plugins from jdk.jlink module + private static int getNumJlinkPlugins() { + ModuleDescriptor desc = Plugin.class.getModule().getDescriptor(); + return desc.provides(). + get(Plugin.class.getName()). + providers().size(); + } + + private static boolean isOfJLinkModule(Plugin p) { + return p.getClass().getModule() == Plugin.class.getModule(); + } public static void main(String[] args) throws Exception { @@ -63,18 +75,27 @@ return; } helper.generateDefaultModules(); - int numPlugins = 13; + // expected num. of plugins from jdk.jlink module + int expectedJLinkPlugins = getNumJlinkPlugins(); + int totalPlugins = 0; { // number of built-in plugins List builtInPlugins = new ArrayList<>(); builtInPlugins.addAll(PluginRepository.getPlugins(Layer.boot())); + totalPlugins = builtInPlugins.size(); + // actual num. of plugins loaded from jdk.jlink module + int actualJLinkPlugins = 0; for (Plugin p : builtInPlugins) { p.getState(); p.getType(); + if (isOfJLinkModule(p)) { + actualJLinkPlugins++; + } } - if (builtInPlugins.size() != numPlugins) { - throw new AssertionError("Found plugins doesn't match expected number : " + - numPlugins + "\n" + builtInPlugins); + if (expectedJLinkPlugins != actualJLinkPlugins) { + throw new AssertionError("Actual plugins loaded from jdk.jlink: " + + actualJLinkPlugins + " which doesn't match expected number : " + + expectedJLinkPlugins); } } @@ -139,9 +160,9 @@ long number = Stream.of(output.split("\\R")) .filter((s) -> s.matches("Plugin Name:.*")) .count(); - if (number != numPlugins) { + if (number != totalPlugins) { System.err.println(output); - throw new AssertionError("Found: " + number + " expected " + numPlugins); + throw new AssertionError("Found: " + number + " expected " + totalPlugins); } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/ResourcePoolTest.java --- a/jdk/test/tools/jlink/ResourcePoolTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/ResourcePoolTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -66,9 +66,7 @@ String module = "/module" + (i / 10); String resourcePath = module + "/java/package" + i; byte[] bytes = resourcePath.getBytes(); - input.add(ModuleEntry.create(module, resourcePath, - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(bytes), bytes.length)); + input.add(ModuleEntry.create(resourcePath, bytes)); } ModulePool output = new ModulePoolImpl(); ResourceVisitor visitor = new ResourceVisitor(); @@ -103,12 +101,11 @@ switch (index) { case 0: ++amountAfter; - return ModuleEntry.create(resource.getModule(), resource.getPath() + SUFFIX, - resource.getType(), resource.stream(), resource.getLength()); + return ModuleEntry.create(resource.getPath() + SUFFIX, + resource.getType(), resource.getBytes()); case 1: ++amountAfter; - return ModuleEntry.create(resource.getModule(), resource.getPath(), - resource.getType(), resource.stream(), resource.getLength()); + return resource.create(resource.getBytes()); } return null; } @@ -132,9 +129,7 @@ samples.add("javax/management/ObjectName"); test(samples, (resources, module, path) -> { try { - resources.add(ModuleEntry.create(module, path, - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(new byte[0]), 0)); + resources.add(ModuleEntry.create(path, new byte[0])); } catch (Exception ex) { throw new RuntimeException(ex); } @@ -142,9 +137,7 @@ test(samples, (resources, module, path) -> { try { resources.add(ModulePoolImpl. - newCompressedResource(ModuleEntry.create(module, path, - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(new byte[0]), 0), + newCompressedResource(ModuleEntry.create(path, new byte[0]), ByteBuffer.allocate(99), "bitcruncher", null, ((ModulePoolImpl)resources).getStringTable(), ByteOrder.nativeOrder())); } catch (Exception ex) { @@ -203,20 +196,14 @@ private void checkResourcesAfterCompression() throws Exception { ModulePoolImpl resources1 = new ModulePoolImpl(); - ModuleEntry res1 = ModuleEntry.create("module1", "/module1/toto1", - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(new byte[0]), 0); - ModuleEntry res2 = ModuleEntry.create("module2", "/module2/toto1", - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(new byte[0]), 0); + ModuleEntry res1 = ModuleEntry.create("/module1/toto1", new byte[0]); + ModuleEntry res2 = ModuleEntry.create("/module2/toto1", new byte[0]); resources1.add(res1); resources1.add(res2); checkResources(resources1, res1, res2); ModulePool resources2 = new ModulePoolImpl(); - ModuleEntry res3 = ModuleEntry.create("module2", "/module2/toto1", - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(new byte[7]), 7); + ModuleEntry res3 = ModuleEntry.create("/module2/toto1", new byte[7]); resources2.add(res3); resources2.add(ModulePoolImpl.newCompressedResource(res1, ByteBuffer.allocate(7), "zip", null, resources1.getStringTable(), @@ -260,8 +247,7 @@ ((ModulePoolImpl) resources).setReadOnly(); try { - resources.add(ModuleEntry.create("module2", "/module2/toto1", - ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0)); + resources.add(ModuleEntry.create("/module2/toto1", new byte[0])); throw new AssertionError("ModulePool is read-only, but an exception is not thrown"); } catch (Exception ex) { // Expected diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/customplugin/module-info.java --- a/jdk/test/tools/jlink/customplugin/module-info.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/customplugin/module-info.java Fri Jul 01 16:50:37 2016 -0700 @@ -23,6 +23,6 @@ module customplugin { requires jdk.jlink; - provides jdk.tools.jlink.plugin.TransformerPlugin with plugin.HelloPlugin; - provides jdk.tools.jlink.plugin.TransformerPlugin with plugin.CustomPlugin; + provides jdk.tools.jlink.plugin.Plugin with plugin.HelloPlugin; + provides jdk.tools.jlink.plugin.Plugin with plugin.CustomPlugin; } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java --- a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -27,9 +27,9 @@ import java.util.function.Function; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; -public class CustomPlugin implements TransformerPlugin { +public class CustomPlugin implements Plugin { private final static String NAME = "custom-plugin"; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java --- a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java Fri Jul 01 16:50:37 2016 -0700 @@ -29,12 +29,12 @@ import java.util.Map; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; /** * Custom plugin */ -public final class HelloPlugin implements TransformerPlugin { +public final class HelloPlugin implements Plugin { private static final String OUTPUT_FILE = "customplugin.txt"; public static final String NAME = "hello"; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/CompressorPluginTest.java --- a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -61,7 +61,6 @@ import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; public class CompressorPluginTest { @@ -279,9 +278,8 @@ ModulePoolImpl inputResources, ModuleEntry res, List includesPatterns) { - TransformerPlugin compressor = (TransformerPlugin) plugin; ModulePool compressedModulePool = new ModulePoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable()); - compressor.visit(inputResources, compressedModulePool); + plugin.visit(inputResources, compressedModulePool); String path = res.getPath(); ModuleEntry compressed = compressedModulePool.findEntry(path).get(); CompressedResourceHeader header diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java --- a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -40,7 +40,6 @@ import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; public class ExcludeFilesPluginTest { public static void main(String[] args) throws Exception { @@ -74,8 +73,8 @@ fplug.configure(prop); ModulePoolImpl files = new ModulePoolImpl(); ModulePoolImpl fresult = new ModulePoolImpl(); - ModuleEntry f = ModuleEntry.create(module, "/" + module + "/" + sample, - ModuleEntry.Type.CONFIG, new ByteArrayInputStream(new byte[0]), 0); + ModuleEntry f = ModuleEntry.create("/" + module + "/" + sample, + ModuleEntry.Type.CONFIG, new byte[0]); files.add(f); fplug.visit(files, fresult); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/ExcludePluginTest.java --- a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -48,16 +48,16 @@ public void test() throws Exception { check("**.jcov", "/num/toto.jcov", true); - check("**.jcov", "//toto.jcov", true); + check("**.jcov", "/toto.jcov/", true); check("**.jcov", "/toto.jcov/tutu/tata", false); check("/java.base/*.jcov", "/java.base/toto.jcov", true); - check("/java.base/toto.jcov", "t/java.base/iti.jcov", false); + check("/java.base/toto.jcov", "/tjava.base/iti.jcov", false); check("/java.base/*/toto.jcov", "/java.base/toto.jcov", false); check("/java.base/*/toto.jcov", "/java.base/tutu/toto.jcov", true); check("**/java.base/*/toto.jcov", "/tutu/java.base/tutu/toto.jcov", true); check("/META-INF/**", "/META-INF/services/ MyProvider ", true); check("/META-INF/**", "/META-INF/services/MyProvider", true); - check("**/META-INF", " /META-INF/services/MyProvider", false); + check("**/META-INF", "/ META-INF/services/MyProvider", false); check("**/META-INF/**", "/java.base//META-INF/services/MyProvider", true); check("/java.base/*/Toto$Titi.class", "/java.base/tutu/Toto$Titi.class", true); check("/**$**.class", "/java.base/tutu/Toto$Titi.class", true); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java --- a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -38,7 +38,6 @@ import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.ModuleEntry; -import jdk.tools.jlink.plugin.TransformerPlugin; public class ExcludeVMPluginTest { @@ -165,15 +164,15 @@ // Create a pool with jvm.cfg and the input paths. byte[] jvmcfgContent = jvmcfg.getBytes(); ModulePool pool = new ModulePoolImpl(); - pool.add(ModuleEntry.create("java.base", "/java.base/native/jvm.cfg", - ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(jvmcfgContent), jvmcfgContent.length)); + pool.add(ModuleEntry.create("/java.base/native/jvm.cfg", + ModuleEntry.Type.NATIVE_LIB, jvmcfgContent)); for (String in : input) { - pool.add(ModuleEntry.create("java.base", in, - ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(new byte[0]), 0)); + pool.add(ModuleEntry.create(in, + ModuleEntry.Type.NATIVE_LIB, new byte[0])); } ModulePool out = new ModulePoolImpl(); - TransformerPlugin p = new ExcludeVMPlugin(); + Plugin p = new ExcludeVMPlugin(); Map config = new HashMap<>(); if (vm != null) { config.put(ExcludeVMPlugin.NAME, vm); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/LastSorterTest.java --- a/jdk/test/tools/jlink/plugins/LastSorterTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/LastSorterTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -45,7 +45,6 @@ import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; public class LastSorterTest { @@ -167,7 +166,7 @@ } } - public static class SorterPlugin implements TransformerPlugin { + public static class SorterPlugin implements Plugin { private final String name; private String starts; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java --- a/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -42,7 +42,7 @@ import jdk.tools.jlink.internal.plugins.OrderResourcesPlugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; public class OrderResourcesPluginTest { @@ -93,7 +93,7 @@ ModulePool out = new ModulePoolImpl(); Map config = new HashMap<>(); config.put(OrderResourcesPlugin.NAME, "/zazou/**,**/module-info.class"); - TransformerPlugin p = new OrderResourcesPlugin(); + Plugin p = new OrderResourcesPlugin(); p.configure(config); p.visit(resources, out); check(out.entries().collect(Collectors.toList()), sorted); @@ -116,7 +116,7 @@ ModulePool out = new ModulePoolImpl(); Map config = new HashMap<>(); config.put(OrderResourcesPlugin.NAME, "@" + order.getAbsolutePath()); - TransformerPlugin p = new OrderResourcesPlugin(); + Plugin p = new OrderResourcesPlugin(); p.configure(config); p.visit(resources, out); check(out.entries().collect(Collectors.toList()), sorted2); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/PluginOrderTest.java --- a/jdk/test/tools/jlink/plugins/PluginOrderTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/PluginOrderTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -46,7 +46,6 @@ import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.Plugin.Category; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; public class PluginOrderTest { @@ -225,7 +224,7 @@ PluginOrderingGraph.sort(plugins); } - private static class Plug implements TransformerPlugin { + private static class Plug implements Plugin { private final Set isBefore; private final Set isAfter; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/PluginsNegativeTest.java --- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -44,7 +44,6 @@ import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; public class PluginsNegativeTest { @@ -117,7 +116,7 @@ } } - public static class CustomPlugin implements TransformerPlugin { + public static class CustomPlugin implements Plugin { private final String name; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/PrevisitorTest.java --- a/jdk/test/tools/jlink/plugins/PrevisitorTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/PrevisitorTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -49,7 +49,6 @@ import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; public class PrevisitorTest { @@ -107,7 +106,7 @@ } } - private static class CustomPlugin implements TransformerPlugin, ResourcePrevisitor { + private static class CustomPlugin implements Plugin, ResourcePrevisitor { private static String NAME = "plugin"; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/StringSharingPluginTest.java --- a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -57,7 +57,7 @@ import jdk.tools.jlink.internal.plugins.StringSharingPlugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import tests.Helper; import tests.JImageValidator; @@ -106,6 +106,9 @@ byte[] content = Files.readAllBytes(p); String path = p.toString().replace('\\', '/'); path = path.substring("/modules".length()); + if (path.charAt(0) != '/') { + path = "/" + path; + } ModuleEntry res = ModuleEntry.create(path, content); resources.add(res); } catch (Exception ex) { @@ -116,7 +119,7 @@ try (java.util.stream.Stream stream = Files.walk(compiledClasses)) { stream.forEach(c); } - TransformerPlugin plugin = new StringSharingPlugin(); + Plugin plugin = new StringSharingPlugin(); ModulePoolImpl result = new ModulePoolImpl(resources.getByteOrder(), resources.getStringTable()); plugin.visit(resources, result); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/jlink/plugins/StripDebugPluginTest.java --- a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -58,7 +58,7 @@ import jdk.tools.jlink.internal.plugins.StripDebugPlugin; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; -import jdk.tools.jlink.plugin.TransformerPlugin; +import jdk.tools.jlink.plugin.Plugin; import tests.Helper; public class StripDebugPluginTest { @@ -124,7 +124,7 @@ checkDebugAttributes(result1.getBytes()); } - private ModuleEntry stripDebug(TransformerPlugin debug, ModuleEntry classResource, + private ModuleEntry stripDebug(Plugin debug, ModuleEntry classResource, String path, String infoPath, byte[] moduleInfo) throws Exception { ModulePool resources = new ModulePoolImpl(); resources.add(classResource); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/launcher/Arrrghs.java --- a/jdk/test/tools/launcher/Arrrghs.java Fri Jun 24 15:06:50 2016 -0700 +++ b/jdk/test/tools/launcher/Arrrghs.java Fri Jul 01 16:50:37 2016 -0700 @@ -24,7 +24,7 @@ /** * @test * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 - * 6894719 6968053 7151434 7146424 8007333 8077822 + * 6894719 6968053 7151434 7146424 8007333 8077822 8143640 * @summary Argument parsing validation. * @compile -XDignore.symbol.file Arrrghs.java * @run main/othervm Arrrghs @@ -197,6 +197,8 @@ // more treatment of mixed slashes checkArgumentParsing("f1/ f3\\ f4/", "f1/", "f3\\", "f4/"); checkArgumentParsing("f1/ f2\' ' f3/ f4/", "f1/", "f2\'", "'", "f3/", "f4/"); + + checkArgumentParsing("a\\*\\b", "a\\*\\b"); } private void initEmptyDir(File emptyDir) throws IOException { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/launcher/modules/dryrun/DryRunTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2016, 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 8159596 + * @library /lib/testlibrary + * @modules jdk.compiler + * jdk.jartool/sun.tools.jar + * @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools + * @run testng DryRunTest + * @summary Test java --dry-run + */ + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.testlibrary.ProcessTools; + +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + + +@Test +public class DryRunTest { + + private static final String TEST_SRC = System.getProperty("test.src"); + + private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); + private static final Path MODS_DIR = Paths.get("mods"); + private static final Path LIBS_DIR = Paths.get("libs"); + + // the module name of the test module + private static final String TEST_MODULE = "test"; + private static final String M_MODULE = "m"; + + // the module main class + private static final String MAIN_CLASS = "jdk.test.Main"; + + + @BeforeTest + public void compileTestModule() throws Exception { + + // javac -d mods/$TESTMODULE src/$TESTMODULE/** + assertTrue(CompilerUtils.compile(SRC_DIR.resolve(M_MODULE), + MODS_DIR, + "-modulesourcepath", SRC_DIR.toString())); + + assertTrue(CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE), + MODS_DIR, + "-modulesourcepath", SRC_DIR.toString())); + + Files.createDirectories(LIBS_DIR); + + // create JAR files with no module-info.class + assertTrue(jar(M_MODULE, "p/Lib.class")); + assertTrue(jar(TEST_MODULE, "jdk/test/Main.class")); + } + + /** + * Execute "java" with the given arguments, returning the exit code. + */ + private int exec(String... args) throws Exception { + return ProcessTools.executeTestJava(args) + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + } + + + /** + * Launch module main + */ + public void testModule() throws Exception { + String dir = MODS_DIR.toString(); + String mid = TEST_MODULE + "/" + MAIN_CLASS; + + // java -modulepath mods -module $TESTMODULE/$MAINCLASS + // no resolution failure + int exitValue = exec("--dry-run", "-modulepath", dir, "-m", mid); + assertTrue(exitValue == 0); + } + + /** + * Test non-existence module in -addmods + */ + public void testNonExistAddModules() throws Exception { + String dir = MODS_DIR.toString(); + String mid = TEST_MODULE + "/" + MAIN_CLASS; + + int exitValue = exec("--dry-run", "-modulepath", dir, + "-addmods", "non.existence", + "-m", mid); + assertTrue(exitValue != 0); + } + + /** + * Launch main class from class path + */ + public void testClassPath() throws Exception { + Path testJar = LIBS_DIR.resolve(TEST_MODULE + ".jar"); + String libs = testJar.toString() + File.pathSeparator + + LIBS_DIR.resolve(M_MODULE + ".jar").toString(); + + // test pass with m.jar:test.jar + int exitValue = exec("-classpath", libs, MAIN_CLASS); + assertTrue(exitValue == 0); + + // m.jar is not on classpath and fails with p.Lib not found + exitValue = exec("-classpath", testJar.toString(), MAIN_CLASS); + assertTrue(exitValue != 0); + + // dry pass passes since main is not executed + exitValue = exec("--dry-run", "-classpath", testJar.toString(), MAIN_CLASS); + assertTrue(exitValue == 0); + } + + /** + * Test automatic modules + */ + public void testAutomaticModule() throws Exception { + String libs = LIBS_DIR.resolve(M_MODULE + ".jar").toString() + + File.pathSeparator + + LIBS_DIR.resolve(TEST_MODULE + ".jar").toString(); + String mid = TEST_MODULE + "/" + MAIN_CLASS; + + // test main method with and without -addmods mm + int exitValue = exec("-modulepath", LIBS_DIR.toString(), + "-m", mid); + assertTrue(exitValue != 0); + + exitValue = exec("-modulepath", LIBS_DIR.toString(), + "-addmods", M_MODULE, + "-m", mid); + assertTrue(exitValue == 0); + + // test dry run with and without -addmods m + // no resolution failure + exitValue = exec("--dry-run", "-modulepath", LIBS_DIR.toString(), + "-m", mid); + assertTrue(exitValue == 0); + + exitValue = exec("--dry-run", "-modulepath", LIBS_DIR.toString(), + "-addmods", M_MODULE, + "-m", mid); + assertTrue(exitValue == 0); + } + + /** + * module m not found + */ + public void testMissingModule() throws Exception { + String subdir = MODS_DIR.resolve(TEST_MODULE).toString(); + String mid = TEST_MODULE + "/" + MAIN_CLASS; + + // resolution failure + int exitValue = exec("--dry-run", "-modulepath", subdir, "-m", mid); + assertTrue(exitValue != 0); + } + + private static boolean jar(String name, String entries) throws IOException { + Path jar = LIBS_DIR.resolve(name + ".jar"); + + // jar --create ... + String classes = MODS_DIR.resolve(name).toString(); + String[] args = { + "--create", + "--file=" + jar, + "-C", classes, entries + }; + boolean success + = new sun.tools.jar.Main(System.out, System.out, "jar").run(args); + return success; + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/launcher/modules/dryrun/src/m/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/launcher/modules/dryrun/src/m/module-info.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016, 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. + */ + +module m { + exports p; +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/launcher/modules/dryrun/src/m/p/Lib.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/launcher/modules/dryrun/src/m/p/Lib.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, 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. + */ + +package p; + +public class Lib { + public static void sayHi() { + System.out.println("Hello world"); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/launcher/modules/dryrun/src/test/jdk/test/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/launcher/modules/dryrun/src/test/jdk/test/Main.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, 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. + */ + +package jdk.test; + +public class Main { + public static void main(String[] args) { + p.Lib.sayHi(); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 jdk/test/tools/launcher/modules/dryrun/src/test/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/launcher/modules/dryrun/src/test/module-info.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016, 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. + */ + +module test { + requires m; +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/.hgtags --- a/langtools/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -366,3 +366,4 @@ 095bd53bdd1ef211a473553a95ee625fcfbc3f59 jdk-9+121 203a9e1b82b6cc7918f96a92e5a7eb28eafcdd18 jdk-9+122 d0c742ddfb01ebe427720798c4c8335023ae20f8 jdk-9+123 +26aa3caa778eab1c931910149c414783ee83bce7 jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/make/build.xml --- a/langtools/make/build.xml Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/make/build.xml Fri Jul 01 16:50:37 2016 -0700 @@ -235,7 +235,10 @@ - + + + + diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/make/diags-examples.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/make/diags-examples.xml Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/make/intellij/utils/jtreg-live-templates.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/make/intellij/utils/jtreg-live-templates.xml Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,25 @@ + + + + diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri Jul 01 16:50:37 2016 -0700 @@ -1039,7 +1039,8 @@ if (start_pc == 0) { // ensure array large enough if (register >= parameterNameIndices.length) { - int newSize = Math.max(register, parameterNameIndices.length + 8); + int newSize = + Math.max(register + 1, parameterNameIndices.length + 8); parameterNameIndices = Arrays.copyOf(parameterNameIndices, newSize); } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java Fri Jul 01 16:50:37 2016 -0700 @@ -28,6 +28,11 @@ import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.*; +/** + * This doclet generates HTML-formatted documentation for the specified packages and types. + * @deprecated The doclet has been superseded by its replacement, + * {@code jdk.javadoc.doclets.StandardDoclet}. + */ @Deprecated public class Standard { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2003, 2015, 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 jdk.javadoc.doclets; + +import java.util.Locale; +import java.util.Set; + +import javax.lang.model.SourceVersion; + +import jdk.javadoc.doclet.Doclet; +import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.doclet.Reporter; +import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet; + +/** + * This doclet generates HTML-formatted documentation for the specified modules, packages and types. + */ +public class StandardDoclet implements Doclet { + + private final HtmlDoclet htmlDoclet; + + public StandardDoclet() { + htmlDoclet = new HtmlDoclet(); + } + + public void init(Locale locale, Reporter reporter) { + htmlDoclet.init(locale, reporter); + } + + public String getName() { + return "Standard"; + } + + public Set getSupportedOptions() { + return htmlDoclet.getSupportedOptions(); + } + + public SourceVersion getSupportedSourceVersion() { + return htmlDoclet.sourceVersion(); + } + + public boolean run(DocletEnvironment root) { + return htmlDoclet.run(root); + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/package-info.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * This package contains standard, supported doclets. + */ +package jdk.javadoc.doclets; + diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java Fri Jul 01 16:50:37 2016 -0700 @@ -547,7 +547,7 @@ @Override public Set getSupportedOptions() { Doclet.Option[] options = { - new Option(this, "bottom", 1) { + new Option(this, "-bottom", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -555,7 +555,7 @@ return true; } }, - new Option(this, "charset", 1) { + new Option(this, "-charset", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -563,7 +563,7 @@ return true; } }, - new Option(this, "doctitle", 1) { + new Option(this, "-doctitle", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -571,7 +571,7 @@ return true; } }, - new Option(this, "footer", 1) { + new Option(this, "-footer", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -579,7 +579,7 @@ return true; } }, - new Option(this, "header", 1) { + new Option(this, "-header", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -587,7 +587,7 @@ return true; } }, - new Option(this, "helpfile", 1) { + new Option(this, "-helpfile", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -595,7 +595,7 @@ return true; } }, - new Option(this, "html4") { + new Option(this, "-html4") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -603,7 +603,7 @@ return true; } }, - new Option(this, "html5") { + new Option(this, "-html5") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -611,7 +611,7 @@ return true; } }, - new Option(this, "nohelp") { + new Option(this, "-nohelp") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -619,7 +619,7 @@ return true; } }, - new Option(this, "nodeprecatedlist") { + new Option(this, "-nodeprecatedlist") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -627,7 +627,7 @@ return true; } }, - new Option(this, "noindex") { + new Option(this, "-noindex") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -635,7 +635,7 @@ return true; } }, - new Option(this, "nonavbar") { + new Option(this, "-nonavbar") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -643,7 +643,7 @@ return true; } }, - new Hidden(this, "nooverview") { + new Hidden(this, "-nooverview") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -651,7 +651,7 @@ return true; } }, - new Option(this, "notree") { + new Option(this, "-notree") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -659,7 +659,7 @@ return true; } }, - new Hidden(this, "overview", 1) { + new Hidden(this, "-overview", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -667,7 +667,7 @@ return true; } }, - new Hidden(this, "packagesheader", 1) { + new Hidden(this, "-packagesheader", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -675,7 +675,7 @@ return true; } }, - new Option(this, "splitindex") { + new Option(this, "-splitindex") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -683,7 +683,7 @@ return true; } }, - new Option(this, "stylesheetfile", 1) { + new Option(this, "-stylesheetfile", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -691,7 +691,7 @@ return true; } }, - new Option(this, "top", 1) { + new Option(this, "-top", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -699,7 +699,7 @@ return true; } }, - new Option(this, "use") { + new Option(this, "-use") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -707,7 +707,7 @@ return true; } }, - new Option(this, "windowtitle", 1) { + new Option(this, "-windowtitle", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -715,7 +715,7 @@ return true; } }, - new XOption(this, "xdoclint") { + new XOption(this, "-Xdoclint") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -723,7 +723,7 @@ return true; } }, - new XOption(this, "Xdocrootparent", 1) { + new XOption(this, "-Xdocrootparent", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -731,11 +731,10 @@ return true; } }, - new XOption(this, "doclet.xusage.xdoclint-extended.", "Xdoclint:", 0) { + new XOption(this, "doclet.xusage.xdoclint-extended.", "-Xdoclint:", 0) { @Override public boolean matches(String option) { - String opt = option.startsWith("-") ? option.substring(1) : option; - return opt.toLowerCase().startsWith(getName().toLowerCase()); + return option.toLowerCase().startsWith(getName().toLowerCase()); } @Override @@ -745,11 +744,10 @@ return true; } }, - new XOption(this, "doclet.xusage.xdoclint-package.", "Xdoclint/package:", 0) { + new XOption(this, "doclet.xusage.xdoclint-package.", "-Xdoclint/package:", 0) { @Override public boolean matches(String option) { - String opt = option.startsWith("-") ? option.substring(1) : option; - return opt.toLowerCase().startsWith(getName().toLowerCase()); + return option.toLowerCase().startsWith(getName().toLowerCase()); } @Override diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Fri Jul 01 16:50:37 2016 -0700 @@ -185,6 +185,7 @@ doclet.Same_package_name_used=Package name format used twice: {0} doclet.exception_encountered=Exception encountered while processing {1}\n{0} +# option specifiers doclet.usage.d.name=d doclet.usage.d.parameters= doclet.usage.d.description=Destination directory for output files @@ -240,18 +241,23 @@ doclet.usage.linkoffline.name=linkoffline doclet.usage.linkoffline.parameters= -doclet.usage.linkoffline.description=Link to docs at using package list at +doclet.usage.linkoffline.description=Link to docs at using package list\n\ +\ at doclet.usage.excludedocfilessubdir.name=excludedocfilessubdir doclet.usage.excludedocfilessubdir.parameters=:.. -doclet.usage.excludedocfilessubdir.description=Exclude any doc-files subdirectories with given name +doclet.usage.excludedocfilessubdir.description=\n\ +\ Exclude any doc-files subdirectories with\n\ +\ given name doclet.usage.group.name=group doclet.usage.group.parameters= :.. -doclet.usage.group.description=Group specified packages together in overview page +doclet.usage.group.description=Group specified packages together\n\ +\ in overview page doclet.usage.nocomment.name=nocomment -doclet.usage.nocomment.description=Suppress description and tags, generate only declarations +doclet.usage.nocomment.description=Suppress description and tags, generate\n\ +\ only declarations doclet.usage.nodeprecated.name=nodeprecated doclet.usage.nodeprecated.description=Do not include @deprecated information @@ -289,7 +295,8 @@ doclet.usage.tag.name=tag doclet.usage.tag.parameters=::
      -doclet.usage.tag.description=Specify single argument custom tags +doclet.usage.tag.description=\n\ +\ Specify single argument custom tags doclet.usage.taglet.name=taglet doclet.usage.taglet.description=The fully qualified name of Taglet to register @@ -299,7 +306,8 @@ doclet.usage.charset.name=charset doclet.usage.charset.parameters= -doclet.usage.charset.description=Charset for cross-platform viewing of generated documentation +doclet.usage.charset.description=Charset for cross-platform viewing of\n\ +\ generated documentation doclet.usage.helpfile.name=helpfile doclet.usage.helpfile.parameters= @@ -310,14 +318,17 @@ doclet.usage.sourcetab.name=sourcetab doclet.usage.sourcetab.parameters= -doclet.usage.sourcetab.description=Specify the number of spaces each tab takes up in the source +doclet.usage.sourcetab.description=Specify the number of spaces each tab\n\ +\ takes up in the source doclet.usage.keywords.name=keywords -doclet.usage.keywords.description=Include HTML meta tags with package, class and member info +doclet.usage.keywords.description=Include HTML meta tags with package,\n\ +\ class and member info doclet.usage.stylesheetfile.name=stylesheetfile doclet.usage.stylesheetfile.parameters= -doclet.usage.stylesheetfile.description=File to change style of the generated documentation +doclet.usage.stylesheetfile.description=File to change style of the generated\n\ +\ documentation doclet.usage.docencoding.name=docencoding doclet.usage.docencoding.parameters= @@ -325,23 +336,30 @@ doclet.xusage.xdocrootparent.name=Xdocrootparent doclet.xusage.xdocrootparent.parameters= -doclet.xusage.xdocrootparent.description=Replaces all @docRoot followed by /.. in doc comments with +doclet.xusage.xdocrootparent.description=Replaces all @docRoot followed by /..\n\ +\ in doc comments with doclet.xusage.xdoclint.name=Xdoclint -doclet.xusage.xdoclint.description=Enable recommended checks for problems in javadoc comments +doclet.xusage.xdoclint.description=Enable recommended checks for problems in\n\ +\ javadoc comments doclet.xusage.xdoclint-extended.name=Xdoclint: doclet.xusage.xdoclint-extended.parameters=(all|none|[-]) # L10N: do not localize these words: all none accessibility html missing reference syntax -doclet.xusage.xdoclint-extended.description=Enable or disable specific checks for problems in javadoc comments,\n\ -\ Enable or disable specific checks for problems in javadoc comments,\n\ -\ where is one of accessibility, html, missing, reference, or syntax.\n +doclet.xusage.xdoclint-extended.description=Enable or disable specific checks\n\ +\ for problems in javadoc comments, where \n\ +\ is one of accessibility, html,\n\ +\ missing, reference, or syntax.\n doclet.xusage.xdoclint-package.name=Xdoclint/package: doclet.xusage.xdoclint-package.parameters=([-]) doclet.xusage.xdoclint-package.description=\n\ -\ Enable or disable checks in specific packages. is a comma separated\n\ -\ list of package specifiers. Package specifier is either a qualified name of a package\n\ -\ or a package name prefix followed by .*, which expands to all sub-packages of\n\ -\ the given package. Prefix the package specifier with - to disable checks for\n\ -\ the specified packages.\n +\ Enable or disable checks in specific\n\ +\ packages. is a comma separated\n\ +\ list of package specifiers. Package\n\ +\ specifier is either a qualified name of a\n\ +\ package or a package name prefix followed\n\ +\ by .*, which expands to all sub-packages\n\ +\ of the given package. Prefix the package\n\ +\ specifier with - to disable checks for\n\ +\ the specified packages.\n diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/standard/Standard.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/standard/Standard.java Fri Jun 24 15:06:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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 jdk.javadoc.internal.doclets.standard; - -import java.util.Locale; -import java.util.Set; - -import javax.lang.model.SourceVersion; - -import jdk.javadoc.doclet.Doclet; -import jdk.javadoc.doclet.DocletEnvironment; -import jdk.javadoc.doclet.Reporter; -import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet; - -public class Standard implements Doclet { - - private final HtmlDoclet htmlDoclet; - - public Standard() { - htmlDoclet = new HtmlDoclet(); - } - - public void init(Locale locale, Reporter reporter) { - htmlDoclet.init(locale, reporter); - } - - public String getName() { - return "Standard"; - } - - public Set getSupportedOptions() { - return htmlDoclet.getSupportedOptions(); - } - - public SourceVersion getSupportedSourceVersion() { - return htmlDoclet.sourceVersion(); - } - - public boolean run(DocletEnvironment root) { - return htmlDoclet.run(root); - } -} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java Fri Jul 01 16:50:37 2016 -0700 @@ -411,7 +411,7 @@ public Set getSupportedOptions() { Doclet.Option[] options = { - new Option(this, "author") { + new Option(this, "-author") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -419,7 +419,7 @@ return true; } }, - new Option(this, "d", 1) { + new Option(this, "-d", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -427,7 +427,7 @@ return true; } }, - new Option(this, "docencoding", 1) { + new Option(this, "-docencoding", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -435,7 +435,7 @@ return true; } }, - new Option(this, "docfilessubdirs") { + new Option(this, "-docfilessubdirs") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -443,7 +443,7 @@ return true; } }, - new Hidden(this, "encoding", 1) { + new Hidden(this, "-encoding", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -451,7 +451,7 @@ return true; } }, - new Option(this, "excludedocfilessubdir", 1) { + new Option(this, "-excludedocfilessubdir", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -459,7 +459,7 @@ return true; } }, - new Option(this, "group", 2) { + new Option(this, "-group", 2) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -467,7 +467,7 @@ return true; } }, - new Hidden(this, "javafx") { + new Hidden(this, "-javafx") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -475,7 +475,7 @@ return true; } }, - new Option(this, "keywords") { + new Option(this, "-keywords") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -483,7 +483,7 @@ return true; } }, - new Option(this, "link", 1) { + new Option(this, "-link", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -492,7 +492,7 @@ return true; } }, - new Option(this, "linksource") { + new Option(this, "-linksource") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -500,7 +500,7 @@ return true; } }, - new Option(this, "linkoffline", 2) { + new Option(this, "-linkoffline", 2) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -509,7 +509,7 @@ return true; } }, - new Option(this, "nocomment") { + new Option(this, "-nocomment") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -517,7 +517,7 @@ return true; } }, - new Option(this, "nodeprecated") { + new Option(this, "-nodeprecated") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -525,7 +525,7 @@ return true; } }, - new Option(this, "nosince") { + new Option(this, "-nosince") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -533,7 +533,7 @@ return true; } }, - new Option(this, "notimestamp") { + new Option(this, "-notimestamp") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -541,7 +541,7 @@ return true; } }, - new Option(this, "noqualifier", 1) { + new Option(this, "-noqualifier", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -549,7 +549,7 @@ return true; } }, - new Hidden(this, "quiet") { + new Hidden(this, "-quiet") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -557,7 +557,7 @@ return true; } }, - new Option(this, "serialwarn") { + new Option(this, "-serialwarn") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -565,7 +565,7 @@ return true; } }, - new Option(this, "sourcetab", 1) { + new Option(this, "-sourcetab", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -584,7 +584,7 @@ return true; } }, - new Option(this, "tag", 1) { + new Option(this, "-tag", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -595,7 +595,7 @@ return true; } }, - new Option(this, "taglet", 1) { + new Option(this, "-taglet", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -606,7 +606,7 @@ return true; } }, - new Option(this, "tagletpath", 1) { + new Option(this, "-tagletpath", 1) { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -614,7 +614,7 @@ return true; } }, - new Option(this, "version") { + new Option(this, "-version") { @Override public boolean process(String opt, ListIterator args) { optionsProcessed.add(this); @@ -1083,14 +1083,13 @@ protected Option(Configuration config, String keyName, String name, int argCount) { c = config; + this.name = name; String key = keyName + "name"; String oname = getOptionsMessage(key); if (oname.isEmpty()) { - this.name = name; this.parameters = ""; this.description = ""; } else { - this.name = oname; this.parameters = getOptionsMessage(keyName + "parameters"); this.description = getOptionsMessage(keyName + "description"); } @@ -1098,7 +1097,7 @@ } protected Option(String prefix, Configuration config, String name, int argCount) { - this(config, prefix + name.toLowerCase() + ".", name, argCount); + this(config, prefix + name.toLowerCase().replaceAll("^-*", "") + ".", name, argCount); } protected Option(Configuration config, String name, int argCount) { @@ -1146,7 +1145,7 @@ String opt = name + (name.endsWith(":") ? "" : " ") + parameters; int optlen = opt.length(); int spaces = 32 - optlen; - StringBuffer sb = new StringBuffer(" -").append(opt); + StringBuffer sb = new StringBuffer(" ").append(opt); for (int i = 0; i < spaces; i++) { sb.append(" "); } @@ -1161,8 +1160,7 @@ @Override public boolean matches(String option) { - String arg = option.startsWith("-") ? option.substring(1) : option; - return name.toLowerCase().equals(arg.toLowerCase()); + return name.toLowerCase().equals(option.toLowerCase()); } @Override diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Fri Jul 01 16:50:37 2016 -0700 @@ -86,7 +86,7 @@ com.sun.tools.doclets.standard.Standard.class; private static final Class StdDoclet = - jdk.javadoc.internal.doclets.standard.Standard.class; + jdk.javadoc.doclets.StandardDoclet.class; /** Context for this invocation. */ private final Context context; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/src/jdk.javadoc/share/classes/module-info.java --- a/langtools/src/jdk.javadoc/share/classes/module-info.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/module-info.java Fri Jul 01 16:50:37 2016 -0700 @@ -30,9 +30,12 @@ exports com.sun.javadoc; exports com.sun.tools.doclets; + exports com.sun.tools.doclets.standard; exports com.sun.tools.javadoc; + exports jdk.javadoc.doclet; exports jdk.javadoc.doclet.taglet; + exports jdk.javadoc.doclets; provides javax.tools.DocumentationTool with jdk.javadoc.internal.api.JavadocTool; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java --- a/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java Fri Jul 01 16:50:37 2016 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 8035473 8154482 + * @bug 8035473 8154482 8154399 8159096 * @summary make sure the javadoc tool responds correctly to Xold, * old doclets and taglets. * @library /tools/lib @@ -87,7 +87,7 @@ CLASS_NAME + "\\$OldTaglet.*"); final static String OLD_STDDOCLET = "com.sun.tools.doclets.standard.Standard"; - final static String NEW_STDDOCLET = "jdk.javadoc.internal.doclets.standard.Standard"; + final static String NEW_STDDOCLET = "jdk.javadoc.doclets.StandardDoclet"; public EnsureNewOldDoclet() throws Exception { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/test/jdk/jshell/ComputeFQNsTest.java --- a/langtools/test/jdk/jshell/ComputeFQNsTest.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/test/jdk/jshell/ComputeFQNsTest.java Fri Jul 01 16:50:37 2016 -0700 @@ -76,8 +76,8 @@ assertInferredFQNs("class X { ArrayList", "ArrayList".length(), false, "java.util.ArrayList"); } - @Test(enabled = false) //JDK-8150860 - public void testSuspendIndexing() throws Exception { + @Test + public void testSuspendIndexing() throws Throwable { compiler.compile(outDir, "package test; public class FQNTest { }"); String jarName = "test.jar"; compiler.jar(outDir, jarName, "test/FQNTest.class"); @@ -90,15 +90,35 @@ getState().sourceCodeAnalysis(); + Throwable[] evalException = new Throwable[1]; + new Thread() { @Override public void run() { - assertEval("{new java.io.FileOutputStream(\"" + runMarkFile.toAbsolutePath().toString() + "\").close();" + - " while (java.nio.file.Files.exists(java.nio.file.Paths.get(\"" + continueMarkFile.toString() + "\"))) Thread.sleep(100); }"); + try { + assertEval("{new java.io.FileOutputStream(\"" + runMarkFile.toAbsolutePath().toString().replace("\\", "\\\\") + "\").close();" + + " while (java.nio.file.Files.exists(java.nio.file.Paths.get(\"" + continueMarkFile.toAbsolutePath().toString().replace("\\", "\\\\") + "\"))) Thread.sleep(100); }"); + } catch (Throwable t) { + evalException[0] = t; + } } }.start(); - while (!Files.exists(runMarkFile)) - Thread.sleep(100); + while (true) { + if (Files.exists(runMarkFile)) + break; + try { + Thread.sleep(100); + } catch (Throwable t) { + if (evalException[0] != null) { + evalException[0].addSuppressed(t); + } else { + throw t; + } + } + if (evalException[0] != null) { + throw evalException[0]; + } + } addToClasspath(compiler.getPath(outDir).resolve(jarName)); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T.jcod --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T.jcod Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2016, 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. + */ +class T { + 0xCAFEBABE; + 0; // minor version + 52; // version + [] { // Constant Pool + ; // first element is empty + Method #3 #15; // #1 + class #16; // #2 + class #17; // #3 + Utf8 ""; // #4 + Utf8 "()V"; // #5 + Utf8 "Code"; // #6 + Utf8 "LocalVariableTable"; // #7 + Utf8 "this"; // #8 + Utf8 "LT;"; // #9 + Utf8 "test"; // #10 + Utf8 "(I)I"; // #11 + Utf8 "p"; // #12 + Utf8 "I"; // #13 + Utf8 "l1"; // #14 + NameAndType #4 #5; // #15 + Utf8 "T"; // #16 + Utf8 "java/lang/Object"; // #17 + } // Constant Pool + + 0x0021; // access + #2;// this_cpx + #3;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + { // Member + 0x0001; // access + #4; // name_cpx + #5; // sig_cpx + [] { // Attributes + Attr(#6) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#7) { // LocalVariableTable + [] { // LocalVariableTable + 0 5 8 9 0; + } + } // end LocalVariableTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0001; // access + #10; // name_cpx + #11; // sig_cpx + [] { // Attributes + Attr(#6) { // Code + 1; // max_stack + 3; // max_locals + Bytes[]{ + 0x033D1CAC; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#7) { // LocalVariableTable + [] { // LocalVariableTable + 0 4 8 9 0; + 0 4 12 13 1; + 0 4 14 13 20; + } + } // end LocalVariableTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + } // Attributes +} // end class T diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T8136453.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T8136453.java Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, 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 8136453 + * @summary Checking that javac's ClassReader expands its parameterNameIndices array properly. + * @modules jdk.compiler + * @build T T8136453 + * @run main T8136453 + */ + +import java.util.Arrays; +import java.util.List; + +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.util.ElementFilter; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; + +public class T8136453 { + public static void main(String... args) { + new T8136453().run(); + } + + void run() { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + List opts = Arrays.asList("-XDsave-parameter-names"); + JavacTask task = (JavacTask) compiler.getTask(null, null, null, opts, null, null); + TypeElement t = task.getElements().getTypeElement("T"); + ExecutableElement testMethod = ElementFilter.methodsIn(t.getEnclosedElements()).get(0); + VariableElement param = testMethod.getParameters().get(0); + Name paramName = param.getSimpleName(); + + if (!paramName.contentEquals("p")) { + throw new AssertionError("Wrong parameter name: " + paramName); + } + } +} diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/test/tools/javac/diags/HTMLWriter.java --- a/langtools/test/tools/javac/diags/HTMLWriter.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/test/tools/javac/diags/HTMLWriter.java Fri Jul 01 16:50:37 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -40,7 +40,7 @@ * @throws IOException if there is a problem writing to the underlying stream */ public HTMLWriter(Writer out) throws IOException { - this(out, ""); + this(out, ""); } /** @@ -328,7 +328,7 @@ */ public void writeLink(File file, String body) throws IOException { startTag(A); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String path = file.getPath().replace(File.separatorChar, '/'); if (file.isAbsolute() && !path.startsWith("/")) sb.append('/'); @@ -472,13 +472,15 @@ public static final String BORDER = "border"; /** The HTML "br" tag. */ public static final String BR = "br"; + /** The HTML "charset" attribute. */ + public static final String CHARSET = "charset"; /** The HTML "class" attribute. */ public static final String CLASS = "class"; /** The HTML "classid" attribute. */ public static final String CLASSID = "classid"; /** The HTML "code" tag. */ public static final String CODE = "code"; - /** The HTML "color" attribte. */ + /** The HTML "color" attribute. */ public static final String COLOR = "color"; /** The HTML "col" attribute value. */ public static final String COL = "col"; @@ -522,6 +524,8 @@ public static final String LI = "li"; /** The HTML "link" tag. */ public static final String LINK = "link"; + /** The HTML "meta" attribute. */ + public static final String META = "meta"; /** The HTML "name" attribute. */ public static final String NAME = "name"; /** The HTML "object" tag. */ diff -r 44eb314f5b38 -r 2dbd21fdb7a0 langtools/test/tools/javac/diags/RunExamples.java --- a/langtools/test/tools/javac/diags/RunExamples.java Fri Jun 24 15:06:50 2016 -0700 +++ b/langtools/test/tools/javac/diags/RunExamples.java Fri Jul 01 16:50:37 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -354,7 +354,10 @@ html.write(title); html.endTag(HTMLWriter.TITLE); } + html.startTag(HTMLWriter.META); + html.writeAttr(HTMLWriter.CHARSET, "UTF-8"); html.startTag(HTMLWriter.STYLE); + html.write(null); // revert to body text html.newLine(); html.writeLine("div.file { background-color:#e0ffe0; margin-left:30px; margin-right:30px;\n" + " padding: 3px; border: thin solid silver; }"); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 make/Bundles.gmk --- a/make/Bundles.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/make/Bundles.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -52,7 +52,7 @@ SetupBundleFile = $(NamedParamsMacroTemplate) define SetupBundleFileBody - $1_RELATIVE_FILES := $$(patsubst $$($1_BASE_DIR)/%, ./%, $$($1_FILES)) + $1_RELATIVE_FILES := $$(patsubst $$($1_BASE_DIR)/%, %, $$($1_FILES)) ifneq ($$(filter %.tar.gz, $$($1_BUNDLE_NAME)), ) $1_TYPE := tar.gz @@ -71,7 +71,7 @@ $$(call MakeDir, $$(@D)) ifneq ($$($1_SPECIAL_INCLUDES), ) $$(foreach i, $$($1_SPECIAL_INCLUDES), \ - ($(CD) $$($1_BASE_DIR) && $(FIND) ./$$i \ + ($(CD) $$($1_BASE_DIR) && $(FIND) $$i \ >> $(SUPPORT_OUTPUTDIR)/bundles/_$1_files ) ; ) endif ifneq ($$($1_SUBDIR), ) diff -r 44eb314f5b38 -r 2dbd21fdb7a0 make/CreateHgtipFiles.gmk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/CreateHgtipFiles.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,55 @@ +# +# Copyright (c) 2016, 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. +# + +default: all + +include $(SPEC) +include MakeBase.gmk + +define SetupCreateHgtip + + $$(strip $1)/$(HGTIP_FILENAME): FRC + $(HG) tip --repository $$(strip $1) --template '{node|short}\n' > $$@.tmp + if [ ! -f $$@ ] || [ "`$(CAT) $$@`" != "`$(CAT) $$@.tmp`" ]; then \ + $(MV) $$@.tmp $$@ ; \ + else \ + $(RM) $$@.tmp ; \ + fi + + TARGETS += $$(strip $1)/$(HGTIP_FILENAME) + +endef + +# Only try to create the tips if finding an actual hg repository. This will be +# false if building from a source bundle. +$(foreach r, $(call FindAllReposAbs), \ + $(if $(wildcard $r/.hg), $(eval $(call SetupCreateHgtip, $r))) \ +) + +all: $(TARGETS) + +FRC: + +.PHONY: all diff -r 44eb314f5b38 -r 2dbd21fdb7a0 make/GensrcModuleInfo.gmk --- a/make/GensrcModuleInfo.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/make/GensrcModuleInfo.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -95,6 +95,7 @@ $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \ $(MODULE_CLASSES_DIRS) \ $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \ + $(JDK_OUTPUTDIR)/modules/$(MODULE) \ ))) # Convert the modification lines into arguments for the modification tool. diff -r 44eb314f5b38 -r 2dbd21fdb7a0 make/Javadoc.gmk --- a/make/Javadoc.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/make/Javadoc.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -463,7 +463,7 @@ DOCLETAPI_HEADER := Doclet API DOCLETAPI_BOTTOM := $(call CommonTrademarkBottom,$(DOCLETAPI_FIRST_COPYRIGHT_YEAR)) DOCLETAPI_GROUPNAME := Packages -DOCLETAPI_REGEXP := jdk.javadoc.doclet.* +DOCLETAPI_REGEXP := jdk.javadoc.doclet* # DOCLETAPI_PKGS is located in NON_CORE_PKGS.gmk # The index.html, options, and packages files diff -r 44eb314f5b38 -r 2dbd21fdb7a0 make/Main.gmk --- a/make/Main.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/make/Main.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -301,13 +301,16 @@ ################################################################################ # Images targets -# Stores the tips for each repository. This file is be used when constructing the jdk image and can be -# used to track the exact sources used to build that image. +# Stores the tips for each repository. This file is be used when constructing +# the jdk image and can be used to track the exact sources used to build that +# image. source-tips: $(SUPPORT_OUTPUTDIR)/source_tips $(SUPPORT_OUTPUTDIR)/source_tips: FRC $(call MakeDir, $(@D)) - @$(RM) $@ - @$(call GetSourceTips) + $(call GetSourceTips) + +create-hgtip-files: + +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateHgtipFiles.gmk) BOOTCYCLE_TARGET := product-images bootcycle-images: @@ -337,8 +340,8 @@ mac-bundles-jdk: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk) -ALL_TARGETS += source-tips bootcycle-images zip-security zip-source \ - jrtfs-jar jimages profiles mac-bundles-jdk +ALL_TARGETS += source-tips create-hgtip-files bootcycle-images zip-security \ + zip-source jrtfs-jar jimages profiles mac-bundles-jdk ################################################################################ # Docs targets diff -r 44eb314f5b38 -r 2dbd21fdb7a0 make/common/MakeBase.gmk --- a/make/common/MakeBase.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/make/common/MakeBase.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -335,25 +335,27 @@ ################################################################################ # The source tips can come from the Mercurial repository, or in the files # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same -# directory as the original $(HGDIR) directory. -# These should not be := assignments, only used from the root Makefile. -HG_VERSION = $(shell $(HG) version 2> /dev/null) -HG_DIRECTORY=.hg -HGTIP_FILENAME=.hgtip -HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO -REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \ - $(shell $(CD) $(SRC_ROOT) ; \ - $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) \ - $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) \ - 2> /dev/null))))) +# directory as the original .hg directory. The hgtip files are created in +# CreateHgtipFiles.gmk. +HGTIP_FILENAME := .hgtip +FindAllReposAbs = \ + $(strip $(sort $(dir $(filter-out $(SRC_ROOT)/build/%, $(wildcard \ + $(addprefix $(SRC_ROOT)/, \ + .hg */.hg */*/.hg */*/.hg */*/*/.hg \ + .hgtip */.hgtip */*/.hgtip */*/.hgtip */*/*/.hgtip \ + ) \ + ))))) + +FindAllReposRel = \ + $(strip $(subst $(SRC_ROOT)/,.,$(patsubst $(SRC_ROOT)/%/, %, $(FindAllReposAbs)))) # Emit the repo:tip pairs to $@, but only if they changed since last time define GetSourceTips $(CD) $(SRC_ROOT) ; \ - for i in $(REPO_LIST) IGNORE ; do \ + for i in $(FindAllReposRel) IGNORE ; do \ if [ "$${i}" = "IGNORE" ] ; then \ continue; \ - elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \ + elif [ -d $${i}/.hg -a "$(HG)" != "" ] ; then \ $(PRINTF) " %s:%s" \ "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \ elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \ @@ -369,12 +371,6 @@ fi endef -# Create the HGTIP_FILENAME file. Called from closed/make/SourceBundles.gmk -define CreateHgTip - $(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \ - $(ECHO) $1/$(HGTIP_FILENAME) -endef - ################################################################################ define SetupLogging diff -r 44eb314f5b38 -r 2dbd21fdb7a0 make/common/NON_CORE_PKGS.gmk --- a/make/common/NON_CORE_PKGS.gmk Fri Jun 24 15:06:50 2016 -0700 +++ b/make/common/NON_CORE_PKGS.gmk Fri Jul 01 16:50:37 2016 -0700 @@ -69,7 +69,8 @@ OLD_DOCLETAPI_PKGS = com.sun.javadoc DOCLETAPI_PKGS = jdk.javadoc.doclet \ - jdk.javadoc.doclet.taglet + jdk.javadoc.doclet.taglet \ + jdk.javadoc.doclets TAGLETAPI_FILE = com/sun/tools/doclets/Taglet.java diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/.hgtags --- a/nashorn/.hgtags Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/.hgtags Fri Jul 01 16:50:37 2016 -0700 @@ -357,3 +357,4 @@ 5992041b0794fa5f25518673d63e8f35bcc89360 jdk-9+121 b1de131a3fed6845c78bdda358ee127532f16a3f jdk-9+122 9ed859b4faaf9ff7cd35f9e7f51c7e630303067a jdk-9+123 +5d68f5155dded7efec7d5aca5d631caa7ee1042b jdk-9+124 diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Fri Jul 01 16:50:37 2016 -0700 @@ -280,12 +280,11 @@ addField(cv, name, OBJECT_DESC); } - @SuppressWarnings("deprecation") static void newFunction(final MethodGenerator mi, final String objName, final String className, final MemberInfo memInfo, final List specs) { final boolean arityFound = (memInfo.getArity() != MemberInfo.DEFAULT_ARITY); loadFunctionName(mi, memInfo.getName()); - mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, memInfo.getJavaName(), memInfo.getJavaDesc())); + mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, memInfo.getJavaName(), memInfo.getJavaDesc(), false)); assert specs != null; if (!specs.isEmpty()) { @@ -306,7 +305,6 @@ mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATIONKEY, SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC); } - @SuppressWarnings("deprecation") static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) { final String propertyName = memInfo.getName(); // stack: Collection @@ -319,13 +317,13 @@ mi.push(memInfo.getAttributes()); // setup getter method handle String javaName = GETTER_PREFIX + memInfo.getJavaName(); - mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, getterDesc(memInfo))); + mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, getterDesc(memInfo), false)); // setup setter method handle if (memInfo.isFinal()) { mi.pushNull(); } else { javaName = SETTER_PREFIX + memInfo.getJavaName(); - mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo))); + mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo), false)); } // property = AccessorProperty.create(key, flags, getter, setter); mi.invokeStatic(ACCESSORPROPERTY_TYPE, ACCESSORPROPERTY_CREATE, ACCESSORPROPERTY_CREATE_DESC); @@ -336,7 +334,6 @@ // stack: Collection } - @SuppressWarnings("deprecation") static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) { final String propertyName = getter.getName(); // stack: Collection @@ -349,13 +346,13 @@ mi.push(getter.getAttributes()); // setup getter method handle mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, - getter.getJavaName(), getter.getJavaDesc())); + getter.getJavaName(), getter.getJavaDesc(), false)); // setup setter method handle if (setter == null) { mi.pushNull(); } else { mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, - setter.getJavaName(), setter.getJavaDesc())); + setter.getJavaName(), setter.getJavaDesc(), false)); } // property = AccessorProperty.create(key, flags, getter, setter); mi.invokeStatic(ACCESSORPROPERTY_TYPE, ACCESSORPROPERTY_CREATE, ACCESSORPROPERTY_CREATE_DESC); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Fri Jul 01 16:50:37 2016 -0700 @@ -178,7 +178,6 @@ } } - @SuppressWarnings("deprecation") private void callSuper(final MethodGenerator mi) { String superClass, superDesc; mi.loadThis(); @@ -192,7 +191,7 @@ superClass = SCRIPTFUNCTION_TYPE; superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3; mi.loadLiteral(constructor.getName()); - mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc())); + mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc(), false)); loadMap(mi); mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java Fri Jul 01 16:50:37 2016 -0700 @@ -390,7 +390,6 @@ return EMPTY_LINK_LOGIC_TYPE.equals(type); } - @SuppressWarnings("deprecation") void memberInfoArray(final String className, final List mis) { if (mis.isEmpty()) { pushNull(); @@ -405,7 +404,7 @@ push(pos++); visitTypeInsn(NEW, SPECIALIZATION_TYPE); dup(); - visitLdcInsn(new Handle(H_INVOKESTATIC, className, mi.getJavaName(), mi.getJavaDesc())); + visitLdcInsn(new Handle(H_INVOKESTATIC, className, mi.getJavaName(), mi.getJavaDesc(), false)); final Type linkLogicClass = mi.getLinkLogicClass(); final boolean linkLogic = !linkLogicIsEmpty(linkLogicClass); final String ctor = linkLogic ? SPECIALIZATION_INIT3 : SPECIALIZATION_INIT2; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/samples/checknames.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/samples/checknames.js Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2016, 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. + */ + +// Simple Java identifier name pattern checker. You can check +// class, method and variable names in java sources to confirm +// to specified patterns. Default check functions just check for +// 'too short' names. You can customize checkXYZName functions to +// have arbitrary name pattern checks. + +// Usage: jjs checknames.js -- + +if (arguments.length == 0) { + print("Usage: jjs checknames.js -- "); + exit(1); +} + +// Java types used +var File = Java.type("java.io.File"); +var Files = Java.type("java.nio.file.Files"); +var StringArray = Java.type("java.lang.String[]"); +var ToolProvider = Java.type("javax.tools.ToolProvider"); +var Tree = Java.type("com.sun.source.tree.Tree"); +var Trees = Java.type("com.sun.source.util.Trees"); +var TreeScanner = Java.type("com.sun.source.util.TreeScanner"); + +// replace these checkXYZ functions with checks you want! +function checkClassName(name) { + return name.length < 3; +} + +function checkMethodName(name) { + return name.length < 3; +} + +function checkVarName(name) { + return name.length < 3; +} + +function checkNames() { + // get the system compiler tool + var compiler = ToolProvider.systemJavaCompiler; + // get standard file manager + var fileMgr = compiler.getStandardFileManager(null, null, null); + // Using Java.to convert script array (arguments) to a Java String[] + var compUnits = fileMgr.getJavaFileObjects(Java.to(arguments, StringArray)); + // create a new compilation task + var task = compiler.getTask(null, fileMgr, null, null, null, compUnits); + var sourcePositions = Trees.instance(task).sourcePositions; + // subclass SimpleTreeVisitor + var NameChecker = Java.extend(TreeScanner); + + var visitor = new NameChecker() { + report: function(node) { + var pos = sourcePositions.getStartPosition(this.compUnit, node); + var line = this.lineMap.getLineNumber(pos); + var col = this.lineMap.getColumnNumber(pos); + print("Too short name: " + node.name + " @ " + this.fileName + ":" + line + ":" + col); + }, + + // override to capture information on current compilation unit + visitCompilationUnit: function(compUnit, p) { + this.compUnit = compUnit; + this.lineMap = compUnit.lineMap; + this.fileName = compUnit.sourceFile.name; + + return Java.super(visitor).visitCompilationUnit(compUnit, p); + }, + + // override to check class name + visitClass: function(node, p) { + if (checkClassName(node.simpleName.toString())) { + this.report(node); + } + + return Java.super(visitor).visitClass(node, p); + }, + + // override to check method name + visitMethod: function(node, p) { + if (checkMethodName(node.name.toString())) { + this.report(node); + } + + return Java.super(visitor).visitMethod(node, p); + }, + + // override to check variable name + visitVariable: function(node, p) { + if (checkVarName(node.name.toString())) { + this.report(node); + } + + return Java.super(visitor).visitVariable(node, p); + } + } + + for each (var cu in task.parse()) { + cu.accept(visitor, null); + } +} + +// for each ".java" file in directory (recursively). +function main(dir) { + var totalCount = 0; + Files.walk(dir.toPath()). + forEach(function(p) { + var name = p.toFile().absolutePath; + if (name.endsWith(".java")) { + checkNames(p); + } + }); +} + +main(new File(arguments[0])); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/AssertsEnabled.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/AssertsEnabled.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/AssertsEnabled.java Fri Jul 01 16:50:37 2016 -0700 @@ -28,7 +28,6 @@ /** * Class that exposes the current state of asserts. */ -@SuppressWarnings("all") public final class AssertsEnabled { private static boolean assertsEnabled = false; static { diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java Fri Jul 01 16:50:37 2016 -0700 @@ -32,6 +32,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC; import static jdk.internal.org.objectweb.asm.Opcodes.GOTO; import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC; +import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKEINTERFACE; import static jdk.internal.org.objectweb.asm.Opcodes.IFEQ; import static jdk.internal.org.objectweb.asm.Opcodes.IFGE; import static jdk.internal.org.objectweb.asm.Opcodes.IFGT; @@ -170,12 +171,10 @@ } /** Bootstrap for normal indy:s */ - @SuppressWarnings("deprecation") - private static final Handle LINKERBOOTSTRAP = new Handle(H_INVOKESTATIC, Bootstrap.BOOTSTRAP.className(), Bootstrap.BOOTSTRAP.name(), Bootstrap.BOOTSTRAP.descriptor()); + private static final Handle LINKERBOOTSTRAP = new Handle(H_INVOKESTATIC, Bootstrap.BOOTSTRAP.className(), Bootstrap.BOOTSTRAP.name(), Bootstrap.BOOTSTRAP.descriptor(), false); /** Bootstrap for array populators */ - @SuppressWarnings("deprecation") - private static final Handle POPULATE_ARRAY_BOOTSTRAP = new Handle(H_INVOKESTATIC, RewriteException.BOOTSTRAP.className(), RewriteException.BOOTSTRAP.name(), RewriteException.BOOTSTRAP.descriptor()); + private static final Handle POPULATE_ARRAY_BOOTSTRAP = new Handle(H_INVOKESTATIC, RewriteException.BOOTSTRAP.className(), RewriteException.BOOTSTRAP.name(), RewriteException.BOOTSTRAP.descriptor(), false); /** * Constructor - internal use from ClassEmitter only @@ -1007,10 +1006,10 @@ * * @return the method emitter */ - @SuppressWarnings("deprecation") MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet flags) { + final int flag = Flag.getValue(flags); debug("load handle "); - pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName))); + pushType(Type.OBJECT.ldc(method, new Handle(flag, className, methodName, descName, flag == H_INVOKEINTERFACE))); return this; } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Fri Jul 01 16:50:37 2016 -0700 @@ -2474,14 +2474,14 @@ } @Override - protected FindProperty findProperty(final Object key, final boolean deep, final ScriptObject start) { - if (lexicalScope != null && start != this && start.isScope()) { + protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { + if (lexicalScope != null && isScope) { final FindProperty find = lexicalScope.findProperty(key, false); if (find != null) { return find; } } - return super.findProperty(key, deep, start); + return super.findProperty(key, deep, isScope, start); } @Override @@ -2854,8 +2854,7 @@ sb.append("$Constructor"); final Class funcClass = Class.forName(sb.toString()); - @SuppressWarnings("deprecation") - final T res = clazz.cast(funcClass.newInstance()); + final T res = clazz.cast(funcClass.getDeclaredConstructor().newInstance()); if (res instanceof ScriptFunction) { // All global constructor prototypes are not-writable, @@ -2871,8 +2870,12 @@ res.setIsBuiltin(); return res; - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { - throw new RuntimeException(e); + } catch (final Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new RuntimeException(e); + } } } @@ -2882,14 +2885,17 @@ final String className = PACKAGE_PREFIX + name + "$Prototype"; final Class funcClass = Class.forName(className); - @SuppressWarnings("deprecation") - final ScriptObject res = (ScriptObject) funcClass.newInstance(); + final ScriptObject res = (ScriptObject) funcClass.getDeclaredConstructor().newInstance(); res.setIsBuiltin(); res.setInitialProto(prototype); return res; - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { - throw new RuntimeException(e); + } catch (final Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new RuntimeException(e); + } } } diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Fri Jul 01 16:50:37 2016 -0700 @@ -609,6 +609,9 @@ if (stream.get(stream.last()) != token) { return false; } + + // Record current position in case multiple heredocs start on this line - see JDK-8073653 + final State state = saveState(); // Rewind to token start position reset(Token.descPosition(token)); @@ -616,7 +619,7 @@ return scanRegEx(); } else if (ch0 == '<') { if (ch1 == '<') { - return scanHereString(lir); + return scanHereString(lir, state); } else if (Character.isJavaIdentifierStart(ch1)) { return scanXMLLiteral(); } @@ -1539,7 +1542,7 @@ * * @return TRUE if is a here string. */ - private boolean scanHereString(final LineInfoReceiver lir) { + private boolean scanHereString(final LineInfoReceiver lir, final State oldState) { assert ch0 == '<' && ch1 == '<'; if (scripting) { // Record beginning of here string. @@ -1589,6 +1592,11 @@ int lastLinePosition = position; restState.setLimit(position); + if (oldState.position > position) { + restoreState(oldState); + skipLine(false); + } + // Record beginning of string. final State stringState = saveState(); int stringEnd = position; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Fri Jul 01 16:50:37 2016 -0700 @@ -775,7 +775,7 @@ * @return FindPropertyData or null if not found. */ public final FindProperty findProperty(final Object key, final boolean deep) { - return findProperty(key, deep, this); + return findProperty(key, deep, false, this); } /** @@ -791,12 +791,12 @@ * @see jdk.nashorn.internal.objects.NativeArray * * @param key Property key. - * @param deep Whether the search should look up proto chain. + * @param deep true if the search should look up proto chain + * @param isScope true if this is a scope access * @param start the object on which the lookup was originally initiated - * * @return FindPropertyData or null if not found. */ - protected FindProperty findProperty(final Object key, final boolean deep, final ScriptObject start) { + protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { final PropertyMap selfMap = getMap(); final Property property = selfMap.findProperty(key); @@ -807,7 +807,7 @@ if (deep) { final ScriptObject myProto = getProto(); - final FindProperty find = myProto == null ? null : myProto.findProperty(key, true, start); + final FindProperty find = myProto == null ? null : myProto.findProperty(key, true, isScope, start); // checkSharedProtoMap must be invoked after myProto.checkSharedProtoMap to propagate // shared proto invalidation up the prototype chain. It also must be invoked when prototype is null. checkSharedProtoMap(); @@ -1977,7 +1977,7 @@ return findMegaMorphicGetMethod(desc, name, operation == StandardOperation.GET_METHOD); } - final FindProperty find = findProperty(name, true); + final FindProperty find = findProperty(name, true, NashornCallSiteDescriptor.isScope(desc), this); MethodHandle mh; if (find == null) { @@ -2035,7 +2035,7 @@ } private static GuardedInvocation findMegaMorphicGetMethod(final CallSiteDescriptor desc, final String name, final boolean isMethod) { - Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic getter: " + desc + " " + name + " " +isMethod); + Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic getter: ", desc, " ", name + " ", isMethod); final MethodHandle invoker = MH.insertArguments(MEGAMORPHIC_GET, 1, name, isMethod, NashornCallSiteDescriptor.isScope(desc)); final MethodHandle guard = getScriptObjectGuard(desc.getMethodType(), true); return new GuardedInvocation(invoker, guard); @@ -2043,7 +2043,7 @@ @SuppressWarnings("unused") private Object megamorphicGet(final String key, final boolean isMethod, final boolean isScope) { - final FindProperty find = findProperty(key, true); + final FindProperty find = findProperty(key, true, isScope, this); if (find != null) { return find.getObjectValue(); } @@ -2181,7 +2181,7 @@ * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ - FindProperty find = findProperty(name, true, this); + FindProperty find = findProperty(name, true, NashornCallSiteDescriptor.isScope(desc), this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !find.getProperty().isAccessorProperty()) { @@ -2258,6 +2258,7 @@ } private GuardedInvocation findMegaMorphicSetMethod(final CallSiteDescriptor desc, final String name) { + Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic setter: ", desc, " ", name); final MethodType type = desc.getMethodType().insertParameterTypes(1, Object.class); //never bother with ClassCastExceptionGuard for megamorphic callsites final GuardedInvocation inv = findSetIndexMethod(getClass(), desc, false, type); @@ -2734,7 +2735,7 @@ if (isValidArrayIndex(index)) { for (ScriptObject object = this; ; ) { if (object.getMap().containsArrayKeys()) { - final FindProperty find = object.findProperty(key, false, this); + final FindProperty find = object.findProperty(key, false); if (find != null) { return getIntValue(find, programPoint); @@ -2805,7 +2806,7 @@ if (isValidArrayIndex(index)) { for (ScriptObject object = this; ; ) { if (object.getMap().containsArrayKeys()) { - final FindProperty find = object.findProperty(key, false, this); + final FindProperty find = object.findProperty(key, false); if (find != null) { return getDoubleValue(find, programPoint); } @@ -2875,7 +2876,7 @@ if (isValidArrayIndex(index)) { for (ScriptObject object = this; ; ) { if (object.getMap().containsArrayKeys()) { - final FindProperty find = object.findProperty(key, false, this); + final FindProperty find = object.findProperty(key, false); if (find != null) { return find.getObjectValue(); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java Fri Jul 01 16:50:37 2016 -0700 @@ -704,7 +704,17 @@ if (property != null) { if (obj instanceof ScriptObject) { - obj = ((ScriptObject)obj).get(property); + // this is a scope identifier + assert property instanceof String; + final ScriptObject sobj = (ScriptObject) obj; + + final FindProperty find = sobj.findProperty(property, true, true, sobj); + if (find != null) { + obj = find.getObjectValue(); + } else { + obj = sobj.invokeNoSuchProperty(property, false, UnwarrantedOptimismException.INVALID_PROGRAM_POINT); + } + if(Global.isLocationPropertyPlaceholder(obj)) { if(CompilerConstants.__LINE__.name().equals(property)) { obj = 0; diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Fri Jul 01 16:50:37 2016 -0700 @@ -193,20 +193,20 @@ * * @param key Property key. * @param deep Whether the search should look up proto chain. + * @param isScope true if is this a scope access * @param start the object on which the lookup was originally initiated - * * @return FindPropertyData or null if not found. */ @Override - protected FindProperty findProperty(final Object key, final boolean deep, final ScriptObject start) { + protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { // We call findProperty on 'expression' with 'expression' itself as start parameter. // This way in ScriptObject.setObject we can tell the property is from a 'with' expression // (as opposed from another non-scope object in the proto chain such as Object.prototype). - final FindProperty exprProperty = expression.findProperty(key, true, expression); + final FindProperty exprProperty = expression.findProperty(key, true, false, expression); if (exprProperty != null) { return exprProperty; } - return super.findProperty(key, deep, start); + return super.findProperty(key, deep, isScope, start); } @Override diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Fri Jul 01 16:50:37 2016 -0700 @@ -191,18 +191,16 @@ private static final Call RUN = interfaceCallNoLookup(Runnable.class, "run", void.class); // ASM handle to the bootstrap method - @SuppressWarnings("deprecation") private static final Handle BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC, Type.getInternalName(JavaAdapterServices.class), "bootstrap", MethodType.methodType(CallSite.class, Lookup.class, String.class, - MethodType.class, int.class).toMethodDescriptorString()); + MethodType.class, int.class).toMethodDescriptorString(), false); // ASM handle to the bootstrap method for array populator - @SuppressWarnings("deprecation") private static final Handle CREATE_ARRAY_BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC, Type.getInternalName(JavaAdapterServices.class), "createArrayBootstrap", MethodType.methodType(CallSite.class, Lookup.class, String.class, - MethodType.class).toMethodDescriptorString()); + MethodType.class).toMethodDescriptorString(), false); // Field type names used in the generated bytecode private static final String SCRIPT_OBJECT_TYPE_DESCRIPTOR = SCRIPT_OBJECT_TYPE.getDescriptor(); @@ -1061,13 +1059,12 @@ endMethod(mv); } - @SuppressWarnings("deprecation") private void generateFinalizerOverride() { final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize", VOID_METHOD_DESCRIPTOR, null, null)); // Overridden finalizer will take a MethodHandle to the finalizer delegating method, ... mv.aconst(new Handle(Opcodes.H_INVOKESTATIC, generatedClassName, FINALIZER_DELEGATE_NAME, - FINALIZER_DELEGATE_METHOD_DESCRIPTOR)); + FINALIZER_DELEGATE_METHOD_DESCRIPTOR, false)); mv.visitVarInsn(ALOAD, 0); // ...and invoke it through JavaAdapterServices.invokeNoPermissions INVOKE_NO_PERMISSIONS.invoke(mv); diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java Fri Jun 24 15:06:50 2016 -0700 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java Fri Jul 01 16:50:37 2016 -0700 @@ -80,8 +80,17 @@ this.negLookaheadLevel = negLookaheadLevel; } - boolean isContained(final int group, final int level) { - return group == this.negLookaheadGroup && level >= this.negLookaheadLevel; + /** + * Returns true if this Capture can be referenced from the position specified by the + * group and level parameters. This is the case if either the group is not within + * a negative lookahead, or the position of the referrer is in the same negative lookahead. + * + * @param group current negative lookahead group + * @param level current negative lokahead level + * @return true if this capture group can be referenced from the given position + */ + boolean canBeReferencedFrom(final int group, final int level) { + return this.negLookaheadLevel == 0 || (group == this.negLookaheadGroup && level >= this.negLookaheadLevel); } } @@ -671,8 +680,9 @@ } else if (decimalValue <= caps.size()) { // Captures inside a negative lookahead are undefined when referenced from the outside. - if (!caps.get(decimalValue - 1).isContained(negLookaheadGroup, negLookaheadLevel)) { - // Reference to capture in negative lookahead, omit from output buffer. + final Capture capture = caps.get(decimalValue - 1); + if (!capture.canBeReferencedFrom(negLookaheadGroup, negLookaheadLevel)) { + // Outside reference to capture in negative lookahead, omit from output buffer. sb.setLength(sb.length() - 1); } else { // Append backreference to output buffer. diff -r 44eb314f5b38 -r 2dbd21fdb7a0 nashorn/test/script/basic/JDK-8073653.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nashorn/test/script/basic/JDK-8073653.js Fri Jul 01 16:50:37 2016 -0700 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8073653: Secondary heredoc eating wrong lines. + * + * @test + * @run + * @option -scripting + */ + + +print(<