changeset 12686:ee79788e8427

Merge
author jwilhelm
date Sat, 11 Mar 2017 23:23:06 -0800
parents 95c595a133d2 (current diff) fc60138effe1 (diff)
children b01c519b715e eef6e15f993a
files
diffstat 10 files changed, 1075 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Thu Mar 09 23:15:59 2017 +0000
+++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Sat Mar 11 23:23:06 2017 -0800
@@ -81,6 +81,7 @@
 PROCESSOR_PATH := $(call PathList, $(PROCESSOR_JARS))
 
 ADD_EXPORTS := \
+    --add-modules jdk.internal.vm.ci \
     --add-exports jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \
     --add-exports jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \
     --add-exports jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \
--- a/src/share/vm/classfile/classFileParser.cpp	Thu Mar 09 23:15:59 2017 +0000
+++ b/src/share/vm/classfile/classFileParser.cpp	Sat Mar 11 23:23:06 2017 -0800
@@ -105,6 +105,12 @@
 
 #define JAVA_9_VERSION                    53
 
+void ClassFileParser::set_class_bad_constant_seen(short bad_constant) {
+  assert((bad_constant == 19 || bad_constant == 20) && _major_version >= JAVA_9_VERSION,
+         "Unexpected bad constant pool entry");
+  if (_bad_constant_seen == 0) _bad_constant_seen = bad_constant;
+}
+
 void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const stream,
                                                   ConstantPool* cp,
                                                   const int length,
@@ -302,6 +308,18 @@
         }
         break;
       }
+      case 19:
+      case 20: {
+        // Record that an error occurred in these two cases but keep parsing so
+        // that ACC_Module can be checked for in the access_flags.  Need to
+        // throw NoClassDefFoundError in that case.
+        if (_major_version >= JAVA_9_VERSION) {
+          cfs->guarantee_more(3, CHECK);
+          cfs->get_u2_fast();
+          set_class_bad_constant_seen(tag);
+          break;
+        }
+      }
       default: {
         classfile_parse_error("Unknown constant tag %u in class file %s",
                               tag,
@@ -359,14 +377,18 @@
 #endif
 
 void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
-                                          ConstantPool* const cp,
-                                          const int length,
-                                          TRAPS) {
+                                         ConstantPool* const cp,
+                                         const int length,
+                                         TRAPS) {
   assert(cp != NULL, "invariant");
   assert(stream != NULL, "invariant");
 
   // parsing constant pool entries
   parse_constant_pool_entries(stream, cp, length, CHECK);
+  if (class_bad_constant_seen() != 0) {
+    // a bad CP entry has been detected previously so stop parsing and just return.
+    return;
+  }
 
   int index = 1;  // declared outside of loops for portability
 
@@ -1244,6 +1266,10 @@
       }
     } else if (_major_version >= JAVA_1_5_VERSION) {
       if (attribute_name == vmSymbols::tag_signature()) {
+        if (generic_signature_index != 0) {
+          classfile_parse_error(
+            "Multiple Signature attributes for field in class file %s", CHECK);
+        }
         if (attribute_length != 2) {
           classfile_parse_error(
             "Wrong size %u for field's Signature attribute in class file %s",
@@ -2565,6 +2591,11 @@
       }
     } else if (_major_version >= JAVA_1_5_VERSION) {
       if (method_attribute_name == vmSymbols::tag_signature()) {
+        if (generic_signature_index != 0) {
+          classfile_parse_error(
+            "Multiple Signature attributes for method in class file %s",
+            CHECK_NULL);
+        }
         if (method_attribute_length != 2) {
           classfile_parse_error(
             "Invalid Signature attribute length %u in class file %s",
@@ -3284,6 +3315,10 @@
       }
     } else if (_major_version >= JAVA_1_5_VERSION) {
       if (tag == vmSymbols::tag_signature()) {
+        if (_generic_signature_index != 0) {
+          classfile_parse_error(
+            "Multiple Signature attributes in class file %s", CHECK);
+        }
         if (attribute_length != 2) {
           classfile_parse_error(
             "Wrong Signature attribute length %u in class file %s",
@@ -5558,6 +5593,7 @@
   _protection_domain(protection_domain),
   _access_flags(),
   _pub_level(pub_level),
+  _bad_constant_seen(0),
   _synthetic_flag(false),
   _sde_length(false),
   _sde_buffer(NULL),
@@ -5765,9 +5801,15 @@
 
   verify_legal_class_modifiers(flags, CHECK);
 
+  short bad_constant = class_bad_constant_seen();
+  if (bad_constant != 0) {
+    // Do not throw CFE until after the access_flags are checked because if
+    // ACC_MODULE is set in the access flags, then NCDFE must be thrown, not CFE.
+    classfile_parse_error("Unknown constant tag %u in class file %s", bad_constant, CHECK);
+  }
+
   _access_flags.set_flags(flags);
 
-
   // This class and superclass
   _this_class_index = stream->get_u2_fast();
   check_property(
--- a/src/share/vm/classfile/classFileParser.hpp	Thu Mar 09 23:15:59 2017 +0000
+++ b/src/share/vm/classfile/classFileParser.hpp	Sat Mar 11 23:23:06 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -122,6 +122,15 @@
   // for tracing and notifications
   Publicity _pub_level;
 
+  // Used to keep track of whether a constant pool item 19 or 20 is found.  These
+  // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
+  // in regular class files.  For class file version >= 53, a CFE cannot be thrown
+  // immediately when these are seen because a NCDFE must be thrown if the class's
+  // access_flags have ACC_MODULE set.  But, the access_flags haven't been looked
+  // at yet.  So, the bad constant pool item is cached here.  A value of zero
+  // means that no constant pool item 19 or 20 was found.
+  short _bad_constant_seen;
+
   // class attributes parsed before the instance klass is created:
   bool _synthetic_flag;
   int _sde_length;
@@ -161,6 +170,8 @@
   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS);
   void set_klass(InstanceKlass* instance);
 
+  void set_class_bad_constant_seen(short bad_constant);
+  short class_bad_constant_seen() { return  _bad_constant_seen; }
   void set_class_synthetic_flag(bool x)        { _synthetic_flag = x; }
   void set_class_sourcefile_index(u2 x)        { _sourcefile_index = x; }
   void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
--- a/src/share/vm/opto/ifnode.cpp	Thu Mar 09 23:15:59 2017 +0000
+++ b/src/share/vm/opto/ifnode.cpp	Sat Mar 11 23:23:06 2017 -0800
@@ -249,6 +249,13 @@
       predicate_proj = proj;
     }
   }
+
+  // If all the defs of the phi are the same constant, we already have the desired end state.
+  // Skip the split that would create empty phi and region nodes.
+  if((r->req() - req_c) == 1) {
+    return NULL;
+  }
+
   if (nb_predicate_proj > 1) {
     // Can happen in case of loop unswitching and when the loop is
     // optimized out: it's not a loop anymore so we don't care about
--- a/test/ProblemList.txt	Thu Mar 09 23:15:59 2017 +0000
+++ b/test/ProblemList.txt	Sat Mar 11 23:23:06 2017 -0800
@@ -79,7 +79,5 @@
 
 # :hotspot_misc
 
-testlibrary_tests/ctw/JarDirTest.java 8172457 windows-all
-
 #############################################################################
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/constantPool/ACCModule52.java	Sat Mar 11 23:23:06 2017 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 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 jdk.internal.org.objectweb.asm.*;
+
+/*
+ * @test
+ * @summary Test that the JVM ignores ACC_MODULE if it is set for a version
+ *          52 class file.
+ * @bug 8175383
+ * @library /test/lib
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @compile -XDignore.symbol.file ACCModule52.java
+ * @run main ACCModule52
+ */
+
+public class ACCModule52 {
+
+    static final String CLASS_NAME = "ACCModule52Pkg";
+
+    public static void main(String[] args) throws Exception {
+        int ACC_MODULE = 0x8000;
+        ClassWriter cw = new ClassWriter(0);
+        cw.visit(Opcodes.V1_8,
+                Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+                CLASS_NAME,
+                null,
+                "java/lang/Object",
+                null);
+
+        cw.visitEnd();
+        byte[] bytes = cw.toByteArray();
+
+
+        ClassLoader loader = new ClassLoader(ACCModule52.class.getClassLoader()) {
+            @Override
+            protected Class<?> findClass(String cn)throws ClassNotFoundException {
+                if (cn.equals(CLASS_NAME)) {
+                    Class superClass = super.defineClass(cn, bytes, 0, bytes.length);
+                } else {
+                    throw new ClassNotFoundException(cn);
+                }
+                return null;
+            }
+        };
+
+        Class<?> clazz = loader.loadClass(CLASS_NAME);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/constantPool/ConstModule.java	Sat Mar 11 23:23:06 2017 -0800
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2017, 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 jdk.internal.org.objectweb.asm.*;
+
+/*
+ * @test
+ * @summary Test scenarios for constant pool CONSTANT_Module and CONSTANT_Package
+ *          types, for class file versions 53 and 52, when ACC_MODULE is set and
+ *          not set in the access_flags.
+ * @bug 8175383
+ * @library /test/lib
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @compile -XDignore.symbol.file ConstModule.java
+ * @run main ConstModule
+ */
+
+public class ConstModule {
+
+    static final int ACC_MODULE = 0x8000;
+    static final boolean MODULE_TEST = true;
+    static final boolean PACKAGE_TEST = false;
+    static final boolean CFE_EXCEPTION = true;
+    static final boolean NCDFE_EXCEPTION = false;
+
+    public static void main(String[] args) throws Exception {
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
+        // class file version 53, when ACC_MODULE is not set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
+            "jdk.fooMod", "FooMod", MODULE_TEST, CFE_EXCEPTION);
+
+        // Test that the JVM throws NCDFE for constant pool CONSTANT_Module type,
+        // for class file version 53, when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC", "FooModACC", MODULE_TEST, NCDFE_EXCEPTION);
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
+        // class file version 52, even when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_8,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC52", "FooModACC52", MODULE_TEST, CFE_EXCEPTION);
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
+        // class file version 53, when ACC_MODULE is not set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
+            "jdk.fooPkg", "FooPkg", PACKAGE_TEST, CFE_EXCEPTION);
+
+        // Test that the JVM throws NCDFE for constant pool CONSTANT_Package type,
+        // for class file version 53, when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC", "FooModACC", PACKAGE_TEST, NCDFE_EXCEPTION);
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
+        // class file version 52, even when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_8,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC52", "FooModACC52", PACKAGE_TEST, CFE_EXCEPTION);
+
+    }
+
+    public static void write_and_load(int version,
+                                      int access_flags,
+                                      String attr,
+                                      String class_name,
+                                      boolean module_test,
+                                      boolean throwCFE) throws Exception {
+        ClassWriter cw = new ClassWriter(0);
+        cw.visit(version,
+                 access_flags,
+                 class_name,
+                 null,
+                 "java/lang/Object",
+                 null);
+
+        if (module_test)
+            cw.visitAttribute(new TestModuleAttribute(attr));
+        else
+            cw.visitAttribute(new TestPackageAttribute(attr));
+
+        cw.visitEnd();
+        byte[] bytes = cw.toByteArray();
+
+
+        ClassLoader loader = new ClassLoader(ConstModule.class.getClassLoader()) {
+            @Override
+            protected Class<?> findClass(String cn)throws ClassNotFoundException {
+                if (cn.equals(class_name)) {
+                    try {
+                        Class superClass = super.defineClass(cn, bytes, 0, bytes.length);
+                        throw new RuntimeException("Expected ClassFormatError not thrown");
+                    } catch (java.lang.ClassFormatError e) {
+                       if (!throwCFE) {
+                           throw new RuntimeException("Unexpected ClassFormatError exception: " + e.getMessage());
+                       }
+                       if (module_test && !e.getMessage().contains(
+                           "Unknown constant tag 19 in class file")) {
+                           throw new RuntimeException("Wrong ClassFormatError exception: " + e.getMessage());
+                       } else if (!module_test && !e.getMessage().contains(
+                           "Unknown constant tag 20 in class file")) {
+                           throw new RuntimeException("Wrong ClassFormatError exception: " + e.getMessage());
+                       }
+                    } catch (java.lang.NoClassDefFoundError f) {
+                       if (throwCFE) {
+                           throw new RuntimeException("Unexpected NoClassDefFoundError exception: " + f.getMessage());
+                       }
+                       if (!f.getMessage().contains(
+                           "is not a class because access_flag ACC_MODULE is set")) {
+                           throw new RuntimeException("Wrong NoClassDefFoundError exception: " + f.getMessage());
+                       }
+                    }
+                } else {
+                    throw new ClassNotFoundException(cn);
+                }
+                return null;
+            }
+        };
+
+        Class<?> clazz = loader.loadClass(class_name);
+    }
+
+    /**
+     * ConstModuleAttr attribute.
+     *
+     * <pre> {@code
+     *
+     * MainClass_attribute {
+     *   // index to CONSTANT_utf8_info structure in constant pool representing
+     *   // the string "ConstModuleAttr"
+     *   u2 attribute_name_index;
+     *   u4 attribute_length;
+     *
+     *   // index to CONSTANT_Module_info structure
+     *   u2 module_name_index
+     * }
+     *
+     * } </pre>
+     */
+    public static class TestModuleAttribute extends Attribute {
+        private final String moduleName;
+
+        public TestModuleAttribute(String moduleName) {
+            super("ConstModuleAttr");
+            this.moduleName = moduleName;
+        }
+
+        public TestModuleAttribute() {
+            this(null);
+        }
+
+        @Override
+        protected Attribute read(ClassReader cr,
+                                 int off,
+                                 int len,
+                                 char[] buf,
+                                 int codeOff,
+                                 Label[] labels)
+        {
+            String mn = cr.readModule(off, buf);
+            off += 2;
+            return new TestModuleAttribute(mn);
+        }
+
+        @Override
+        protected ByteVector write(ClassWriter cw,
+                                   byte[] code,
+                                   int len,
+                                   int maxStack,
+                                   int maxLocals)
+        {
+            ByteVector attr = new ByteVector();
+            attr.putShort(cw.newModule(moduleName));
+            return attr;
+        }
+    }
+
+    /**
+     * ConstPackageAttr attribute.
+     *
+     * <pre> {@code
+     *
+     * MainClass_attribute {
+     *   // index to CONSTANT_utf8_info structure in constant pool representing
+     *   // the string "ConstPackageAttr"
+     *   u2 attribute_name_index;
+     *   u4 attribute_length;
+     *
+     *   // index to CONSTANT_Package_info structure
+     *   u2 module_name_index
+     * }
+     *
+     * } </pre>
+     */
+    public static class TestPackageAttribute extends Attribute {
+        private final String packageName;
+
+        public TestPackageAttribute(String packageName) {
+            super("ConstPackageAttr");
+            this.packageName = packageName;
+        }
+
+        public TestPackageAttribute() {
+            this(null);
+        }
+
+        @Override
+        protected Attribute read(ClassReader cr,
+                                 int off,
+                                 int len,
+                                 char[] buf,
+                                 int codeOff,
+                                 Label[] labels)
+        {
+            String mn = cr.readPackage(off, buf);
+            off += 2;
+            return new TestPackageAttribute(mn);
+        }
+
+        @Override
+        protected ByteVector write(ClassWriter cw,
+                                   byte[] code,
+                                   int len,
+                                   int maxStack,
+                                   int maxLocals)
+        {
+            ByteVector attr = new ByteVector();
+            attr.putShort(cw.newPackage(packageName));
+            return attr;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/duplAttributes/DupSignatureAttrs.jcod	Sat Mar 11 23:23:06 2017 -0800
@@ -0,0 +1,615 @@
+/*
+ * Copyright (c) 2017, 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 containing duplicate Signature attributes.  Loading it should cause a
+// ClassFormatError exception.
+class DupClassSigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [33] { // Constant Pool
+    ; // first element is empty
+    Method #6 #17; // #1     at 0x0A
+    Field #18 #19; // #2     at 0x0F
+    String #20; // #3     at 0x14
+    Method #21 #22; // #4     at 0x17
+    class #23; // #5     at 0x1C
+    class #24; // #6     at 0x1F
+    Utf8 "<init>"; // #7     at 0x22
+    Utf8 "()V"; // #8     at 0x2B
+    Utf8 "Code"; // #9     at 0x31
+    Utf8 "LineNumberTable"; // #10     at 0x38
+    Utf8 "main"; // #11     at 0x4A
+    Utf8 "([Ljava/lang/String;)V"; // #12     at 0x51
+    Utf8 "Exceptions"; // #13     at 0x6A
+    class #25; // #14     at 0x77
+    Utf8 "SourceFile"; // #15     at 0x7A
+    Utf8 "DupClassSigAttrs.java"; // #16     at 0x87
+    NameAndType #7 #8; // #17     at 0x9F
+    class #26; // #18     at 0xA4
+    NameAndType #27 #28; // #19     at 0xA7
+    Utf8 "hi"; // #20     at 0xAC
+    class #29; // #21     at 0xB1
+    NameAndType #30 #31; // #22     at 0xB4
+    Utf8 "DupClassSigAttrs"; // #23     at 0xB9
+    Utf8 "java/lang/Object"; // #24     at 0xCC
+    Utf8 "java/lang/Throwable"; // #25     at 0xDF
+    Utf8 "java/lang/System"; // #26     at 0xF5
+    Utf8 "out"; // #27     at 0x0108
+    Utf8 "Ljava/io/PrintStream;"; // #28     at 0x010E
+    Utf8 "java/io/PrintStream"; // #29     at 0x0126
+    Utf8 "println"; // #30     at 0x013C
+    Utf8 "(Ljava/lang/String;)V"; // #31     at 0x0146
+    Utf8 "Signature"; // #32     at 0x015E
+  } // Constant Pool
+
+  0x0021; // access
+  #5;// this_cpx
+  #6;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [0] { // fields
+  } // fields
+
+  [2] { // methods
+    { // Member at 0x0176
+      0x0001; // access
+      #7; // name_cpx
+      #8; // sig_cpx
+      [1] { // Attributes
+        Attr(#9, 29) { // Code at 0x017E
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 6) { // LineNumberTable at 0x0195
+              [1] { // LineNumberTable
+                0  1; //  at 0x01A1
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x01A1
+      0x0009; // access
+      #11; // name_cpx
+      #12; // sig_cpx
+      [2] { // Attributes
+        Attr(#9, 37) { // Code at 0x01A9
+          2; // max_stack
+          1; // max_locals
+          Bytes[9]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 10) { // LineNumberTable at 0x01C4
+              [2] { // LineNumberTable
+                0  4; //  at 0x01D0
+                8  5; //  at 0x01D4
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#13, 4) { // Exceptions at 0x01D4
+          [1] { // Exceptions
+            #14; //  at 0x01DE
+          }
+        } // end Exceptions
+      } // Attributes
+    } // Member
+  } // methods
+
+  [3] { // Attributes
+    Attr(#15, 2) { // SourceFile at 0x01E0
+      #16;
+    } // end SourceFile
+    ;
+    Attr(#32, 2) { // Signature at 0x01E8
+      #16;
+    } // end Signature
+    ;
+    Attr(#32, 2) { // *** Duplicate *** Signature at 0x01F0
+      #16;
+    } // end Signature
+  } // Attributes
+} // end class DupClassSigAttrs
+
+
+// Class containing a method with duplicate Signature attributes.  Loading it
+// should cause a ClassFormatError exception.
+class DupMthSigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [33] { // Constant Pool
+    ; // first element is empty
+    Method #6 #17; // #1     at 0x0A
+    Field #18 #19; // #2     at 0x0F
+    String #20; // #3     at 0x14
+    Method #21 #22; // #4     at 0x17
+    class #23; // #5     at 0x1C
+    class #24; // #6     at 0x1F
+    Utf8 "<init>"; // #7     at 0x22
+    Utf8 "()V"; // #8     at 0x2B
+    Utf8 "Code"; // #9     at 0x31
+    Utf8 "LineNumberTable"; // #10     at 0x38
+    Utf8 "main"; // #11     at 0x4A
+    Utf8 "([Ljava/lang/String;)V"; // #12     at 0x51
+    Utf8 "Exceptions"; // #13     at 0x6A
+    class #25; // #14     at 0x77
+    Utf8 "SourceFile"; // #15     at 0x7A
+    Utf8 "DupMthSigAttrs.java"; // #16     at 0x87
+    NameAndType #7 #8; // #17     at 0x9D
+    class #26; // #18     at 0xA2
+    NameAndType #27 #28; // #19     at 0xA5
+    Utf8 "hi"; // #20     at 0xAA
+    class #29; // #21     at 0xAF
+    NameAndType #30 #31; // #22     at 0xB2
+    Utf8 "DupMthSigAttrs"; // #23     at 0xB7
+    Utf8 "java/lang/Object"; // #24     at 0xC8
+    Utf8 "java/lang/Throwable"; // #25     at 0xDB
+    Utf8 "java/lang/System"; // #26     at 0xF1
+    Utf8 "out"; // #27     at 0x0104
+    Utf8 "Ljava/io/PrintStream;"; // #28     at 0x010A
+    Utf8 "java/io/PrintStream"; // #29     at 0x0122
+    Utf8 "println"; // #30     at 0x0138
+    Utf8 "(Ljava/lang/String;)V"; // #31     at 0x0142
+    Utf8 "Signature"; // #32     at 0x015A
+  } // Constant Pool
+
+  0x0021; // access
+  #5;// this_cpx
+  #6;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [0] { // fields
+  } // fields
+
+  [2] { // methods
+    { // Member at 0x0172
+      0x0001; // access
+      #7; // name_cpx
+      #8; // sig_cpx
+      [1] { // Attributes
+        Attr(#9, 29) { // Code at 0x017A
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 6) { // LineNumberTable at 0x0191
+              [1] { // LineNumberTable
+                0  1; //  at 0x019D
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x019D
+      0x0009; // access
+      #11; // name_cpx
+      #12; // sig_cpx
+      [4] { // Attributes
+        Attr(#9, 37) { // Code at 0x01A5
+          2; // max_stack
+          1; // max_locals
+          Bytes[9]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 10) { // LineNumberTable at 0x01C0
+              [2] { // LineNumberTable
+                0  4; //  at 0x01CC
+                8  5; //  at 0x01D0
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#32, 2) { // Signature at 0x01D0
+          #16;
+        } // end Signature
+        ;
+        Attr(#13, 4) { // Exceptions at 0x01D8
+          [1] { // Exceptions
+            #14; //  at 0x01E2
+          }
+        } // end Exceptions
+        ;
+        Attr(#32, 2) { // *** Duplicate *** Signature at 0x01E2
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+  } // methods
+
+  [1] { // Attributes
+    Attr(#15, 2) { // SourceFile at 0x01EC
+      #16;
+    } // end SourceFile
+  } // Attributes
+} // end class DupMthSigAttrs
+
+
+// Class containing a field with duplicate Signature attributes.  Loading it
+// should cause a ClassFormatError exception.
+class DupFldSigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [42] { // Constant Pool
+    ; // first element is empty
+    Method #9 #23; // #1     at 0x0A
+    Field #24 #25; // #2     at 0x0F
+    Field #8 #26; // #3     at 0x14
+    Method #27 #28; // #4     at 0x19
+    class #29; // #5     at 0x1E
+    String #30; // #6     at 0x21
+    Method #5 #31; // #7     at 0x24
+    class #32; // #8     at 0x29
+    class #33; // #9     at 0x2C
+    Utf8 "str"; // #10     at 0x2F
+    Utf8 "Ljava/lang/String;"; // #11     at 0x35
+    Utf8 "<init>"; // #12     at 0x4A
+    Utf8 "()V"; // #13     at 0x53
+    Utf8 "Code"; // #14     at 0x59
+    Utf8 "LineNumberTable"; // #15     at 0x60
+    Utf8 "main"; // #16     at 0x72
+    Utf8 "([Ljava/lang/String;)V"; // #17     at 0x79
+    Utf8 "Exceptions"; // #18     at 0x92
+    class #34; // #19     at 0x9F
+    Utf8 "<clinit>"; // #20     at 0xA2
+    Utf8 "SourceFile"; // #21     at 0xAD
+    Utf8 "DupFldSigAttrs.java"; // #22     at 0xBA
+    NameAndType #12 #13; // #23     at 0xD0
+    class #35; // #24     at 0xD5
+    NameAndType #36 #37; // #25     at 0xD8
+    NameAndType #10 #11; // #26     at 0xDD
+    class #38; // #27     at 0xE2
+    NameAndType #39 #40; // #28     at 0xE5
+    Utf8 "java/lang/String"; // #29     at 0xEA
+    Utf8 "Hi"; // #30     at 0xFD
+    NameAndType #12 #40; // #31     at 0x0102
+    Utf8 "DupFldSigAttrs"; // #32     at 0x0107
+    Utf8 "java/lang/Object"; // #33     at 0x0118
+    Utf8 "java/lang/Throwable"; // #34     at 0x012B
+    Utf8 "java/lang/System"; // #35     at 0x0141
+    Utf8 "out"; // #36     at 0x0154
+    Utf8 "Ljava/io/PrintStream;"; // #37     at 0x015A
+    Utf8 "java/io/PrintStream"; // #38     at 0x0172
+    Utf8 "println"; // #39     at 0x0188
+    Utf8 "(Ljava/lang/String;)V"; // #40     at 0x0192
+    Utf8 "Signature"; // #41     at 0x01AA
+  } // Constant Pool
+
+  0x0021; // access
+  #8;// this_cpx
+  #9;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [1] { // fields
+    { // Member at 0x01C0
+      0x0008; // access
+      #10; // name_cpx
+      #11; // sig_cpx
+      [2] { // Attributes
+        Attr(#41, 2) { // Signature at 0x01C8
+          #16;
+        } // end Signature
+        ;
+        Attr(#41, 2) { // *** Duplicate *** Signature at 0x01D0
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+  } // fields
+
+  [3] { // methods
+    { // Member at 0x01DA
+      0x0001; // access
+      #12; // name_cpx
+      #13; // sig_cpx
+      [1] { // Attributes
+        Attr(#14, 29) { // Code at 0x01E2
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x01F9
+              [1] { // LineNumberTable
+                0  1; //  at 0x0205
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0205
+      0x0009; // access
+      #16; // name_cpx
+      #17; // sig_cpx
+      [2] { // Attributes
+        Attr(#14, 38) { // Code at 0x020D
+          2; // max_stack
+          1; // max_locals
+          Bytes[10]{
+            0xB20002B20003B600;
+            0x04B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 10) { // LineNumberTable at 0x0229
+              [2] { // LineNumberTable
+                0  6; //  at 0x0235
+                9  7; //  at 0x0239
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#18, 4) { // Exceptions at 0x0239
+          [1] { // Exceptions
+            #19; //  at 0x0243
+          }
+        } // end Exceptions
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0243
+      0x0008; // access
+      #20; // name_cpx
+      #13; // sig_cpx
+      [1] { // Attributes
+        Attr(#14, 37) { // Code at 0x024B
+          3; // max_stack
+          0; // max_locals
+          Bytes[13]{
+            0xBB0005591206B700;
+            0x07B30003B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x026A
+              [1] { // LineNumberTable
+                0  3; //  at 0x0276
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [1] { // Attributes
+    Attr(#21, 2) { // SourceFile at 0x0278
+      #22;
+    } // end SourceFile
+  } // Attributes
+} // end class DupFldSigAttrs
+
+
+// Class containing a Signature attribute and a field and methods with Signature
+// attributes.  Since neither the class nor any of its fields or methods have
+// duplicate Signature attributes, loading this class should not cause a
+// ClassFormatError exception.
+class OkaySigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [42] { // Constant Pool
+    ; // first element is empty
+    Method #9 #23; // #1     at 0x0A
+    Field #24 #25; // #2     at 0x0F
+    Field #8 #26; // #3     at 0x14
+    Method #27 #28; // #4     at 0x19
+    class #29; // #5     at 0x1E
+    String #30; // #6     at 0x21
+    Method #5 #31; // #7     at 0x24
+    class #32; // #8     at 0x29
+    class #33; // #9     at 0x2C
+    Utf8 "str"; // #10     at 0x2F
+    Utf8 "Ljava/lang/String;"; // #11     at 0x35
+    Utf8 "<init>"; // #12     at 0x4A
+    Utf8 "()V"; // #13     at 0x53
+    Utf8 "Code"; // #14     at 0x59
+    Utf8 "LineNumberTable"; // #15     at 0x60
+    Utf8 "main"; // #16     at 0x72
+    Utf8 "([Ljava/lang/String;)V"; // #17     at 0x79
+    Utf8 "Exceptions"; // #18     at 0x92
+    class #34; // #19     at 0x9F
+    Utf8 "<clinit>"; // #20     at 0xA2
+    Utf8 "SourceFile"; // #21     at 0xAD
+    Utf8 "OkaySigAttrs.java"; // #22     at 0xBA
+    NameAndType #12 #13; // #23     at 0xCE
+    class #35; // #24     at 0xD3
+    NameAndType #36 #37; // #25     at 0xD6
+    NameAndType #10 #11; // #26     at 0xDB
+    class #38; // #27     at 0xE0
+    NameAndType #39 #40; // #28     at 0xE3
+    Utf8 "java/lang/String"; // #29     at 0xE8
+    Utf8 "Hi"; // #30     at 0xFB
+    NameAndType #12 #40; // #31     at 0x0100
+    Utf8 "OkaySigAttrs"; // #32     at 0x0105
+    Utf8 "java/lang/Object"; // #33     at 0x0114
+    Utf8 "java/lang/Throwable"; // #34     at 0x0127
+    Utf8 "java/lang/System"; // #35     at 0x013D
+    Utf8 "out"; // #36     at 0x0150
+    Utf8 "Ljava/io/PrintStream;"; // #37     at 0x0156
+    Utf8 "java/io/PrintStream"; // #38     at 0x016E
+    Utf8 "println"; // #39     at 0x0184
+    Utf8 "(Ljava/lang/String;)V"; // #40     at 0x018E
+    Utf8 "Signature"; // #41     at 0x01A6
+  } // Constant Pool
+
+  0x0021; // access
+  #8;// this_cpx
+  #9;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [1] { // fields
+    { // Member at 0x01BC
+      0x0008; // access
+      #10; // name_cpx
+      #11; // sig_cpx
+      [1] { // Attributes
+        Attr(#41, 2) { // Signature at 0x01C4
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+  } // fields
+
+  [3] { // methods
+    { // Member at 0x01CE
+      0x0001; // access
+      #12; // name_cpx
+      #13; // sig_cpx
+      [2] { // Attributes
+        Attr(#14, 29) { // Code at 0x01D6
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x01ED
+              [1] { // LineNumberTable
+                0  1; //  at 0x01F9
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#41, 2) { // Signature at 0x01F9
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0201
+      0x0009; // access
+      #16; // name_cpx
+      #17; // sig_cpx
+      [3] { // Attributes
+        Attr(#14, 38) { // Code at 0x0209
+          2; // max_stack
+          1; // max_locals
+          Bytes[10]{
+            0xB20002B20003B600;
+            0x04B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 10) { // LineNumberTable at 0x0225
+              [2] { // LineNumberTable
+                0  6; //  at 0x0231
+                9  7; //  at 0x0235
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#41, 2) { // Signature at 0x0235
+          #16;
+        } // end Signature
+        ;
+        Attr(#18, 4) { // Exceptions at 0x023D
+          [1] { // Exceptions
+            #19; //  at 0x0247
+          }
+        } // end Exceptions
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0247
+      0x0008; // access
+      #20; // name_cpx
+      #13; // sig_cpx
+      [1] { // Attributes
+        Attr(#14, 37) { // Code at 0x024F
+          3; // max_stack
+          0; // max_locals
+          Bytes[13]{
+            0xBB0005591206B700;
+            0x07B30003B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x026E
+              [1] { // LineNumberTable
+                0  3; //  at 0x027A
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [2] { // Attributes
+    Attr(#21, 2) { // SourceFile at 0x027C
+      #22;
+    } // end SourceFile
+    ;
+    Attr(#41, 2) { // Signature at 0x0284
+      #16;
+    } // end Signature
+  } // Attributes
+} // end class OkaySigAttrs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/duplAttributes/TestDupSignatureAttr.java	Sat Mar 11 23:23:06 2017 -0800
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017, 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 8176147
+ * @summary Throw ClassFormatError exception for multiple Signature attributes
+ * @compile DupSignatureAttrs.jcod
+ * @run main TestDupSignatureAttr
+ */
+
+public class TestDupSignatureAttr {
+    public static void main(String args[]) throws Throwable {
+
+        System.out.println("Regression test for bug 8176147");
+
+        String[] badClasses = new String[] {
+            "DupClassSigAttrs",
+            "DupMthSigAttrs",
+            "DupFldSigAttrs",
+        };
+        String[] messages = new String[] {
+            "Multiple Signature attributes in class file",
+            "Multiple Signature attributes for method",
+            "Multiple Signature attributes for field",
+        };
+
+        for (int x = 0; x < badClasses.length; x++) {
+            try {
+                Class newClass = Class.forName(badClasses[x]);
+                throw new RuntimeException("Expected ClassFormatError exception not thrown");
+            } catch (java.lang.ClassFormatError e) {
+                if (!e.getMessage().contains(messages[x])) {
+                    throw new RuntimeException("Wrong ClassFormatError exception thrown: " +
+                                               e.getMessage());
+                }
+            }
+        }
+
+        // Multiple Signature attributes but no duplicates.
+        Class newClass = Class.forName("OkaySigAttrs");
+    }
+}
--- a/test/testlibrary_tests/ctw/CtwTest.java	Thu Mar 09 23:15:59 2017 +0000
+++ b/test/testlibrary_tests/ctw/CtwTest.java	Sat Mar 11 23:23:06 2017 -0800
@@ -37,6 +37,7 @@
 import java.nio.file.StandardCopyOption;
 import java.nio.charset.Charset;
 
+import jdk.test.lib.Platform;
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
@@ -93,7 +94,12 @@
         // concat CTW_COMMAND and args w/o 0th element
         String[] cmd = Arrays.copyOf(CTW_COMMAND, CTW_COMMAND.length + args.length - 1);
         System.arraycopy(args, 1, cmd, CTW_COMMAND.length, args.length - 1);
-
+        if (Platform.isWindows()) {
+            // '*' has to be escaped on windows
+            for (int i = 0; i < cmd.length; ++i) {
+                cmd[i] = cmd[i].replace("*", "\"*\"");
+            }
+        }
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd);
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         dump(output, "compile");