--- old/src/java.base/share/classes/java/lang/Class.java 2018-05-22 05:25:44.886850513 -0400
+++ new/src/java.base/share/classes/java/lang/Class.java 2018-05-22 05:25:43.398764449 -0400
@@ -3854,8 +3854,8 @@
/**
* Returns the nest host of the object represented by this {@code Class}.
*
- *
If there is any error accessing the nest host, or the nest host is
- * in any way invalid, then {@code this} is returned.
+ *
If there is any {@linkplain LinkageError linkage error} accessing the nest host,
+ * or the nest host is in any way invalid, then {@code this} is returned.
*
*
A nest is a set of classes and interfaces (nestmates) that
* form an access control context in which each nestmate has access to the
@@ -3863,8 +3863,10 @@
* The nest host is the class or interface designated to hold the list of
* classes and interfaces that make up the nest, and to which each of the
* other nestmates refer.
+ * All nestmates are implicitly defined in the same runtime package.
*
- *
A class or interface that is not explicitly a member of a nest,
+ *
A class or interface that is not explicitly a member of a nest
+ * (such as a primitive or array class),
* is a member of the nest consisting only of itself, and is the
* nest host. Every class and interface is a member of exactly one nest.
*
@@ -3878,8 +3880,8 @@
* The top-level {@linkplain #getEnclosingClass() enclosing class or interface}
* is designated as the nest host.
*
- * @return the nest host of this class, or {@code this} if we cannot
- * obtain a valid nest host
+ * @return the nest host of this class, or {@code this} if a valid nest host
+ * cannot be obtained
* @throws SecurityException
* If the returned class is not the current class, and
* if a security manager, s, is present and the caller's
@@ -3920,7 +3922,7 @@
/**
* Determines if the given {@code Class} is a nestmate of the
* object represented by this {@code Class}. Two classes are nestmates
- * if they have the same {@linkplain #getNestHost nest host}.
+ * if they have the same {@linkplain #getNestHost() nest host}.
*
* @param c the class to check
* @return {@code true} if this class and {@code c} are valid members of the same
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/HostOfMemberMalformedHost.jcod 2018-05-22 05:25:50.307164001 -0400
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to class with invalid class file format
+
+class HostOfMemberMalformedHost$MemberMalformedHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "Hosts.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "HostOfMemberMalformedHost$MemberMalformedHost"; // #13
+ Utf8 "MemberMalformedHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "HostOfMemberMalformedHost"; // #17
+ // added
+ Utf8 "MalformedHost"; // #18
+ class #18; // #19
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 68;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#10) { // NestHost
+ 0x0013; // Modified #19
+ } // end NestHost
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class HostOfMemberMalformedHost$MemberMalformedHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/HostOfMemberMissingHost.jcod 2018-05-22 05:25:57.051554067 -0400
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to non-existent class
+
+class HostOfMemberMissingHost$MemberMissingHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "Hosts.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "HostOfMemberMissingHost$MemberMissingHost"; // #13
+ Utf8 "MemberMissingHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "HostOfMemberMissingHost"; // #17
+ class #10; // #18 - added
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 60;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#10) { // NestHost
+ 0x0012; // modified
+ } // end NestHost
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class HostOfMemberMissingHost$MemberMissingHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/HostOfMemberNoHost.jcod 2018-05-22 05:26:03.815945289 -0400
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute deleted
+
+class HostOfMemberNoHost$MemberNoHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "Hosts.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "HostOfMemberNoHost$MemberNoHost"; // #13
+ Utf8 "MemberNoHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "HostOfMemberNoHost"; // #17
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 57;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class HostOfMemberNoHost$MemberNoHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/HostOfMemberNotInstanceHost.jcod 2018-05-22 05:26:10.628339287 -0400
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to non-instance class
+
+class HostOfMemberNotInstanceHost$MemberNotInstanceHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #14; // #1
+ class #15; // #2
+ class #18; // #3
+ Utf8 "oa"; // #4
+ Utf8 "[LInvalidNestHost;"; // #5
+ Utf8 ""; // #6
+ Utf8 "()V"; // #7
+ Utf8 "Code"; // #8
+ Utf8 "LineNumberTable"; // #9
+ Utf8 "SourceFile"; // #10
+ Utf8 "Hosts.java"; // #11
+ Utf8 "NestHost"; // #12
+ class #19; // #13
+ NameAndType #6 #7; // #14
+ Utf8 "HostOfMemberNotInstanceHost$MemberNotInstanceHost"; // #15
+ Utf8 "MemberNotInstanceHost"; // #16
+ Utf8 "InnerClasses"; // #17
+ Utf8 "java/lang/Object"; // #18
+ Utf8 "HostOfMemberNotInstanceHost"; // #19
+ class #5; // #20 - added
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ { // Member
+ 0x0000; // access
+ #4; // name_cpx
+ #5; // sig_cpx
+ [] { // Attributes
+ } // Attributes
+ } // Member
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // access
+ #6; // name_cpx
+ #7; // sig_cpx
+ [] { // Attributes
+ Attr(#8) { // Code
+ 1; // max_stack
+ 1; // max_locals
+ Bytes[]{
+ 0x2AB70001B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#9) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 63;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#10) { // SourceFile
+ #11;
+ } // end SourceFile
+ ;
+ Attr(#12) { // NestHost
+ 0x0014; // Modified #20
+ } // end NestHost
+ ;
+ Attr(#17) { // InnerClasses
+ [] { // InnerClasses
+ #2 #13 #16 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class HostOfMemberNotInstanceHost$MemberNotInstanceHost
+
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/HostOfMemberNotOurHost.jcod 2018-05-22 05:26:17.300725188 -0400
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to class with no nest
+
+class HostOfMemberNotOurHost$MemberNotOurHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "Hosts.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "HostOfMemberNotOurHost$MemberNotOurHost"; // #13
+ Utf8 "MemberNotOurHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "HostOfMemberNotOurHost"; // #17
+ // Added
+ Utf8 "InvalidNestHost"; // #18
+ class #18; // #19
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 68;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#10) { // NestHost
+ 0x0013; // Modified #19
+ } // end NestHost
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class HostOfMemberNotOurHost$MemberNotOurHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/HostWithDuplicateMembers.jcod 2018-05-22 05:26:24.873163142 -0400
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+// Modify NestMembers attribute to contain multiple duplicates
+
+class HostWithDuplicateMembers {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #16; // #1
+ class #17; // #2
+ class #18; // #3
+ class #19; // #4
+ Utf8 "Member2"; // #5
+ Utf8 "InnerClasses"; // #6
+ class #20; // #7
+ Utf8 "Member1"; // #8
+ Utf8 ""; // #9
+ Utf8 "()V"; // #10
+ Utf8 "Code"; // #11
+ Utf8 "LineNumberTable"; // #12
+ Utf8 "SourceFile"; // #13
+ Utf8 "Hosts.java"; // #14
+ Utf8 "NestMembers"; // #15
+ NameAndType #9 #10; // #16
+ Utf8 "HostWithDuplicateMembers"; // #17
+ Utf8 "java/lang/Object"; // #18
+ Utf8 "HostWithDuplicateMembers$Member2"; // #19
+ Utf8 "HostWithDuplicateMembers$Member1"; // #20
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // access
+ #9; // name_cpx
+ #10; // sig_cpx
+ [] { // Attributes
+ Attr(#11) { // Code
+ 1; // max_stack
+ 1; // max_locals
+ Bytes[]{
+ 0x2AB70001B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#12) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 60;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#13) { // SourceFile
+ #14;
+ } // end SourceFile
+ ;
+ Attr(#15) { // NestMembers
+ 0x0006000700040007; // modified
+ 0x000400070004;
+ } // end NestMembers
+ ;
+ Attr(#6) { // InnerClasses
+ [] { // InnerClasses
+ #4 #2 #5 1544;
+ #7 #2 #8 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class HostWithDuplicateMembers
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/HostWithSelfMember.jcod 2018-05-22 05:26:31.577550891 -0400
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+// Modify NestMembers attribute to include reference to the currnet class
+
+class HostWithSelfMember {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #14; // #1
+ class #15; // #2
+ class #16; // #3
+ class #17; // #4
+ Utf8 "Member"; // #5
+ Utf8 "InnerClasses"; // #6
+ Utf8 ""; // #7
+ Utf8 "()V"; // #8
+ Utf8 "Code"; // #9
+ Utf8 "LineNumberTable"; // #10
+ Utf8 "SourceFile"; // #11
+ Utf8 "Hosts.java"; // #12
+ Utf8 "NestMembers"; // #13
+ NameAndType #7 #8; // #14
+ Utf8 "HostWithSelfMember"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "HostWithSelfMember$Member"; // #17
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // access
+ #7; // name_cpx
+ #8; // sig_cpx
+ [] { // Attributes
+ Attr(#9) { // Code
+ 1; // max_stack
+ 1; // max_locals
+ Bytes[]{
+ 0x2AB70001B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#10) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 55;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#11) { // SourceFile
+ #12;
+ } // end SourceFile
+ ;
+ Attr(#13) { // NestMembers
+ 0x000200040002; // modified - added self
+ } // end NestMembers
+ ;
+ Attr(#6) { // InnerClasses
+ [] { // InnerClasses
+ #4 #2 #5 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class HostWithSelfMember
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/Hosts.java 2018-05-22 05:26:38.741965246 -0400
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// Non-public classes so we can keep them all in this one source file
+
+class HostOfMemberNoHost {
+ // Missing NestHost attribute
+ static class MemberNoHost {}
+}
+
+class HostOfMemberMissingHost {
+ // Missing NestHost class
+ static class MemberMissingHost {}
+}
+
+class HostOfMemberNotInstanceHost {
+ // Invalid NestHost class (not instance class)
+ static class MemberNotInstanceHost {
+ Object[] oa; // create CP entry to use in jcod change
+ }
+}
+
+class HostOfMemberNotOurHost {
+ // Valid but different NestHost class
+ static class MemberNotOurHost {}
+}
+
+class HostOfMemberMalformedHost {
+ // Malformed NestHost class
+ static class MemberMalformedHost {}
+}
+
+// Host lists itself as a member along
+// with real member.
+class HostWithSelfMember {
+ static class Member {}
+}
+
+// Host lists duplicate members.
+class HostWithDuplicateMembers {
+ static class Member1 {}
+ static interface Member2 {}
+}
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/InvalidNestHost.java 2018-05-22 05:26:45.470354385 -0400
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+/* Empty class to use as an invalid nest-host class, in the same package as
+ * the test classes.
+ */
+public class InvalidNestHost {
+}
+
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/MalformedHost.jcod 2018-05-22 05:26:52.238745836 -0400
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// Invalid class file format
+
+class MalformedHost {
+ 0xDEADBEEF; // bad magic number
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "MemberMalformedHost"; // #14
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "TestReflectionAPI"; // #17
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 68;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ } // Attributes
+} // end class MalformedHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/MemberMalformedHost.jcod 2018-05-22 05:26:58.963134741 -0400
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to class with invalid class file format
+
+class TestReflectionAPI$MemberMalformedHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "TestReflectionAPI.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "TestReflectionAPI$MemberMalformedHost"; // #13
+ Utf8 "MemberMalformedHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "TestReflectionAPI"; // #17
+ // added
+ Utf8 "MalformedHost"; // #18
+ class #18; // #19
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 68;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#10) { // NestHost
+ 0x0013; // Modified #19
+ } // end NestHost
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class TestReflectionAPI$MemberMalformedHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/MemberMissingHost.jcod 2018-05-22 05:27:05.751527348 -0400
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to non-existent class
+
+class TestReflectionAPI$MemberMissingHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "TestReflectionAPI.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "TestReflectionAPI$MemberMissingHost"; // #13
+ Utf8 "MemberMissingHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "TestReflectionAPI"; // #17
+ class #10; // #18 - added
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 60;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#10) { // NestHost
+ 0x0012; // modified
+ } // end NestHost
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class TestReflectionAPI$MemberMissingHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/MemberNoHost.jcod 2018-05-22 05:27:12.439914170 -0400
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute deleted
+
+class TestReflectionAPI$MemberNoHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "TestReflectionAPI.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "TestReflectionAPI$MemberNoHost"; // #13
+ Utf8 "MemberNoHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "TestReflectionAPI"; // #17
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 57;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class TestReflectionAPI$MemberNoHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/MemberNotInstanceHost.jcod 2018-05-22 05:27:19.188304463 -0400
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to non-instance class
+
+class TestReflectionAPI$MemberNotInstanceHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #14; // #1
+ class #15; // #2
+ class #18; // #3
+ Utf8 "oa"; // #4
+ Utf8 "[LInvalidNestHost;"; // #5
+ Utf8 ""; // #6
+ Utf8 "()V"; // #7
+ Utf8 "Code"; // #8
+ Utf8 "LineNumberTable"; // #9
+ Utf8 "SourceFile"; // #10
+ Utf8 "TestReflectionAPI.java"; // #11
+ Utf8 "NestHost"; // #12
+ class #19; // #13
+ NameAndType #6 #7; // #14
+ Utf8 "TestReflectionAPI$MemberNotInstanceHost"; // #15
+ Utf8 "MemberNotInstanceHost"; // #16
+ Utf8 "InnerClasses"; // #17
+ Utf8 "java/lang/Object"; // #18
+ Utf8 "TestReflectionAPI"; // #19
+ class #5; // #20 - added
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ { // Member
+ 0x0000; // access
+ #4; // name_cpx
+ #5; // sig_cpx
+ [] { // Attributes
+ } // Attributes
+ } // Member
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // access
+ #6; // name_cpx
+ #7; // sig_cpx
+ [] { // Attributes
+ Attr(#8) { // Code
+ 1; // max_stack
+ 1; // max_locals
+ Bytes[]{
+ 0x2AB70001B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#9) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 63;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#10) { // SourceFile
+ #11;
+ } // end SourceFile
+ ;
+ Attr(#12) { // NestHost
+ 0x0014; // Modified #20
+ } // end NestHost
+ ;
+ Attr(#17) { // InnerClasses
+ [] { // InnerClasses
+ #2 #13 #16 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class TestReflectionAPI$MemberNotInstanceHost
+
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/MemberNotOurHost.jcod 2018-05-22 05:27:26.660736629 -0400
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute refers to class with no nest
+
+class TestReflectionAPI$MemberNotOurHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #3 #12; // #1
+ class #13; // #2
+ class #16; // #3
+ Utf8 ""; // #4
+ Utf8 "()V"; // #5
+ Utf8 "Code"; // #6
+ Utf8 "LineNumberTable"; // #7
+ Utf8 "SourceFile"; // #8
+ Utf8 "TestReflectionAPI.java"; // #9
+ Utf8 "NestHost"; // #10
+ class #17; // #11
+ NameAndType #4 #5; // #12
+ Utf8 "TestReflectionAPI$MemberNotOurHost"; // #13
+ Utf8 "MemberNotOurHost"; // #14
+ Utf8 "InnerClasses"; // #15
+ Utf8 "java/lang/Object"; // #16
+ Utf8 "TestReflectionAPI"; // #17
+ // Added
+ Utf8 "InvalidNestHost"; // #18
+ class #18; // #19
+ } // Constant Pool
+
+ 0x0020; // access
+ #2;// this_cpx
+ #3;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0000; // 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) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 68;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#8) { // SourceFile
+ #9;
+ } // end SourceFile
+ ;
+ Attr(#10) { // NestHost
+ 0x0013; // Modified #19
+ } // end NestHost
+ ;
+ Attr(#15) { // InnerClasses
+ [] { // InnerClasses
+ #2 #11 #14 8;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class TestReflectionAPI$MemberNotOurHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/PackagedNestHost.java 2018-05-22 05:27:33.437128540 -0400
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package P1;
+
+/*
+ * This is used to produce a jcod file in which we modify the
+ * NestMembers attribute to claim that P2.PackagedNestHost.Member
+ * is a member of our nest.
+ */
+public class PackagedNestHost {
+ public static class Member { }
+}
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/PackagedNestHost.jcod 2018-05-22 05:27:40.617543817 -0400
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestMembers attribute is modified to contain P2.PackagedNestHost2.Member
+
+class P1/PackagedNestHost {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #4 #16; // #1
+ Method #17 #18; // #2
+ class #19; // #3
+ class #20; // #4
+ class #21; // #5
+ Utf8 "Member"; // #6
+ Utf8 "InnerClasses"; // #7
+ Utf8 ""; // #8
+ Utf8 "()V"; // #9
+ Utf8 "Code"; // #10
+ Utf8 "LineNumberTable"; // #11
+ Utf8 "doAccess"; // #12
+ Utf8 "SourceFile"; // #13
+ Utf8 "PackagedNestHost.java"; // #14
+ Utf8 "NestMembers"; // #15
+ NameAndType #8 #9; // #16
+ class #23; // #17
+ NameAndType #24 #9; // #18
+ Utf8 "P1/PackagedNestHost"; // #19
+ Utf8 "java/lang/Object"; // #20
+ Utf8 "P1/PackagedNestHost$Member"; // #21
+ class #25; // #22
+ Utf8 "P2/PackagedNestHost2$Member"; // #23
+ Utf8 "m"; // #24
+ Utf8 "P2/PackagedNestHost2"; // #25
+ } // Constant Pool
+
+ 0x0021; // access
+ #3;// this_cpx
+ #4;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0001; // access
+ #8; // name_cpx
+ #9; // sig_cpx
+ [] { // Attributes
+ Attr(#10) { // Code
+ 1; // max_stack
+ 1; // max_locals
+ Bytes[]{
+ 0x2AB70001B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#11) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 31;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ ;
+ { // Member
+ 0x0009; // access
+ #12; // name_cpx
+ #9; // sig_cpx
+ [] { // Attributes
+ Attr(#10) { // Code
+ 0; // max_stack
+ 0; // max_locals
+ Bytes[]{
+ 0xB80002B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#11) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 44;
+ 3 45;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#13) { // SourceFile
+ #14;
+ } // end SourceFile
+ ;
+ Attr(#15) { // NestMembers
+ 0x00010011; // modified - #17
+ } // end NestMembers
+ ;
+ Attr(#7) { // InnerClasses
+ [] { // InnerClasses
+ #5 #3 #6 9;
+ #17 #22 #6 9;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class P1/PackagedNestHost
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/PackagedNestHost2.java 2018-05-22 05:27:47.329932024 -0400
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package P2;
+
+/*
+ * This is used to produce a jcod file in which we modify the
+ * NestHost attribute to claim that P2.PackagedNestHost.Member
+ * is a member of the nest of P1.PackagedNestHost.
+ */
+public class PackagedNestHost2 {
+ public static class Member { }
+}
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/PackagedNestHost2Member.jcod 2018-05-22 05:27:54.126325091 -0400
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// NestHost attribute is modified to contain P1.PackagedNestHost
+// m() is declared private
+
+class P2/PackagedNestHost2$Member {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #7 #18; // #1
+ Field #19 #20; // #2
+ String #21; // #3
+ Method #22 #23; // #4
+ Method #24 #25; // #5
+ class #26; // #6
+ class #29; // #7
+ Utf8 ""; // #8
+ Utf8 "()V"; // #9
+ Utf8 "Code"; // #10
+ Utf8 "LineNumberTable"; // #11
+ Utf8 "m"; // #12
+ Utf8 "doAccess"; // #13
+ Utf8 "SourceFile"; // #14
+ Utf8 "PackagedNestHost2.java"; // #15
+ Utf8 "NestHost"; // #16
+ class #30; // #17
+ NameAndType #8 #9; // #18
+ class #31; // #19
+ NameAndType #32 #33; // #20
+ Utf8 "You should never see this!"; // #21
+ class #34; // #22
+ NameAndType #35 #36; // #23
+ class #38; // #24
+ NameAndType #12 #9; // #25
+ Utf8 "P2/PackagedNestHost2$Member"; // #26
+ Utf8 "Member"; // #27
+ Utf8 "InnerClasses"; // #28
+ Utf8 "java/lang/Object"; // #29
+ Utf8 "P2/PackagedNestHost2"; // #30
+ Utf8 "java/lang/System"; // #31
+ Utf8 "out"; // #32
+ Utf8 "Ljava/io/PrintStream;"; // #33
+ Utf8 "java/io/PrintStream"; // #34
+ Utf8 "println"; // #35
+ Utf8 "(Ljava/lang/String;)V"; // #36
+ class #39; // #37
+ Utf8 "P1/PackagedNestHost$Member"; // #38
+ Utf8 "P1/PackagedNestHost"; // #39
+ } // Constant Pool
+
+ 0x0021; // access
+ #6;// this_cpx
+ #7;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0001; // access
+ #8; // name_cpx
+ #9; // sig_cpx
+ [] { // Attributes
+ Attr(#10) { // Code
+ 1; // max_stack
+ 1; // max_locals
+ Bytes[]{
+ 0x2AB70001B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#11) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 32;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ ;
+ { // Member
+ 0x000A; // access - modified
+ #12; // name_cpx
+ #9; // sig_cpx
+ [] { // Attributes
+ Attr(#10) { // Code
+ 2; // max_stack
+ 0; // max_locals
+ Bytes[]{
+ 0xB200021203B60004;
+ 0xB1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#11) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 35;
+ 8 36;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ ;
+ { // Member
+ 0x0009; // access
+ #13; // name_cpx
+ #9; // sig_cpx
+ [] { // Attributes
+ Attr(#10) { // Code
+ 0; // max_stack
+ 0; // max_locals
+ Bytes[]{
+ 0xB80005B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#11) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 42;
+ 3 43;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#14) { // SourceFile
+ #15;
+ } // end SourceFile
+ ;
+ Attr(#16) { // NestHost
+ 0x0025; // modified - #37
+ } // end NestHost
+ ;
+ Attr(#28) { // InnerClasses
+ [] { // InnerClasses
+ #6 #17 #27 9;
+ #24 #37 #27 9;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class P2/PackagedNestHost2$Member
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/PackagedNestHostMember.jcod 2018-05-22 05:28:00.838713299 -0400
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2017, 2018, 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.
+ */
+
+// m() is declared private
+
+class P1/PackagedNestHost$Member {
+ 0xCAFEBABE;
+ 0; // minor version
+ 55; // version
+ [] { // Constant Pool
+ ; // first element is empty
+ Method #6 #16; // #1
+ Field #17 #18; // #2
+ String #19; // #3
+ Method #20 #21; // #4
+ class #22; // #5
+ class #25; // #6
+ Utf8 ""; // #7
+ Utf8 "()V"; // #8
+ Utf8 "Code"; // #9
+ Utf8 "LineNumberTable"; // #10
+ Utf8 "m"; // #11
+ Utf8 "SourceFile"; // #12
+ Utf8 "PackagedNestHost.java"; // #13
+ Utf8 "NestHost"; // #14
+ class #26; // #15
+ NameAndType #7 #8; // #16
+ class #27; // #17
+ NameAndType #28 #29; // #18
+ Utf8 "You should never see this!"; // #19
+ class #30; // #20
+ NameAndType #31 #32; // #21
+ Utf8 "P1/PackagedNestHost$Member"; // #22
+ Utf8 "Member"; // #23
+ Utf8 "InnerClasses"; // #24
+ Utf8 "java/lang/Object"; // #25
+ Utf8 "P1/PackagedNestHost"; // #26
+ Utf8 "java/lang/System"; // #27
+ Utf8 "out"; // #28
+ Utf8 "Ljava/io/PrintStream;"; // #29
+ Utf8 "java/io/PrintStream"; // #30
+ Utf8 "println"; // #31
+ Utf8 "(Ljava/lang/String;)V"; // #32
+ } // Constant Pool
+
+ 0x0021; // access
+ #5;// this_cpx
+ #6;// super_cpx
+
+ [] { // Interfaces
+ } // Interfaces
+
+ [] { // fields
+ } // fields
+
+ [] { // methods
+ { // Member
+ 0x0001; // access
+ #7; // name_cpx
+ #8; // sig_cpx
+ [] { // Attributes
+ Attr(#9) { // Code
+ 1; // max_stack
+ 1; // max_locals
+ Bytes[]{
+ 0x2AB70001B1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#10) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 32;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ ;
+ { // Member
+ 0x000A; // access - modified
+ #11; // name_cpx
+ #8; // sig_cpx
+ [] { // Attributes
+ Attr(#9) { // Code
+ 2; // max_stack
+ 0; // max_locals
+ Bytes[]{
+ 0xB200021203B60004;
+ 0xB1;
+ };
+ [] { // Traps
+ } // end Traps
+ [] { // Attributes
+ Attr(#10) { // LineNumberTable
+ [] { // LineNumberTable
+ 0 35;
+ 8 36;
+ }
+ } // end LineNumberTable
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [] { // Attributes
+ Attr(#12) { // SourceFile
+ #13;
+ } // end SourceFile
+ ;
+ Attr(#14) { // NestHost
+ 0x000F;
+ } // end NestHost
+ ;
+ Attr(#24) { // InnerClasses
+ [] { // InnerClasses
+ #5 #15 #23 9;
+ }
+ } // end InnerClasses
+ } // Attributes
+} // end class P1/PackagedNestHost$Member
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/SampleNest.java 2018-05-22 05:28:07.503098730 -0400
@@ -0,0 +1,82 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+import java.util.LinkedList;
+
+// A sample nest for use with reflection API tests
+public class SampleNest {
+
+ // recursively gather all the named nested types
+
+ static List> _nestedTypes = new LinkedList>();
+
+ static void gather(Class> c) {
+ _nestedTypes.add(c);
+ for (Class> d : c.getDeclaredClasses()) {
+ gather(d);
+ }
+ }
+
+ static {
+ gather(SampleNest.class);
+ SampleNest s = new SampleNest();
+ }
+
+ public static Class>[] nestedTypes() {
+ return _nestedTypes.toArray(new Class>[0]);
+ }
+
+ // Define a nested type of each possible kind
+
+ static class StaticClass { }
+ static interface StaticIface { }
+ class InnerClass { }
+ interface InnerIface { }
+
+ // check multi-level nesting
+
+ static class DeepNest1 {
+ static class DeepNest2 {
+ static class DeepNest3 {
+ }
+ }
+ }
+
+ // local and anonymous classes aren't declared
+ // so they have to add themselves
+ public SampleNest() {
+ class LocalClass { }
+ _nestedTypes.add(LocalClass.class);
+
+ Runnable r = new Runnable() {
+ public void run() {
+ // anonymous class
+ _nestedTypes.add(getClass());
+ }
+ };
+ r.run();
+ }
+}
+
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/TestReflectionAPI.java 2018-05-22 05:28:14.215486937 -0400
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2017, 2018, 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 8046171
+ * @summary Test the new nestmate reflection API
+ * @compile TestReflectionAPI.java
+ * PackagedNestHost.java
+ * PackagedNestHost2.java
+ * SampleNest.java
+ * Hosts.java
+ * InvalidNestHost.java
+ *
+ * @compile MemberNoHost.jcod
+ * MemberMissingHost.jcod
+ * MemberNotInstanceHost.jcod
+ * MemberNotOurHost.jcod
+ * MemberMalformedHost.jcod
+ * MalformedHost.jcod
+ * PackagedNestHost.jcod
+ * PackagedNestHost2Member.jcod
+ * PackagedNestHostMember.jcod
+ * HostOfMemberNoHost.jcod
+ * HostOfMemberMissingHost.jcod
+ * HostOfMemberNotInstanceHost.jcod
+ * HostOfMemberNotOurHost.jcod
+ * HostOfMemberMalformedHost.jcod
+ * HostWithSelfMember.jcod
+ * HostWithDuplicateMembers.jcod
+ *
+ * @run main/othervm TestReflectionAPI
+ * @run main/othervm/java.security.policy=empty.policy TestReflectionAPI
+ */
+
+// We need a nest member class that is invalid for each of the possible reasons,
+// plus we need some external classes to test other failure modes.
+// For each nested class below there is a corresponding .jcod file which breaks one
+// of the rules regarding nest membership. For the package related tests we have
+// additional PackageNestHost*.java sources.
+// For testing getNestMembers we need an external host class that has a nested class
+// which we can form a jcod file from such that we get all the expected failure modes.
+// Note that all the .java files must be compiled in the same step, while all
+// .jcod files must be compiled in a later step.
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+
+public class TestReflectionAPI {
+
+ // Valid nest member
+ static class Member {}
+
+ // Missing NestHost attribute
+ static class MemberNoHost {}
+
+ // Missing NestHost class
+ static class MemberMissingHost {}
+
+ // Invalid NestHost class (not instance class)
+ static class MemberNotInstanceHost {
+ Object[] oa; // create CP entry to use in jcod change
+ }
+
+ // Valid but different NestHost class
+ static class MemberNotOurHost {}
+
+ // Malformed NestHost class
+ static class MemberMalformedHost {}
+
+ public static void main(String[] args) throws Throwable {
+ // run tests twice so that failure reasons are
+ // seen to remain the same
+ for (int i = 0; i < 2; i++) {
+ test_getNestHost();
+ test_isNestmateOf();
+ test_getNestMembers();
+ }
+ }
+
+ static void test_getNestHost() {
+ Class> host = TestReflectionAPI.class;
+
+ // sampling of "good" checks
+
+ checkHost(host, host);
+ checkHost(Member.class, host);
+ Runnable r = new Runnable() { public void run() {}};
+ checkHost(r.getClass(), host);
+
+ // all the "bad" classes should report themselves as their
+ // own nest host - no exceptions should be thrown
+ Class>[] allClasses = host.getDeclaredClasses();
+ for (Class> c : allClasses) {
+ if (c == Member.class)
+ continue;
+ checkHost(c, c);
+ }
+ checkHost(P1.PackagedNestHost.Member.class,
+ P1.PackagedNestHost.Member.class);
+ checkHost(P2.PackagedNestHost2.Member.class,
+ P2.PackagedNestHost2.Member.class);
+
+ // test some 'special' classes
+ checkHost(int.class, int.class); // primitive
+ checkHost(Object[].class, Object[].class); // array
+ checkHost(Thread.State.class, Thread.class); // enum
+ checkHost(java.lang.annotation.Documented.class, // annotation
+ java.lang.annotation.Documented.class);
+ }
+
+ static void test_isNestmateOf() {
+ Class> host = TestReflectionAPI.class;
+ checkNestmates(host, host, true);
+ checkNestmates(Member.class, host, true);
+ Runnable r = new Runnable() { public void run() {}};
+ checkNestmates(r.getClass(), host, true);
+
+ // all the "bad" classes should report themselves as their
+ // own nest host - no exceptions should be thrown - so not
+ // nestmates
+ Class>[] allClasses = host.getDeclaredClasses();
+ for (Class> c : allClasses) {
+ if (c == Member.class)
+ continue;
+ checkNestmates(host, c, false);
+ }
+
+ // 'special' classes
+ checkNestmates(int.class, int.class, true); // primitive
+ checkNestmates(int.class, long.class, false); // primitive
+ checkNestmates(Object[].class, Object[].class, true); // array
+ checkNestmates(Object[].class, int[].class, false); // array
+ checkNestmates(Thread.State.class, Thread.class, true); // enum
+ checkNestmates(java.lang.annotation.Documented.class, // annotation
+ java.lang.annotation.Documented.class, true);
+ }
+
+ static void test_getNestMembers() {
+ // Sampling of "good" checks
+ Class>[] good = { Object.class, Object[].class, int.class};
+ checkSingletonNests(good);
+
+ // More thorough correctness check
+ checkNest(SampleNest.class, SampleNest.nestedTypes(), false);
+
+ // Special cases - legal but not produced by javac
+ checkNest(HostWithSelfMember.class,
+ new Class>[] { HostWithSelfMember.class,
+ HostWithSelfMember.Member.class },
+ true);
+ checkNest(HostWithDuplicateMembers.class,
+ new Class>[] { HostWithDuplicateMembers.class,
+ HostWithDuplicateMembers.Member1.class,
+ HostWithDuplicateMembers.Member2.class },
+ true);
+
+ // Hosts with "bad" members
+ Class>[] bad = {
+ HostOfMemberNoHost.class,
+ HostOfMemberMissingHost.class,
+ HostOfMemberNotOurHost.class,
+ HostOfMemberNotInstanceHost.class,
+ HostOfMemberMalformedHost.class,
+ };
+ Class>[] exceptions = {
+ IncompatibleClassChangeError.class,
+ NoClassDefFoundError.class,
+ IncompatibleClassChangeError.class,
+ IncompatibleClassChangeError.class,
+ ClassFormatError.class,
+ };
+ String[] messages = {
+ "Nest member HostOfMemberNoHost$MemberNoHost in HostOfMemberNoHost " +
+ "declares a different nest host of HostOfMemberNoHost$MemberNoHost",
+ "Unable to load nest-host class (NestHost) of " +
+ "HostOfMemberMissingHost$MemberMissingHost",
+ "Type HostOfMemberNotOurHost$MemberNotOurHost is not a nest member " +
+ "of InvalidNestHost: current type is not listed as a nest member",
+ "Type HostOfMemberNotInstanceHost$MemberNotInstanceHost is not a nest " +
+ "member of [LInvalidNestHost;: current type is not listed as a nest member",
+ "Incompatible magic value 3735928559 in class file MalformedHost",
+ };
+ for (int i = 0; i < bad.length; i++) {
+ try {
+ bad[i].getNestMembers();
+ throw new Error("getNestMembers() succeeded for class " +
+ bad[i].getName());
+ } catch (LinkageError e) {
+ checkException(e, messages[i], exceptions[i]);
+ }
+ }
+ }
+
+ static void checkException(Throwable actual, String msg, Class> expected) {
+ if (!actual.getClass().equals(expected))
+ throw new Error("Unexpected exception: got " + actual.getClass().getName()
+ + " but expected " + expected.getName());
+ if (!actual.getMessage().contains(msg))
+ throw new Error("Wrong " + actual.getClass().getSimpleName() +": \"" +
+ actual.getMessage() + "\" does not contain \"" +
+ msg + "\"");
+ System.out.println("OK - got expected exception: " + actual);
+ }
+
+ static void checkHost(Class> target, Class> expected) {
+ System.out.println("Checking nest host of " + target.getName());
+ Class> host = target.getNestHost();
+ if (host != expected)
+ throw new Error("Class " + target.getName() +
+ " has nest host " + host.getName() +
+ " but expected " + expected.getName());
+ }
+
+ static void checkNestmates(Class> a, Class> b, boolean mates) {
+ System.out.println("Checking if " + a.getName() +
+ " isNestmateOf " + b.getName());
+
+ if (a.isNestmateOf(b) != mates)
+ throw new Error("Class " + a.getName() + " is " +
+ (mates ? "not " : "") +
+ "a nestmate of " + b.getName() + " but should " +
+ (mates ? "" : "not ") + "be");
+ }
+
+ static Comparator> cmp = Comparator.comparing(Class::getName);
+
+ static void checkNest(Class> host, Class>[] unsortedTypes, boolean expectDups) {
+ Class>[] members = host.getNestMembers();
+ Arrays.sort(members, cmp);
+ Class>[] nestedTypes = unsortedTypes.clone();
+ Arrays.sort(nestedTypes, cmp);
+ printMembers(host, members);
+ printDeclared(host, nestedTypes);
+ if (!Arrays.equals(members, nestedTypes)) {
+ if (!expectDups) {
+ throw new Error("Class " + host.getName() + " has different members " +
+ "compared to declared classes");
+ }
+ else {
+ // get rid of duplicates
+ Class>[] memberSet =
+ new HashSet>(Arrays.asList(members)).toArray(new Class>[0]);
+ Arrays.sort(memberSet, cmp);
+ if (!Arrays.equals(memberSet, nestedTypes)) {
+ throw new Error("Class " + host.getName() + " has different members " +
+ "compared to declared classes, even after duplicate removal");
+ }
+ }
+ }
+ // verify all the relationships that must hold for nest members
+ for (Class> a : members) {
+ checkHost(a, host);
+ checkNestmates(a, host, true);
+ Class>[] aMembers = a.getNestMembers();
+ if (aMembers[0] != host) {
+ throw new Error("Class " + a.getName() + " getNestMembers()[0] = " +
+ aMembers[0].getName() + " not " + host.getName());
+
+ }
+ Arrays.sort(aMembers, cmp);
+ if (!Arrays.equals(members, aMembers)) {
+ throw new Error("Class " + a.getName() + " has different members " +
+ "compared to host " + host.getName());
+ }
+ for (Class> b : members) {
+ checkNestmates(a, b, true);
+ }
+ }
+ }
+
+ static void checkSingletonNests(Class>[] classes) {
+ for (Class> host : classes) {
+ Class>[] members = host.getNestMembers();
+ if (members.length != 1) {
+ printMembers(host, members);
+ throw new Error("Class " + host.getName() + " lists " + members.length
+ + " members instead of 1 (itself)");
+ }
+ if (members[0] != host) {
+ printMembers(host, members);
+ throw new Error("Class " + host.getName() + " lists " +
+ members[0].getName() + " as member instead of itself");
+ }
+ }
+ }
+
+ static void printMembers(Class> host, Class>[] members) {
+ System.out.println("Class " + host.getName() + " has members: ");
+ for (Class> c : members) {
+ System.out.println(" - " + c.getName());
+ }
+ }
+
+ static void printDeclared(Class> host, Class>[] declared) {
+ System.out.println("Class " + host.getName() + " has declared types: ");
+ for (Class> c : declared) {
+ System.out.println(" - " + c.getName());
+ }
+ }
+
+}
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/TestSecurityManagerChecks.java 2018-05-22 05:28:21.719920950 -0400
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2018, 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 8046171
+ * @summary Test that security checks occur for getNestHost/getNestMembers
+ *
+ * @library /test/lib
+ * @build TestSecurityManagerChecks testPkg.Host testPkg.Singleton
+ * @run driver ClassFileInstaller testPkg.Host testPkg.Host$Member testPkg.Singleton
+ * @run main/othervm -Xbootclasspath/a:. TestSecurityManagerChecks
+ */
+
+// ClassFileInstaller copies the testPkg files into the "current" directory
+// so we can add it to the bootclasspath. Then when we run the test the
+// loader for the testPkg files is the bootloader but the loader for the
+// test class is the system loader, hence a package access check will fail
+// because the system loader is not the same as, nor a parent of, the bootloader.
+import java.security.Security;
+
+public class TestSecurityManagerChecks {
+
+ public static void main(String[] args) throws Throwable {
+
+ // First get hold of the target classes before we enable security
+ Class> host = testPkg.Host.class;
+ Class> member = testPkg.Host.Member.class;
+ Class> memberArray = testPkg.Host.Member[].class;
+ Class> singleton = testPkg.Singleton.class;
+
+ // Next add testPkg to the set of packages for which package-access
+ // permission is required
+ Security.setProperty("package.access",
+ Security.getProperty("package.access") + ",testPkg.");
+
+ // Finally install a default security manager
+ SecurityManager sm = new SecurityManager();
+ System.setSecurityManager(sm);
+
+ // These cases all succeed
+ getNestHost(int.class); // primitive
+ getNestHost(int[].class); // primitive[]
+ getNestHost(host); // host class
+ getNestHost(memberArray); // NestedT[]
+ getNestHost(singleton); // Singleton nest
+
+ getNestMembers(int.class); // primitive
+ getNestMembers(int[].class); // primitive[]
+ getNestMembers(memberArray); // NestedT[]
+ getNestMembers(singleton); // Singleton nest
+
+ // these cases all fail
+ getNestHostThrows(member); // NestedT
+
+ getNestMembersThrows(member); // NestedT
+ getNestMembersThrows(host); // host class
+ }
+
+ static void getNestHost(Class> c) {
+ Class> host = c.getNestHost();
+ System.out.println("OK - getNestHost succeeded for " + c.getName());
+ }
+
+ static void getNestHostThrows(Class> c) throws SecurityException {
+ try {
+ Class> host = c.getNestHost();
+ throw new Error("getNestHost succeeded for " + c.getName());
+ } catch (SecurityException e) {
+ System.out.println("OK - getNestHost for " + c.getName() +
+ " got expected exception: " + e);
+ }
+ }
+
+ static void getNestMembers(Class> c) {
+ Class>[] members = c.getNestMembers();
+ System.out.println("OK - getNestMembers succeeded for " + c.getName());
+ }
+
+ static void getNestMembersThrows(Class> c) throws SecurityException {
+ try {
+ Class>[] members = c.getNestMembers();
+ throw new Error("getNestMembers succeeded for " + c.getName());
+ } catch (SecurityException e) {
+ System.out.println("OK - getNestMembers for " + c.getName() +
+ " got expected exception: " + e);
+ }
+ }
+
+}
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/empty.policy 2018-05-22 05:28:28.444309850 -0400
@@ -0,0 +1,5 @@
+// A deliberately empty policy file for use with jtreg.
+// Setting othervm/java.security.policy=empty.policy
+// causes jtreg to run under the default system policy
+// and default security manager, with the addition of
+// the permissions jtreg itself needs to run.
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/testPkg/Host.java 2018-05-22 05:28:35.104695048 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018, 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 testPkg;
+
+// Host class with single member
+public class Host {
+ public static class Member {
+ }
+}
--- /dev/null 2018-04-28 00:26:07.190086997 -0400
+++ new/test/jdk/java/lang/reflect/Nestmates/testPkg/Singleton.java 2018-05-22 05:28:42.305111476 -0400
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2018, 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 testPkg;
+
+// Self-hosting singleton nest
+public class Singleton {
+}
--- old/test/jdk/jdk/lambda/vm/InterfaceAccessFlagsTest.java 2018-05-22 05:28:50.533587362 -0400
+++ new/test/jdk/jdk/lambda/vm/InterfaceAccessFlagsTest.java 2018-05-22 05:28:49.021499912 -0400
@@ -71,12 +71,11 @@
}
}
- /* excluded: 8187655
- @Test(groups = "vm_prototype")
+ /* excluded: 8187655 */
+ @Test(enabled=false, groups = "vm_prototype")
public void testPrivateMethodCall() {
testMethodCallWithFlag(AccessFlag.PRIVATE);
}
- */
@Test(groups = "vm_prototype")
public void testStaticMethodCall() {
--- old/src/java.base/share/classes/jdk/internal/reflect/Reflection.java 2018-05-22 05:28:57.293978343 -0400
+++ new/src/java.base/share/classes/jdk/internal/reflect/Reflection.java 2018-05-22 05:28:55.821893206 -0400
@@ -145,13 +145,12 @@
// Check for nestmate access if member is private
if (Modifier.isPrivate(modifiers)) {
- // assert: isSubclassof(targetClass, memberClass)
- // Note: targetClass may be outside the nest, but that is okay
- // as long as memberClass is in the nest.
- boolean nestmates = areNestMates(currentClass, memberClass);
- if (nestmates) {
- return true;
- }
+ // assert: isSubclassof(targetClass, memberClass)
+ // Note: targetClass may be outside the nest, but that is okay
+ // as long as memberClass is in the nest.
+ if (areNestMates(currentClass, memberClass)) {
+ return true;
+ }
}
boolean successSoFar = false;
--- old/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java 2018-05-22 05:29:02.758294367 -0400
+++ new/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java 2018-05-22 05:29:01.294209693 -0400
@@ -135,17 +135,14 @@
// Rules for privates follows access rules for nestmates.
boolean canAccess = ((allowedModes & PRIVATE) != 0 &&
Reflection.areNestMates(defc, lookupClass));
- // FIX ME: Sanity check refc == defc. Either remove or convert to
- // plain assert before integration.
- myassert((canAccess && refc == defc) || !canAccess);
+ // for private methods the selected method equals the
+ // resolved method - so refc == defc
+ assert (canAccess && refc == defc) || !canAccess;
return canAccess;
default:
throw new IllegalArgumentException("bad modifiers: "+Modifier.toString(mods));
}
}
- static void myassert(boolean cond) {
- if (!cond) throw new Error("Assertion failed");
- }
static boolean isRelatedClass(Class> refc, Class> lookupClass) {
return (refc == lookupClass ||