--- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TestFinalMethodOverride.java 2017-12-06 00:51:06.859388093 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TestFinalMethodOverride.java 2017-12-06 00:51:04.699264997 -0500 @@ -28,6 +28,20 @@ * @run main TestFinalMethodOverride */ +// The check_final_method_override function in ClassfileParser uses an +// accessability check to see if the subclass method overrides a same-named +// superclass method. This would result in a nestmate access check if the +// super class method is private, which in turn could lead to classloading +// and possibly exceptions and cause havoc in the classfile parsing process. +// To fix that we added a check for whether the super class method is private, +// and if so, we skip the override check as by definition you can't override +// a private method. +// +// This test simply sets up the case where a public subclass method has the +// same signature as a private superclass method - the case we now skip when +// doing check_final_method_override. The test should trivially complete +// normally. + public class TestFinalMethodOverride { public static class Super { @@ -42,4 +56,5 @@ public static void main(String[] args) { Inner i = new Inner(); } -} \ No newline at end of file +} + --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerMissingHost.jcod 2017-12-06 00:51:13.403761026 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerMissingHost.jcod 2017-12-06 00:51:11.231637247 -0500 @@ -29,61 +29,74 @@ 53; // version [] { // Constant Pool ; // first element is empty - Method #10 #24; // #1 - String #25; // #2 - Field #9 #26; // #3 - Field #27 #28; // #4 - String #29; // #5 - Method #30 #31; // #6 - Method #32 #33; // #7 - Method #34 #33; // #8 - class #35; // #9 - class #38; // #10 - Utf8 "msg"; // #11 - Utf8 "Ljava/lang/String;"; // #12 - Utf8 ""; // #13 - Utf8 "()V"; // #14 - Utf8 "Code"; // #15 - Utf8 "LineNumberTable"; // #16 - Utf8 "m"; // #17 - Utf8 "invokeTarget"; // #18 - Utf8 "invokeTargetMissingHost"; // #19 - Utf8 "SourceFile"; // #20 - Utf8 "TestNestmateMembership.java"; // #21 - Utf8 "NestHost"; // #22 - class #39; // #23 - NameAndType #13 #14; // #24 - Utf8 "NoCallerMissingHost"; // #25 - NameAndType #11 #12; // #26 - class #40; // #27 - NameAndType #41 #42; // #28 - Utf8 "CallerMissingHost.m() - java version"; // #29 - class #43; // #30 - NameAndType #44 #45; // #31 - class #46; // #32 - NameAndType #17 #14; // #33 - class #48; // #34 - Utf8 "TestNestmateMembership$CallerMissingHost"; // #35 - Utf8 "CallerMissingHost"; // #36 - Utf8 "InnerClasses"; // #37 - Utf8 "java/lang/Object"; // #38 - Utf8 "TestNestmateMembership"; // #39 - Utf8 "java/lang/System"; // #40 - Utf8 "out"; // #41 - Utf8 "Ljava/io/PrintStream;"; // #42 - Utf8 "java/io/PrintStream"; // #43 - Utf8 "println"; // #44 - Utf8 "(Ljava/lang/String;)V"; // #45 - Utf8 "TestNestmateMembership$Target"; // #46 - Utf8 "Target"; // #47 - Utf8 "TestNestmateMembership$TargetMissingHost"; // #48 - Utf8 "TargetMissingHost"; // #49 - class #25; // #50 - added + Field #38 #39; // #1 + String #40; // #2 + Method #41 #42; // #3 + Method #9 #43; // #4 + Method #11 #43; // #5 + Method #16 #44; // #6 + String #45; // #7 + Field #15 #46; // #8 + class #47; // #9 + Method #9 #44; // #10 + class #50; // #11 + Method #11 #44; // #12 + Field #9 #52; // #13 + Field #11 #52; // #14 + class #53; // #15 + class #55; // #16 + Utf8 "msg"; // #17 + Utf8 "Ljava/lang/String;"; // #18 + Utf8 "f"; // #19 + Utf8 "I"; // #20 + Utf8 "m"; // #21 + Utf8 "()V"; // #22 + Utf8 "Code"; // #23 + Utf8 "LineNumberTable"; // #24 + Utf8 "invokeTarget"; // #25 + Utf8 "invokeTargetMissingHost"; // #26 + Utf8 ""; // #27 + Utf8 "newTarget"; // #28 + Utf8 "newTargetMissingHost"; // #29 + Utf8 "getFieldTarget"; // #30 + Utf8 "getFieldTargetMissingHost"; // #31 + Utf8 "putFieldTarget"; // #32 + Utf8 "putFieldTargetMissingHost"; // #33 + Utf8 "SourceFile"; // #34 + Utf8 "TestNestmateMembership.java"; // #35 + Utf8 "NestHost"; // #36 + class #56; // #37 + class #57; // #38 + NameAndType #58 #59; // #39 + Utf8 "CallerMissingHost.m() - java version"; // #40 + class #60; // #41 + NameAndType #61 #62; // #42 + NameAndType #21 #22; // #43 + NameAndType #27 #22; // #44 + Utf8 "NoCallerMissingHost"; // #45 + NameAndType #17 #18; // #46 + Utf8 "TestNestmateMembership$Target"; // #47 + Utf8 "Target"; // #48 + Utf8 "InnerClasses"; // #49 + Utf8 "TestNestmateMembership$TargetMissingHost"; // #50 + Utf8 "TargetMissingHost"; // #51 + NameAndType #19 #20; // #52 + Utf8 "TestNestmateMembership$CallerMissingHost"; // #53 + Utf8 "CallerMissingHost"; // #54 + Utf8 "java/lang/Object"; // #55 + Utf8 "TestNestmateMembership"; // #56 + Utf8 "java/lang/System"; // #57 + Utf8 "out"; // #58 + Utf8 "Ljava/io/PrintStream;"; // #59 + Utf8 "java/io/PrintStream"; // #60 + Utf8 "println"; // #61 + Utf8 "(Ljava/lang/String;)V"; // #62 + class #45; // added - #63 } // Constant Pool 0x0020; // access - #9;// this_cpx - #10;// super_cpx + #15;// this_cpx + #16;// super_cpx [] { // Interfaces } // Interfaces @@ -91,8 +104,16 @@ [] { // fields { // Member 0x0000; // access - #11; // name_cpx - #12; // sig_cpx + #17; // name_cpx + #18; // sig_cpx + [] { // Attributes + } // Attributes + } // Member + ; + { // Member + 0x000A; // access + #19; // name_cpx + #20; // sig_cpx [] { // Attributes } // Attributes } // Member @@ -100,24 +121,101 @@ [] { // methods { // Member - 0x0000; // access - #13; // name_cpx - #14; // sig_cpx + 0x000A; // access + #21; // name_cpx + #22; // sig_cpx [] { // Attributes - Attr(#15) { // Code + Attr(#23) { // Code + 2; // max_stack + 0; // max_locals + Bytes[]{ + 0xB200011202B60003; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#24) { // LineNumberTable + [] { // LineNumberTable + 0 209; + 8 210; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #25; // name_cpx + #22; // sig_cpx + [] { // Attributes + Attr(#23) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80004B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#24) { // LineNumberTable + [] { // LineNumberTable + 0 212; + 3 213; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #26; // name_cpx + #22; // sig_cpx + [] { // Attributes + Attr(#23) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80005B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#24) { // LineNumberTable + [] { // LineNumberTable + 0 215; + 3 216; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0002; // access + #27; // name_cpx + #22; // sig_cpx + [] { // Attributes + Attr(#23) { // Code 2; // max_stack 1; // max_locals Bytes[]{ - 0x2AB700012A1202B5; - 0x0003B1; + 0x2AB700062A1207B5; + 0x0008B1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#16) { // LineNumberTable + Attr(#24) { // LineNumberTable [] { // LineNumberTable - 0 91; - 4 92; + 0 220; + 4 204; + 10 220; } } // end LineNumberTable } // Attributes @@ -126,24 +224,24 @@ } // Member ; { // Member - 0x000A; // access - #17; // name_cpx - #14; // sig_cpx + 0x0009; // access + #28; // name_cpx + #22; // sig_cpx [] { // Attributes - Attr(#15) { // Code + Attr(#23) { // Code 2; // max_stack - 0; // max_locals + 1; // max_locals Bytes[]{ - 0xB200041205B60006; + 0xBB000959B7000A4B; 0xB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#16) { // LineNumberTable + Attr(#24) { // LineNumberTable [] { // LineNumberTable - 0 94; - 8 95; + 0 223; + 8 224; } } // end LineNumberTable } // Attributes @@ -153,22 +251,98 @@ ; { // Member 0x0009; // access - #18; // name_cpx - #14; // sig_cpx + #29; // name_cpx + #22; // sig_cpx [] { // Attributes - Attr(#15) { // Code - 0; // max_stack + Attr(#23) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xBB000B59B7000C4B; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#24) { // LineNumberTable + [] { // LineNumberTable + 0 226; + 8 227; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #30; // name_cpx + #22; // sig_cpx + [] { // Attributes + Attr(#23) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000D3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#24) { // LineNumberTable + [] { // LineNumberTable + 0 234; + 4 235; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #31; // name_cpx + #22; // sig_cpx + [] { // Attributes + Attr(#23) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000E3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#24) { // LineNumberTable + [] { // LineNumberTable + 0 237; + 4 238; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #32; // name_cpx + #22; // sig_cpx + [] { // Attributes + Attr(#23) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80007B1; + 0x102AB3000DB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#16) { // LineNumberTable + Attr(#24) { // LineNumberTable [] { // LineNumberTable - 0 97; - 3 98; + 0 240; + 5 241; } } // end LineNumberTable } // Attributes @@ -178,22 +352,22 @@ ; { // Member 0x0009; // access - #19; // name_cpx - #14; // sig_cpx + #33; // name_cpx + #22; // sig_cpx [] { // Attributes - Attr(#15) { // Code - 0; // max_stack + Attr(#23) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80008B1; + 0x102AB3000EB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#16) { // LineNumberTable + Attr(#24) { // LineNumberTable [] { // LineNumberTable - 0 100; - 3 101; + 0 243; + 5 244; } } // end LineNumberTable } // Attributes @@ -203,19 +377,19 @@ } // methods [] { // Attributes - Attr(#20) { // SourceFile - #21; + Attr(#34) { // SourceFile + #35; } // end SourceFile ; - Attr(#22) { // NestHost - 0x0032; // modified - #50 + Attr(#36) { // NestHost + 0x003F; // modified - #63 } // end NestHost ; - Attr(#37) { // InnerClasses + Attr(#49) { // InnerClasses [] { // InnerClasses - #9 #23 #36 8; - #32 #23 #47 8; - #34 #23 #49 8; + #9 #37 #48 8; + #11 #37 #51 8; + #15 #37 #54 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNoHost.jcod 2017-12-06 00:51:21.804239731 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNoHost.jcod 2017-12-06 00:51:19.632115950 -0500 @@ -29,79 +29,175 @@ 53; // version [] { // Constant Pool ; // first element is empty - Method #8 #20; // #1 - Field #21 #22; // #2 - String #23; // #3 - Method #24 #25; // #4 - Method #26 #27; // #5 - Method #28 #27; // #6 - class #29; // #7 - class #32; // #8 - Utf8 ""; // #9 - Utf8 "()V"; // #10 - Utf8 "Code"; // #11 - Utf8 "LineNumberTable"; // #12 - Utf8 "m"; // #13 - Utf8 "invokeTarget"; // #14 - Utf8 "invokeTargetNoHost"; // #15 - Utf8 "SourceFile"; // #16 - Utf8 "TestNestmateMembership.java"; // #17 - Utf8 "NestHost"; // #18 - class #33; // #19 - NameAndType #9 #10; // #20 - class #34; // #21 - NameAndType #35 #36; // #22 - Utf8 "CallerNoHost.m() - java version"; // #23 - class #37; // #24 - NameAndType #38 #39; // #25 - class #40; // #26 - NameAndType #13 #10; // #27 - class #42; // #28 - Utf8 "TestNestmateMembership$CallerNoHost"; // #29 - Utf8 "CallerNoHost"; // #30 - Utf8 "InnerClasses"; // #31 - Utf8 "java/lang/Object"; // #32 - Utf8 "TestNestmateMembership"; // #33 - Utf8 "java/lang/System"; // #34 - Utf8 "out"; // #35 - Utf8 "Ljava/io/PrintStream;"; // #36 - Utf8 "java/io/PrintStream"; // #37 - Utf8 "println"; // #38 - Utf8 "(Ljava/lang/String;)V"; // #39 - Utf8 "TestNestmateMembership$Target"; // #40 - Utf8 "Target"; // #41 - Utf8 "TestNestmateMembership$TargetNoHost"; // #42 - Utf8 "TargetNoHost"; // #43 + Field #34 #35; // #1 + String #36; // #2 + Method #37 #38; // #3 + Method #7 #39; // #4 + Method #9 #39; // #5 + Method #14 #40; // #6 + class #41; // #7 + Method #7 #40; // #8 + class #44; // #9 + Method #9 #40; // #10 + Field #7 #46; // #11 + Field #9 #46; // #12 + class #47; // #13 + class #49; // #14 + Utf8 "f"; // #15 + Utf8 "I"; // #16 + Utf8 "m"; // #17 + Utf8 "()V"; // #18 + Utf8 "Code"; // #19 + Utf8 "LineNumberTable"; // #20 + Utf8 "invokeTarget"; // #21 + Utf8 "invokeTargetNoHost"; // #22 + Utf8 ""; // #23 + Utf8 "newTarget"; // #24 + Utf8 "newTargetNoHost"; // #25 + Utf8 "getFieldTarget"; // #26 + Utf8 "getFieldTargetNoHost"; // #27 + Utf8 "putFieldTarget"; // #28 + Utf8 "putFieldTargetNoHost"; // #29 + Utf8 "SourceFile"; // #30 + Utf8 "TestNestmateMembership.java"; // #31 + Utf8 "NestHost"; // #32 + class #50; // #33 + class #51; // #34 + NameAndType #52 #53; // #35 + Utf8 "CallerNoHost.m() - java version"; // #36 + class #54; // #37 + NameAndType #55 #56; // #38 + NameAndType #17 #18; // #39 + NameAndType #23 #18; // #40 + Utf8 "TestNestmateMembership$Target"; // #41 + Utf8 "Target"; // #42 + Utf8 "InnerClasses"; // #43 + Utf8 "TestNestmateMembership$TargetNoHost"; // #44 + Utf8 "TargetNoHost"; // #45 + NameAndType #15 #16; // #46 + Utf8 "TestNestmateMembership$CallerNoHost"; // #47 + Utf8 "CallerNoHost"; // #48 + Utf8 "java/lang/Object"; // #49 + Utf8 "TestNestmateMembership"; // #50 + Utf8 "java/lang/System"; // #51 + Utf8 "out"; // #52 + Utf8 "Ljava/io/PrintStream;"; // #53 + Utf8 "java/io/PrintStream"; // #54 + Utf8 "println"; // #55 + Utf8 "(Ljava/lang/String;)V"; // #56 } // Constant Pool 0x0020; // access - #7;// this_cpx - #8;// super_cpx + #13;// this_cpx + #14;// super_cpx [] { // Interfaces } // Interfaces [] { // fields + { // Member + 0x000A; // access + #15; // name_cpx + #16; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0000; // access - #9; // name_cpx - #10; // sig_cpx + 0x000A; // access + #17; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 2; // max_stack + 0; // max_locals + Bytes[]{ + 0xB200011202B60003; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 163; + 8 164; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #21; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80004B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 166; + 3 167; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #22; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80005B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 169; + 3 170; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0002; // access + #23; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code + Attr(#19) { // Code 1; // max_stack 1; // max_locals Bytes[]{ - 0x2AB70001B1; + 0x2AB70006B1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 79; + 0 174; } } // end LineNumberTable } // Attributes @@ -110,24 +206,24 @@ } // Member ; { // Member - 0x000A; // access - #13; // name_cpx - #10; // sig_cpx + 0x0009; // access + #24; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code + Attr(#19) { // Code 2; // max_stack - 0; // max_locals + 1; // max_locals Bytes[]{ - 0xB200021203B60004; + 0xBB000759B700084B; 0xB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 81; - 8 82; + 0 177; + 8 178; } } // end LineNumberTable } // Attributes @@ -137,22 +233,98 @@ ; { // Member 0x0009; // access - #14; // name_cpx - #10; // sig_cpx + #25; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code - 0; // max_stack + Attr(#19) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xBB000959B7000A4B; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 180; + 8 181; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #26; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000B3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 188; + 4 189; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #27; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000C3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 191; + 4 192; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #28; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80005B1; + 0x102AB3000BB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 84; - 3 85; + 0 195; + 5 196; } } // end LineNumberTable } // Attributes @@ -162,22 +334,22 @@ ; { // Member 0x0009; // access - #15; // name_cpx - #10; // sig_cpx + #29; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code - 0; // max_stack + Attr(#19) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80006B1; + 0x102AB3000CB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 87; - 3 88; + 0 198; + 5 199; } } // end LineNumberTable } // Attributes @@ -187,15 +359,15 @@ } // methods [] { // Attributes - Attr(#16) { // SourceFile - #17; + Attr(#30) { // SourceFile + #31; } // end SourceFile ; - Attr(#31) { // InnerClasses + Attr(#43) { // InnerClasses [] { // InnerClasses - #7 #19 #30 8; - #26 #19 #41 8; - #28 #19 #43 8; + #7 #33 #42 8; + #9 #33 #45 8; + #13 #33 #48 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotInstanceHost.jcod 2017-12-06 00:51:28.360613348 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotInstanceHost.jcod 2017-12-06 00:51:26.192489797 -0500 @@ -29,57 +29,70 @@ 53; // version [] { // Constant Pool ; // first element is empty - Method #8 #22; // #1 - Field #23 #24; // #2 - String #25; // #3 - Method #26 #27; // #4 - Method #28 #29; // #5 - Method #30 #29; // #6 - class #31; // #7 - class #34; // #8 - Utf8 "oa"; // #9 - Utf8 "[Ljava/lang/Object;"; // #10 - Utf8 ""; // #11 - Utf8 "()V"; // #12 - Utf8 "Code"; // #13 - Utf8 "LineNumberTable"; // #14 - Utf8 "m"; // #15 - Utf8 "invokeTarget"; // #16 - Utf8 "invokeTargetNotInstanceHost"; // #17 - Utf8 "SourceFile"; // #18 - Utf8 "TestNestmateMembership.java"; // #19 - Utf8 "NestHost"; // #20 - class #35; // #21 - NameAndType #11 #12; // #22 - class #36; // #23 - NameAndType #37 #38; // #24 - Utf8 "CallerNotInstanceHost.m() - java version"; // #25 - class #39; // #26 - NameAndType #40 #41; // #27 - class #42; // #28 - NameAndType #15 #12; // #29 - class #44; // #30 - Utf8 "TestNestmateMembership$CallerNotInstanceHost"; // #31 - Utf8 "CallerNotInstanceHost"; // #32 - Utf8 "InnerClasses"; // #33 - Utf8 "java/lang/Object"; // #34 - Utf8 "TestNestmateMembership"; // #35 - Utf8 "java/lang/System"; // #36 - Utf8 "out"; // #37 - Utf8 "Ljava/io/PrintStream;"; // #38 - Utf8 "java/io/PrintStream"; // #39 - Utf8 "println"; // #40 - Utf8 "(Ljava/lang/String;)V"; // #41 - Utf8 "TestNestmateMembership$Target"; // #42 - Utf8 "Target"; // #43 - Utf8 "TestNestmateMembership$TargetNotInstanceHost"; // #44 - Utf8 "TargetNotInstanceHost"; // #45 - class #10; // #46 - added + Field #36 #37; // #1 + String #38; // #2 + Method #39 #40; // #3 + Method #7 #41; // #4 + Method #9 #41; // #5 + Method #14 #42; // #6 + class #43; // #7 + Method #7 #42; // #8 + class #46; // #9 + Method #9 #42; // #10 + Field #7 #48; // #11 + Field #9 #48; // #12 + class #49; // #13 + class #51; // #14 + Utf8 "oa"; // #15 + Utf8 "[Ljava/lang/Object;"; // #16 + Utf8 "f"; // #17 + Utf8 "I"; // #18 + Utf8 "m"; // #19 + Utf8 "()V"; // #20 + Utf8 "Code"; // #21 + Utf8 "LineNumberTable"; // #22 + Utf8 "invokeTarget"; // #23 + Utf8 "invokeTargetNotInstanceHost"; // #24 + Utf8 ""; // #25 + Utf8 "newTarget"; // #26 + Utf8 "newTargetNotInstanceHost"; // #27 + Utf8 "getFieldTarget"; // #28 + Utf8 "getFieldTargetNotInstanceHost"; // #29 + Utf8 "putFieldTarget"; // #30 + Utf8 "putFieldTargetNotInstanceHost"; // #31 + Utf8 "SourceFile"; // #32 + Utf8 "TestNestmateMembership.java"; // #33 + Utf8 "NestHost"; // #34 + class #52; // #35 + class #53; // #36 + NameAndType #54 #55; // #37 + Utf8 "CallerNotInstanceHost.m() - java version"; // #38 + class #56; // #39 + NameAndType #57 #58; // #40 + NameAndType #19 #20; // #41 + NameAndType #25 #20; // #42 + Utf8 "TestNestmateMembership$Target"; // #43 + Utf8 "Target"; // #44 + Utf8 "InnerClasses"; // #45 + Utf8 "TestNestmateMembership$TargetNotInstanceHost"; // #46 + Utf8 "TargetNotInstanceHost"; // #47 + NameAndType #17 #18; // #48 + Utf8 "TestNestmateMembership$CallerNotInstanceHost"; // #49 + Utf8 "CallerNotInstanceHost"; // #50 + Utf8 "java/lang/Object"; // #51 + Utf8 "TestNestmateMembership"; // #52 + Utf8 "java/lang/System"; // #53 + Utf8 "out"; // #54 + Utf8 "Ljava/io/PrintStream;"; // #55 + Utf8 "java/io/PrintStream"; // #56 + Utf8 "println"; // #57 + Utf8 "(Ljava/lang/String;)V"; // #58 + class #16; // Added - #59 } // Constant Pool 0x0020; // access - #7;// this_cpx - #8;// super_cpx + #13;// this_cpx + #14;// super_cpx [] { // Interfaces } // Interfaces @@ -87,8 +100,16 @@ [] { // fields { // Member 0x0000; // access - #9; // name_cpx - #10; // sig_cpx + #15; // name_cpx + #16; // sig_cpx + [] { // Attributes + } // Attributes + } // Member + ; + { // Member + 0x000A; // access + #17; // name_cpx + #18; // sig_cpx [] { // Attributes } // Attributes } // Member @@ -96,22 +117,98 @@ [] { // methods { // Member - 0x0000; // access - #11; // name_cpx - #12; // sig_cpx + 0x000A; // access + #19; // name_cpx + #20; // sig_cpx + [] { // Attributes + Attr(#21) { // Code + 2; // max_stack + 0; // max_locals + Bytes[]{ + 0xB200011202B60003; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#22) { // LineNumberTable + [] { // LineNumberTable + 0 254; + 8 255; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #23; // name_cpx + #20; // sig_cpx + [] { // Attributes + Attr(#21) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80004B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#22) { // LineNumberTable + [] { // LineNumberTable + 0 257; + 3 258; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #24; // name_cpx + #20; // sig_cpx [] { // Attributes - Attr(#13) { // Code + Attr(#21) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80005B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#22) { // LineNumberTable + [] { // LineNumberTable + 0 260; + 3 261; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0002; // access + #25; // name_cpx + #20; // sig_cpx + [] { // Attributes + Attr(#21) { // Code 1; // max_stack 1; // max_locals Bytes[]{ - 0x2AB70001B1; + 0x2AB70006B1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#14) { // LineNumberTable + Attr(#22) { // LineNumberTable [] { // LineNumberTable - 0 104; + 0 265; } } // end LineNumberTable } // Attributes @@ -120,24 +217,24 @@ } // Member ; { // Member - 0x000A; // access - #15; // name_cpx - #12; // sig_cpx + 0x0009; // access + #26; // name_cpx + #20; // sig_cpx [] { // Attributes - Attr(#13) { // Code + Attr(#21) { // Code 2; // max_stack - 0; // max_locals + 1; // max_locals Bytes[]{ - 0xB200021203B60004; + 0xBB000759B700084B; 0xB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#14) { // LineNumberTable + Attr(#22) { // LineNumberTable [] { // LineNumberTable - 0 107; - 8 108; + 0 268; + 8 269; } } // end LineNumberTable } // Attributes @@ -147,22 +244,98 @@ ; { // Member 0x0009; // access - #16; // name_cpx - #12; // sig_cpx + #27; // name_cpx + #20; // sig_cpx [] { // Attributes - Attr(#13) { // Code - 0; // max_stack + Attr(#21) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xBB000959B7000A4B; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#22) { // LineNumberTable + [] { // LineNumberTable + 0 271; + 8 272; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #28; // name_cpx + #20; // sig_cpx + [] { // Attributes + Attr(#21) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000B3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#22) { // LineNumberTable + [] { // LineNumberTable + 0 279; + 4 280; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #29; // name_cpx + #20; // sig_cpx + [] { // Attributes + Attr(#21) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000C3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#22) { // LineNumberTable + [] { // LineNumberTable + 0 282; + 4 283; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #30; // name_cpx + #20; // sig_cpx + [] { // Attributes + Attr(#21) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80005B1; + 0x102AB3000BB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#14) { // LineNumberTable + Attr(#22) { // LineNumberTable [] { // LineNumberTable - 0 110; - 3 111; + 0 285; + 5 286; } } // end LineNumberTable } // Attributes @@ -172,22 +345,22 @@ ; { // Member 0x0009; // access - #17; // name_cpx - #12; // sig_cpx + #31; // name_cpx + #20; // sig_cpx [] { // Attributes - Attr(#13) { // Code - 0; // max_stack + Attr(#21) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80006B1; + 0x102AB3000CB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#14) { // LineNumberTable + Attr(#22) { // LineNumberTable [] { // LineNumberTable - 0 113; - 3 114; + 0 288; + 5 289; } } // end LineNumberTable } // Attributes @@ -197,19 +370,19 @@ } // methods [] { // Attributes - Attr(#18) { // SourceFile - #19; + Attr(#32) { // SourceFile + #33; } // end SourceFile ; - Attr(#20) { // NestHost - 0x002E; // modified - #46 + Attr(#34) { // NestHost + 0x003B; // modified #59 } // end NestHost ; - Attr(#33) { // InnerClasses + Attr(#45) { // InnerClasses [] { // InnerClasses - #7 #21 #32 8; - #28 #21 #43 8; - #30 #21 #45 8; + #7 #35 #44 8; + #9 #35 #47 8; + #13 #35 #50 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotOurHost.jcod 2017-12-06 00:51:34.920987194 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotOurHost.jcod 2017-12-06 00:51:32.744863187 -0500 @@ -29,79 +29,175 @@ 53; // version [] { // Constant Pool ; // first element is empty - Method #8 #20; // #1 - Field #21 #22; // #2 - String #23; // #3 - Method #24 #25; // #4 - Method #26 #27; // #5 - Method #28 #27; // #6 - class #29; // #7 - class #32; // #8 - Utf8 ""; // #9 - Utf8 "()V"; // #10 - Utf8 "Code"; // #11 - Utf8 "LineNumberTable"; // #12 - Utf8 "m"; // #13 - Utf8 "invokeTarget"; // #14 - Utf8 "invokeTargetNotOurHost"; // #15 - Utf8 "SourceFile"; // #16 - Utf8 "TestNestmateMembership.java"; // #17 - Utf8 "NestHost"; // #18 - class #33; // #19 - NameAndType #9 #10; // #20 - class #34; // #21 - NameAndType #35 #36; // #22 - Utf8 "CallerNotOurHost.m() - java version"; // #23 - class #37; // #24 - NameAndType #38 #39; // #25 - class #40; // #26 - NameAndType #13 #10; // #27 - class #42; // #28 - Utf8 "TestNestmateMembership$CallerNotOurHost"; // #29 - Utf8 "CallerNotOurHost"; // #30 - Utf8 "InnerClasses"; // #31 - Utf8 "java/lang/Object"; // #32 - Utf8 "TestNestmateMembership"; // #33 - Utf8 "java/lang/System"; // #34 - Utf8 "out"; // #35 - Utf8 "Ljava/io/PrintStream;"; // #36 - Utf8 "java/io/PrintStream"; // #37 - Utf8 "println"; // #38 - Utf8 "(Ljava/lang/String;)V"; // #39 - Utf8 "TestNestmateMembership$Target"; // #40 - Utf8 "Target"; // #41 - Utf8 "TestNestmateMembership$TargetNotOurHost"; // #42 - Utf8 "TargetNotOurHost"; // #43 + Field #34 #35; // #1 + String #36; // #2 + Method #37 #38; // #3 + Method #7 #39; // #4 + Method #9 #39; // #5 + Method #14 #40; // #6 + class #41; // #7 + Method #7 #40; // #8 + class #44; // #9 + Method #9 #40; // #10 + Field #7 #46; // #11 + Field #9 #46; // #12 + class #47; // #13 + class #49; // #14 + Utf8 "f"; // #15 + Utf8 "I"; // #16 + Utf8 "m"; // #17 + Utf8 "()V"; // #18 + Utf8 "Code"; // #19 + Utf8 "LineNumberTable"; // #20 + Utf8 "invokeTarget"; // #21 + Utf8 "invokeTargetNotOurHost"; // #22 + Utf8 ""; // #23 + Utf8 "newTarget"; // #24 + Utf8 "newTargetNotOurHost"; // #25 + Utf8 "getFieldTarget"; // #26 + Utf8 "getFieldTargetNotOurHost"; // #27 + Utf8 "putFieldTarget"; // #28 + Utf8 "putFieldTargetNotOurHost"; // #29 + Utf8 "SourceFile"; // #30 + Utf8 "TestNestmateMembership.java"; // #31 + Utf8 "NestHost"; // #32 + class #50; // #33 + class #51; // #34 + NameAndType #52 #53; // #35 + Utf8 "CallerNotOurHost.m() - java version"; // #36 + class #54; // #37 + NameAndType #55 #56; // #38 + NameAndType #17 #18; // #39 + NameAndType #23 #18; // #40 + Utf8 "TestNestmateMembership$Target"; // #41 + Utf8 "Target"; // #42 + Utf8 "InnerClasses"; // #43 + Utf8 "TestNestmateMembership$TargetNotOurHost"; // #44 + Utf8 "TargetNotOurHost"; // #45 + NameAndType #15 #16; // #46 + Utf8 "TestNestmateMembership$CallerNotOurHost"; // #47 + Utf8 "CallerNotOurHost"; // #48 + Utf8 "java/lang/Object"; // #49 + Utf8 "TestNestmateMembership"; // #50 + Utf8 "java/lang/System"; // #51 + Utf8 "out"; // #52 + Utf8 "Ljava/io/PrintStream;"; // #53 + Utf8 "java/io/PrintStream"; // #54 + Utf8 "println"; // #55 + Utf8 "(Ljava/lang/String;)V"; // #56 } // Constant Pool 0x0020; // access - #7;// this_cpx - #8;// super_cpx + #13;// this_cpx + #14;// super_cpx [] { // Interfaces } // Interfaces [] { // fields + { // Member + 0x000A; // access + #15; // name_cpx + #16; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0000; // access - #9; // name_cpx - #10; // sig_cpx + 0x000A; // access + #17; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 2; // max_stack + 0; // max_locals + Bytes[]{ + 0xB200011202B60003; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 297; + 8 298; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #21; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80004B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 300; + 3 301; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #22; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 0; // max_stack + 0; // max_locals + Bytes[]{ + 0xB80005B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 303; + 3 304; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0002; // access + #23; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code + Attr(#19) { // Code 1; // max_stack 1; // max_locals Bytes[]{ - 0x2AB70001B1; + 0x2AB70006B1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 117; + 0 308; } } // end LineNumberTable } // Attributes @@ -110,24 +206,24 @@ } // Member ; { // Member - 0x000A; // access - #13; // name_cpx - #10; // sig_cpx + 0x0009; // access + #24; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code + Attr(#19) { // Code 2; // max_stack - 0; // max_locals + 1; // max_locals Bytes[]{ - 0xB200021203B60004; + 0xBB000759B700084B; 0xB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 119; - 8 120; + 0 311; + 8 312; } } // end LineNumberTable } // Attributes @@ -137,22 +233,98 @@ ; { // Member 0x0009; // access - #14; // name_cpx - #10; // sig_cpx + #25; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code - 0; // max_stack + Attr(#19) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xBB000959B7000A4B; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 314; + 8 315; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #26; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000B3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 322; + 4 323; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #27; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB2000C3BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 325; + 4 326; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #28; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80005B1; + 0x102AB3000BB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 122; - 3 123; + 0 328; + 5 329; } } // end LineNumberTable } // Attributes @@ -162,22 +334,22 @@ ; { // Member 0x0009; // access - #15; // name_cpx - #10; // sig_cpx + #29; // name_cpx + #18; // sig_cpx [] { // Attributes - Attr(#11) { // Code - 0; // max_stack + Attr(#19) { // Code + 1; // max_stack 0; // max_locals Bytes[]{ - 0xB80006B1; + 0x102AB3000CB1; }; [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#20) { // LineNumberTable [] { // LineNumberTable - 0 125; - 3 126; + 0 331; + 5 332; } } // end LineNumberTable } // Attributes @@ -187,19 +359,19 @@ } // methods [] { // Attributes - Attr(#16) { // SourceFile - #17; + Attr(#30) { // SourceFile + #31; } // end SourceFile ; - Attr(#18) { // NestHost - 0x0008; // modified - #8 + Attr(#32) { // NestHost + 0x000E; // modified - #14 } // end NestHost ; - Attr(#31) { // InnerClasses + Attr(#43) { // InnerClasses [] { // InnerClasses - #7 #19 #30 8; - #26 #19 #41 8; - #28 #19 #43 8; + #7 #33 #42 8; + #9 #33 #45 8; + #13 #33 #48 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost.java 2017-12-06 00:51:41.473360584 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost.java 2017-12-06 00:51:39.297236576 -0500 @@ -30,17 +30,32 @@ */ public class PackagedNestHost { public static class Member { - // jcod file will change this to private + // jcod file will change these to private + public Member() {} + public static int f; public static void m() { System.out.println("You should never see this!"); } } - // Entry point for main test - public static void doAccess() { - // this should fail at runtime as m() will now be private - // and the nestmate access check should fail due to being in - // a different package. + // Entry points for main test. + // These should fail at runtime as members will now be private + // and the nestmate access check should fail due to being in a + // different package. + + public static void doInvoke() { P2.PackagedNestHost2.Member.m(); } + + public static void doConstruct() { + Object o = new P2.PackagedNestHost2.Member(); + } + + public static void doGetField() { + int x = P2.PackagedNestHost2.Member.f; + } + + public static void doPutField() { + P2.PackagedNestHost2.Member.f = 42; + } } --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost.jcod 2017-12-06 00:51:48.293749247 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost.jcod 2017-12-06 00:51:46.085623416 -0500 @@ -29,36 +29,44 @@ 53; // 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 + Method #7 #22; // #1 + Method #3 #23; // #2 + class #25; // #3 + Method #3 #22; // #4 + Field #3 #26; // #5 + class #27; // #6 + class #28; // #7 + class #29; // #8 + Utf8 "Member"; // #9 + Utf8 "InnerClasses"; // #10 + Utf8 ""; // #11 + Utf8 "()V"; // #12 + Utf8 "Code"; // #13 + Utf8 "LineNumberTable"; // #14 + Utf8 "doInvoke"; // #15 + Utf8 "doConstruct"; // #16 + Utf8 "doGetField"; // #17 + Utf8 "doPutField"; // #18 + Utf8 "SourceFile"; // #19 + Utf8 "PackagedNestHost.java"; // #20 + Utf8 "NestMembers"; // #21 + NameAndType #11 #12; // #22 + NameAndType #30 #12; // #23 + class #31; // #24 + Utf8 "P2/PackagedNestHost2$Member"; // #25 + NameAndType #32 #33; // #26 + Utf8 "P1/PackagedNestHost"; // #27 + Utf8 "java/lang/Object"; // #28 + Utf8 "P1/PackagedNestHost$Member"; // #29 + Utf8 "m"; // #30 + Utf8 "P2/PackagedNestHost2"; // #31 + Utf8 "f"; // #32 + Utf8 "I"; // #33 } // Constant Pool 0x0021; // access - #3;// this_cpx - #4;// super_cpx + #6;// this_cpx + #7;// super_cpx [] { // Interfaces } // Interfaces @@ -69,10 +77,10 @@ [] { // methods { // Member 0x0001; // access - #8; // name_cpx - #9; // sig_cpx + #11; // name_cpx + #12; // sig_cpx [] { // Attributes - Attr(#10) { // Code + Attr(#13) { // Code 1; // max_stack 1; // max_locals Bytes[]{ @@ -81,7 +89,7 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#11) { // LineNumberTable + Attr(#14) { // LineNumberTable [] { // LineNumberTable 0 31; } @@ -93,10 +101,10 @@ ; { // Member 0x0009; // access - #12; // name_cpx - #9; // sig_cpx + #15; // name_cpx + #12; // sig_cpx [] { // Attributes - Attr(#10) { // Code + Attr(#13) { // Code 0; // max_stack 0; // max_locals Bytes[]{ @@ -105,10 +113,86 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#11) { // LineNumberTable + Attr(#14) { // LineNumberTable [] { // LineNumberTable - 0 44; - 3 45; + 0 47; + 3 48; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #16; // name_cpx + #12; // sig_cpx + [] { // Attributes + Attr(#13) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xBB000359B700044B; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#14) { // LineNumberTable + [] { // LineNumberTable + 0 51; + 8 52; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #17; // name_cpx + #12; // sig_cpx + [] { // Attributes + Attr(#13) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB200053BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#14) { // LineNumberTable + [] { // LineNumberTable + 0 55; + 4 56; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #18; // name_cpx + #12; // sig_cpx + [] { // Attributes + Attr(#13) { // Code + 1; // max_stack + 0; // max_locals + Bytes[]{ + 0x102AB30005B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#14) { // LineNumberTable + [] { // LineNumberTable + 0 59; + 5 60; } } // end LineNumberTable } // Attributes @@ -118,18 +202,18 @@ } // methods [] { // Attributes - Attr(#13) { // SourceFile - #14; + Attr(#19) { // SourceFile + #20; } // end SourceFile ; - Attr(#15) { // NestMembers - 0x00010011; // modified - #17 + Attr(#21) { // NestMembers + 0x00010003; // modified - #3 } // end NestMembers ; - Attr(#7) { // InnerClasses + Attr(#10) { // InnerClasses [] { // InnerClasses - #5 #3 #6 9; - #17 #22 #6 9; + #8 #6 #9 9; + #3 #24 #9 9; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost2.java 2017-12-06 00:51:55.166140873 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost2.java 2017-12-06 00:51:52.994017094 -0500 @@ -30,16 +30,31 @@ */ public class PackagedNestHost2 { public static class Member { - // jcod file changes this to private + // jcod file will change these to private + public Member() {} + public static int f; public static void m() { System.out.println("You should never see this!"); } - // Entry point for main test - public static void doAccess() { - // this should fail at runtime as m() will now be private - // and our nest-host won't resolve as it's in a different package + // Entry points for main test. + // These should fail at runtime as members will now be private + // and our nest-host won't resolve as it's in a different package. + + public static void doInvoke() { P1.PackagedNestHost.Member.m(); } + + public static void doConstruct() { + Object o = new P1.PackagedNestHost.Member(); + } + + public static void doGetField() { + int x = P1.PackagedNestHost.Member.f; + } + + public static void doPutField() { + P1.PackagedNestHost.Member.f = 42; + } } } --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost2Member.jcod 2017-12-06 00:52:01.730514947 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost2Member.jcod 2017-12-06 00:51:59.558391167 -0500 @@ -22,7 +22,7 @@ */ // NestHost attribute is modified to contain P1.PackagedNestHost -// m() is declared private +// Required members are declared private class P2/PackagedNestHost2$Member { 0xCAFEBABE; @@ -30,64 +30,79 @@ 53; // 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 + Method #10 #26; // #1 + Field #27 #28; // #2 + String #29; // #3 + Method #30 #31; // #4 + Method #6 #32; // #5 + class #34; // #6 + Method #6 #26; // #7 + Field #6 #37; // #8 + class #38; // #9 + class #39; // #10 + Utf8 "f"; // #11 + Utf8 "I"; // #12 + Utf8 ""; // #13 + Utf8 "()V"; // #14 + Utf8 "Code"; // #15 + Utf8 "LineNumberTable"; // #16 + Utf8 "m"; // #17 + Utf8 "doInvoke"; // #18 + Utf8 "doConstruct"; // #19 + Utf8 "doGetField"; // #20 + Utf8 "doPutField"; // #21 + Utf8 "SourceFile"; // #22 + Utf8 "PackagedNestHost2.java"; // #23 + Utf8 "NestHost"; // #24 + class #40; // #25 + NameAndType #13 #14; // #26 + class #41; // #27 + NameAndType #42 #43; // #28 + Utf8 "You should never see this!"; // #29 + class #44; // #30 + NameAndType #45 #46; // #31 + NameAndType #17 #14; // #32 + class #47; // #33 + Utf8 "P1/PackagedNestHost$Member"; // #34 + Utf8 "Member"; // #35 + Utf8 "InnerClasses"; // #36 + NameAndType #11 #12; // #37 + Utf8 "P2/PackagedNestHost2$Member"; // #38 + Utf8 "java/lang/Object"; // #39 + Utf8 "P2/PackagedNestHost2"; // #40 + Utf8 "java/lang/System"; // #41 + Utf8 "out"; // #42 + Utf8 "Ljava/io/PrintStream;"; // #43 + Utf8 "java/io/PrintStream"; // #44 + Utf8 "println"; // #45 + Utf8 "(Ljava/lang/String;)V"; // #46 + Utf8 "P1/PackagedNestHost"; // #47 } // Constant Pool 0x0021; // access - #6;// this_cpx - #7;// super_cpx + #9;// this_cpx + #10;// super_cpx [] { // Interfaces } // Interfaces [] { // fields + { // Member + 0x000A; // access - modified + #11; // name_cpx + #12; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0001; // access - #8; // name_cpx - #9; // sig_cpx + 0x0002; // access - modified + #13; // name_cpx + #14; // sig_cpx [] { // Attributes - Attr(#10) { // Code + Attr(#15) { // Code 1; // max_stack 1; // max_locals Bytes[]{ @@ -96,9 +111,9 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#11) { // LineNumberTable + Attr(#16) { // LineNumberTable [] { // LineNumberTable - 0 32; + 0 34; } } // end LineNumberTable } // Attributes @@ -108,10 +123,10 @@ ; { // Member 0x000A; // access - modified - #12; // name_cpx - #9; // sig_cpx + #17; // name_cpx + #14; // sig_cpx [] { // Attributes - Attr(#10) { // Code + Attr(#15) { // Code 2; // max_stack 0; // max_locals Bytes[]{ @@ -121,10 +136,10 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#11) { // LineNumberTable + Attr(#16) { // LineNumberTable [] { // LineNumberTable - 0 35; - 8 36; + 0 37; + 8 38; } } // end LineNumberTable } // Attributes @@ -134,10 +149,10 @@ ; { // Member 0x0009; // access - #13; // name_cpx - #9; // sig_cpx + #18; // name_cpx + #14; // sig_cpx [] { // Attributes - Attr(#10) { // Code + Attr(#15) { // Code 0; // max_stack 0; // max_locals Bytes[]{ @@ -146,10 +161,86 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#11) { // LineNumberTable + Attr(#16) { // LineNumberTable + [] { // LineNumberTable + 0 45; + 3 46; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #19; // name_cpx + #14; // sig_cpx + [] { // Attributes + Attr(#15) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xBB000659B700074B; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#16) { // LineNumberTable + [] { // LineNumberTable + 0 49; + 8 50; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #20; // name_cpx + #14; // sig_cpx + [] { // Attributes + Attr(#15) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0xB200083BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#16) { // LineNumberTable + [] { // LineNumberTable + 0 53; + 4 54; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #21; // name_cpx + #14; // sig_cpx + [] { // Attributes + Attr(#15) { // Code + 1; // max_stack + 0; // max_locals + Bytes[]{ + 0x102AB30008B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#16) { // LineNumberTable [] { // LineNumberTable - 0 42; - 3 43; + 0 57; + 5 58; } } // end LineNumberTable } // Attributes @@ -159,18 +250,18 @@ } // methods [] { // Attributes - Attr(#14) { // SourceFile - #15; + Attr(#22) { // SourceFile + #23; } // end SourceFile ; - Attr(#16) { // NestHost - 0x0025; // modified - #37 + Attr(#24) { // NestHost + 0x0021; // modified - #33 } // end NestHost ; - Attr(#28) { // InnerClasses + Attr(#36) { // InnerClasses [] { // InnerClasses - #6 #17 #27 9; - #24 #37 #27 9; + #6 #33 #35 9; + #9 #25 #35 9; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHostMember.jcod 2017-12-06 00:52:08.374893580 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHostMember.jcod 2017-12-06 00:52:06.210770257 -0500 @@ -21,7 +21,7 @@ * questions. */ -// m() is declared private +// all members are declared private class P1/PackagedNestHost$Member { 0xCAFEBABE; @@ -29,38 +29,40 @@ 53; // 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 + Method #6 #18; // #1 + Field #19 #20; // #2 + String #21; // #3 + Method #22 #23; // #4 + class #24; // #5 + class #27; // #6 + Utf8 "f"; // #7 + Utf8 "I"; // #8 + Utf8 ""; // #9 + Utf8 "()V"; // #10 + Utf8 "Code"; // #11 + Utf8 "LineNumberTable"; // #12 + Utf8 "m"; // #13 + Utf8 "SourceFile"; // #14 + Utf8 "PackagedNestHost.java"; // #15 + Utf8 "NestHost"; // #16 + class #28; // #17 + NameAndType #9 #10; // #18 + class #29; // #19 + NameAndType #30 #31; // #20 + Utf8 "You should never see this!"; // #21 + class #32; // #22 + NameAndType #33 #34; // #23 + Utf8 "P1/PackagedNestHost$Member"; // #24 + Utf8 "Member"; // #25 + Utf8 "InnerClasses"; // #26 + Utf8 "java/lang/Object"; // #27 + Utf8 "P1/PackagedNestHost"; // #28 + Utf8 "java/lang/System"; // #29 + Utf8 "out"; // #30 + Utf8 "Ljava/io/PrintStream;"; // #31 + Utf8 "java/io/PrintStream"; // #32 + Utf8 "println"; // #33 + Utf8 "(Ljava/lang/String;)V"; // #34 } // Constant Pool 0x0021; // access @@ -71,15 +73,22 @@ } // Interfaces [] { // fields + { // Member + 0x000A; // access - modified + #7; // name_cpx + #8; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0001; // access - #7; // name_cpx - #8; // sig_cpx + 0x0002; // access - modified + #9; // name_cpx + #10; // sig_cpx [] { // Attributes - Attr(#9) { // Code + Attr(#11) { // Code 1; // max_stack 1; // max_locals Bytes[]{ @@ -88,9 +97,9 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#10) { // LineNumberTable + Attr(#12) { // LineNumberTable [] { // LineNumberTable - 0 32; + 0 34; } } // end LineNumberTable } // Attributes @@ -100,10 +109,10 @@ ; { // Member 0x000A; // access - modified - #11; // name_cpx - #8; // sig_cpx + #13; // name_cpx + #10; // sig_cpx [] { // Attributes - Attr(#9) { // Code + Attr(#11) { // Code 2; // max_stack 0; // max_locals Bytes[]{ @@ -113,10 +122,10 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#10) { // LineNumberTable + Attr(#12) { // LineNumberTable [] { // LineNumberTable - 0 35; - 8 36; + 0 37; + 8 38; } } // end LineNumberTable } // Attributes @@ -126,17 +135,17 @@ } // methods [] { // Attributes - Attr(#12) { // SourceFile - #13; + Attr(#14) { // SourceFile + #15; } // end SourceFile ; - Attr(#14) { // NestHost - 0x000F; + Attr(#16) { // NestHost + 0x0011; } // end NestHost ; - Attr(#24) { // InnerClasses + Attr(#26) { // InnerClasses [] { // InnerClasses - #5 #15 #23 9; + #5 #17 #25 9; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetMissingHost.jcod 2017-12-06 00:52:14.919266514 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetMissingHost.jcod 2017-12-06 00:52:12.759143419 -0500 @@ -29,45 +29,47 @@ 53; // version [] { // Constant Pool ; // first element is empty - Method #8 #20; // #1 - String #21; // #2 - Field #7 #22; // #3 - Field #23 #24; // #4 - String #25; // #5 - Method #26 #27; // #6 - class #28; // #7 - class #31; // #8 + Method #8 #22; // #1 + String #23; // #2 + Field #7 #24; // #3 + Field #25 #26; // #4 + String #27; // #5 + Method #28 #29; // #6 + class #30; // #7 + class #33; // #8 Utf8 "msg"; // #9 Utf8 "Ljava/lang/String;"; // #10 - Utf8 ""; // #11 - Utf8 "()V"; // #12 - Utf8 "Code"; // #13 - Utf8 "LineNumberTable"; // #14 - Utf8 "m"; // #15 - Utf8 "SourceFile"; // #16 - Utf8 "TestNestmateMembership.java"; // #17 - Utf8 "NestHost"; // #18 - class #32; // #19 - NameAndType #11 #12; // #20 - Utf8 "NoTargetMissingHost"; // #21 - NameAndType #9 #10; // #22 - class #33; // #23 - NameAndType #34 #35; // #24 - Utf8 "TargetMissingHost.m() - java version"; // #25 - class #36; // #26 - NameAndType #37 #38; // #27 - Utf8 "TestNestmateMembership$TargetMissingHost"; // #28 - Utf8 "TargetMissingHost"; // #29 - Utf8 "InnerClasses"; // #30 - Utf8 "java/lang/Object"; // #31 - Utf8 "TestNestmateMembership"; // #32 - Utf8 "java/lang/System"; // #33 - Utf8 "out"; // #34 - Utf8 "Ljava/io/PrintStream;"; // #35 - Utf8 "java/io/PrintStream"; // #36 - Utf8 "println"; // #37 - Utf8 "(Ljava/lang/String;)V"; // #38 - class #21; // #39 - added + Utf8 "f"; // #11 + Utf8 "I"; // #12 + Utf8 ""; // #13 + Utf8 "()V"; // #14 + Utf8 "Code"; // #15 + Utf8 "LineNumberTable"; // #16 + Utf8 "m"; // #17 + Utf8 "SourceFile"; // #18 + Utf8 "TestNestmateMembership.java"; // #19 + Utf8 "NestHost"; // #20 + class #34; // #21 + NameAndType #13 #14; // #22 + Utf8 "NoTargetMissingHost"; // #23 + NameAndType #9 #10; // #24 + class #35; // #25 + NameAndType #36 #37; // #26 + Utf8 "TargetMissingHost.m() - java version"; // #27 + class #38; // #28 + NameAndType #39 #40; // #29 + Utf8 "TestNestmateMembership$TargetMissingHost"; // #30 + Utf8 "TargetMissingHost"; // #31 + Utf8 "InnerClasses"; // #32 + Utf8 "java/lang/Object"; // #33 + Utf8 "TestNestmateMembership"; // #34 + Utf8 "java/lang/System"; // #35 + Utf8 "out"; // #36 + Utf8 "Ljava/io/PrintStream;"; // #37 + Utf8 "java/io/PrintStream"; // #38 + Utf8 "println"; // #39 + Utf8 "(Ljava/lang/String;)V"; // #40 + class #23; // #41 - added } // Constant Pool 0x0020; // access @@ -85,15 +87,23 @@ [] { // Attributes } // Attributes } // Member + ; + { // Member + 0x000A; // access + #11; // name_cpx + #12; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0000; // access - #11; // name_cpx - #12; // sig_cpx + 0x0002; // access + #13; // name_cpx + #14; // sig_cpx [] { // Attributes - Attr(#13) { // Code + Attr(#15) { // Code 2; // max_stack 1; // max_locals Bytes[]{ @@ -103,10 +113,11 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#14) { // LineNumberTable + Attr(#16) { // LineNumberTable [] { // LineNumberTable - 0 141; - 4 142; + 0 354; + 4 353; + 10 354; } } // end LineNumberTable } // Attributes @@ -116,10 +127,10 @@ ; { // Member 0x000A; // access - #15; // name_cpx - #12; // sig_cpx + #17; // name_cpx + #14; // sig_cpx [] { // Attributes - Attr(#13) { // Code + Attr(#15) { // Code 2; // max_stack 0; // max_locals Bytes[]{ @@ -129,10 +140,10 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#14) { // LineNumberTable + Attr(#16) { // LineNumberTable [] { // LineNumberTable - 0 144; - 8 145; + 0 357; + 8 358; } } // end LineNumberTable } // Attributes @@ -142,17 +153,17 @@ } // methods [] { // Attributes - Attr(#16) { // SourceFile - #17; + Attr(#18) { // SourceFile + #19; } // end SourceFile ; - Attr(#18) { // NestHost - 0x0027; // modified - #39 + Attr(#20) { // NestHost + 0x0029; // modified #41 } // end NestHost ; - Attr(#30) { // InnerClasses + Attr(#32) { // InnerClasses [] { // InnerClasses - #7 #19 #29 8; + #7 #21 #31 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNoHost.jcod 2017-12-06 00:52:23.031728807 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNoHost.jcod 2017-12-06 00:52:20.859605029 -0500 @@ -29,38 +29,40 @@ 53; // 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 "TestNestmateMembership.java"; // #13 - Utf8 "NestHost"; // #14 - class #26; // #15 - NameAndType #7 #8; // #16 - class #27; // #17 - NameAndType #28 #29; // #18 - Utf8 "TargetNoHost.m() - java version"; // #19 - class #30; // #20 - NameAndType #31 #32; // #21 - Utf8 "TestNestmateMembership$TargetNoHost"; // #22 - Utf8 "TargetNoHost"; // #23 - Utf8 "InnerClasses"; // #24 - Utf8 "java/lang/Object"; // #25 - Utf8 "TestNestmateMembership"; // #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 + Method #6 #18; // #1 + Field #19 #20; // #2 + String #21; // #3 + Method #22 #23; // #4 + class #24; // #5 + class #27; // #6 + Utf8 "f"; // #7 + Utf8 "I"; // #8 + Utf8 ""; // #9 + Utf8 "()V"; // #10 + Utf8 "Code"; // #11 + Utf8 "LineNumberTable"; // #12 + Utf8 "m"; // #13 + Utf8 "SourceFile"; // #14 + Utf8 "TestNestmateMembership.java"; // #15 + Utf8 "NestHost"; // #16 + class #28; // #17 + NameAndType #9 #10; // #18 + class #29; // #19 + NameAndType #30 #31; // #20 + Utf8 "TargetNoHost.m() - java version"; // #21 + class #32; // #22 + NameAndType #33 #34; // #23 + Utf8 "TestNestmateMembership$TargetNoHost"; // #24 + Utf8 "TargetNoHost"; // #25 + Utf8 "InnerClasses"; // #26 + Utf8 "java/lang/Object"; // #27 + Utf8 "TestNestmateMembership"; // #28 + Utf8 "java/lang/System"; // #29 + Utf8 "out"; // #30 + Utf8 "Ljava/io/PrintStream;"; // #31 + Utf8 "java/io/PrintStream"; // #32 + Utf8 "println"; // #33 + Utf8 "(Ljava/lang/String;)V"; // #34 } // Constant Pool 0x0020; // access @@ -71,15 +73,22 @@ } // Interfaces [] { // fields + { // Member + 0x000A; // access + #7; // name_cpx + #8; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0000; // access - #7; // name_cpx - #8; // sig_cpx + 0x0002; // access + #9; // name_cpx + #10; // sig_cpx [] { // Attributes - Attr(#9) { // Code + Attr(#11) { // Code 1; // max_stack 1; // max_locals Bytes[]{ @@ -88,9 +97,9 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#10) { // LineNumberTable + Attr(#12) { // LineNumberTable [] { // LineNumberTable - 0 135; + 0 345; } } // end LineNumberTable } // Attributes @@ -100,10 +109,10 @@ ; { // Member 0x000A; // access - #11; // name_cpx - #8; // sig_cpx + #13; // name_cpx + #10; // sig_cpx [] { // Attributes - Attr(#9) { // Code + Attr(#11) { // Code 2; // max_stack 0; // max_locals Bytes[]{ @@ -113,10 +122,10 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#10) { // LineNumberTable + Attr(#12) { // LineNumberTable [] { // LineNumberTable - 0 137; - 8 138; + 0 348; + 8 349; } } // end LineNumberTable } // Attributes @@ -126,13 +135,13 @@ } // methods [] { // Attributes - Attr(#12) { // SourceFile - #13; + Attr(#14) { // SourceFile + #15; } // end SourceFile ; - Attr(#24) { // InnerClasses + Attr(#26) { // InnerClasses [] { // InnerClasses - #5 #15 #23 8; + #5 #17 #25 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotInstanceHost.jcod 2017-12-06 00:52:29.572101514 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotInstanceHost.jcod 2017-12-06 00:52:27.407978190 -0500 @@ -29,41 +29,43 @@ 53; // version [] { // Constant Pool ; // first element is empty - Method #6 #18; // #1 - Field #19 #20; // #2 - String #21; // #3 - Method #22 #23; // #4 - class #24; // #5 - class #27; // #6 + Method #6 #20; // #1 + Field #21 #22; // #2 + String #23; // #3 + Method #24 #25; // #4 + class #26; // #5 + class #29; // #6 Utf8 "oa"; // #7 Utf8 "[Ljava/lang/Object;"; // #8 - Utf8 ""; // #9 - Utf8 "()V"; // #10 - Utf8 "Code"; // #11 - Utf8 "LineNumberTable"; // #12 - Utf8 "m"; // #13 - Utf8 "SourceFile"; // #14 - Utf8 "TestNestmateMembership.java"; // #15 - Utf8 "NestHost"; // #16 - class #28; // #17 - NameAndType #9 #10; // #18 - class #29; // #19 - NameAndType #30 #31; // #20 - Utf8 "TargetNotInstanceHost.m() - java version"; // #21 - class #32; // #22 - NameAndType #33 #34; // #23 - Utf8 "TestNestmateMembership$TargetNotInstanceHost"; // #24 - Utf8 "TargetNotInstanceHost"; // #25 - Utf8 "InnerClasses"; // #26 - Utf8 "java/lang/Object"; // #27 - Utf8 "TestNestmateMembership"; // #28 - Utf8 "java/lang/System"; // #29 - Utf8 "out"; // #30 - Utf8 "Ljava/io/PrintStream;"; // #31 - Utf8 "java/io/PrintStream"; // #32 - Utf8 "println"; // #33 - Utf8 "(Ljava/lang/String;)V"; // #34 - class #8; // #35 added + Utf8 "f"; // #9 + Utf8 "I"; // #10 + Utf8 ""; // #11 + Utf8 "()V"; // #12 + Utf8 "Code"; // #13 + Utf8 "LineNumberTable"; // #14 + Utf8 "m"; // #15 + Utf8 "SourceFile"; // #16 + Utf8 "TestNestmateMembership.java"; // #17 + Utf8 "NestHost"; // #18 + class #30; // #19 + NameAndType #11 #12; // #20 + class #31; // #21 + NameAndType #32 #33; // #22 + Utf8 "TargetNotInstanceHost.m() - java version"; // #23 + class #34; // #24 + NameAndType #35 #36; // #25 + Utf8 "TestNestmateMembership$TargetNotInstanceHost"; // #26 + Utf8 "TargetNotInstanceHost"; // #27 + Utf8 "InnerClasses"; // #28 + Utf8 "java/lang/Object"; // #29 + Utf8 "TestNestmateMembership"; // #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 #8; // #37 added } // Constant Pool 0x0020; // access @@ -81,15 +83,23 @@ [] { // Attributes } // Attributes } // Member + ; + { // Member + 0x000A; // access + #9; // name_cpx + #10; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0000; // access - #9; // name_cpx - #10; // sig_cpx + 0x0002; // access + #11; // name_cpx + #12; // sig_cpx [] { // Attributes - Attr(#11) { // Code + Attr(#13) { // Code 1; // max_stack 1; // max_locals Bytes[]{ @@ -98,9 +108,9 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#14) { // LineNumberTable [] { // LineNumberTable - 0 148; + 0 363; } } // end LineNumberTable } // Attributes @@ -110,10 +120,10 @@ ; { // Member 0x000A; // access - #13; // name_cpx - #10; // sig_cpx + #15; // name_cpx + #12; // sig_cpx [] { // Attributes - Attr(#11) { // Code + Attr(#13) { // Code 2; // max_stack 0; // max_locals Bytes[]{ @@ -123,10 +133,10 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#12) { // LineNumberTable + Attr(#14) { // LineNumberTable [] { // LineNumberTable - 0 151; - 8 152; + 0 366; + 8 367; } } // end LineNumberTable } // Attributes @@ -136,17 +146,17 @@ } // methods [] { // Attributes - Attr(#14) { // SourceFile - #15; + Attr(#16) { // SourceFile + #17; } // end SourceFile ; - Attr(#16) { // NestHost - 0x0023; // modified - #35 + Attr(#18) { // NestHost + 0x0025; // modified - #37 } // end NestHost ; - Attr(#26) { // InnerClasses + Attr(#28) { // InnerClasses [] { // InnerClasses - #5 #17 #25 8; + #5 #19 #27 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotOurHost.jcod 2017-12-06 00:52:36.116474448 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotOurHost.jcod 2017-12-06 00:52:33.952351124 -0500 @@ -29,38 +29,40 @@ 53; // 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 "TestNestmateMembership.java"; // #13 - Utf8 "NestHost"; // #14 - class #26; // #15 - NameAndType #7 #8; // #16 - class #27; // #17 - NameAndType #28 #29; // #18 - Utf8 "TargetNotOurHost.m() - java version"; // #19 - class #30; // #20 - NameAndType #31 #32; // #21 - Utf8 "TestNestmateMembership$TargetNotOurHost"; // #22 - Utf8 "TargetNotOurHost"; // #23 - Utf8 "InnerClasses"; // #24 - Utf8 "java/lang/Object"; // #25 - Utf8 "TestNestmateMembership"; // #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 + Method #6 #18; // #1 + Field #19 #20; // #2 + String #21; // #3 + Method #22 #23; // #4 + class #24; // #5 + class #27; // #6 + Utf8 "f"; // #7 + Utf8 "I"; // #8 + Utf8 ""; // #9 + Utf8 "()V"; // #10 + Utf8 "Code"; // #11 + Utf8 "LineNumberTable"; // #12 + Utf8 "m"; // #13 + Utf8 "SourceFile"; // #14 + Utf8 "TestNestmateMembership.java"; // #15 + Utf8 "NestHost"; // #16 + class #28; // #17 + NameAndType #9 #10; // #18 + class #29; // #19 + NameAndType #30 #31; // #20 + Utf8 "TargetNotOurHost.m() - java version"; // #21 + class #32; // #22 + NameAndType #33 #34; // #23 + Utf8 "TestNestmateMembership$TargetNotOurHost"; // #24 + Utf8 "TargetNotOurHost"; // #25 + Utf8 "InnerClasses"; // #26 + Utf8 "java/lang/Object"; // #27 + Utf8 "TestNestmateMembership"; // #28 + Utf8 "java/lang/System"; // #29 + Utf8 "out"; // #30 + Utf8 "Ljava/io/PrintStream;"; // #31 + Utf8 "java/io/PrintStream"; // #32 + Utf8 "println"; // #33 + Utf8 "(Ljava/lang/String;)V"; // #34 } // Constant Pool 0x0020; // access @@ -71,15 +73,22 @@ } // Interfaces [] { // fields + { // Member + 0x000A; // access + #7; // name_cpx + #8; // sig_cpx + [] { // Attributes + } // Attributes + } // Member } // fields [] { // methods { // Member - 0x0000; // access - #7; // name_cpx - #8; // sig_cpx + 0x0002; // access + #9; // name_cpx + #10; // sig_cpx [] { // Attributes - Attr(#9) { // Code + Attr(#11) { // Code 1; // max_stack 1; // max_locals Bytes[]{ @@ -88,9 +97,9 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#10) { // LineNumberTable + Attr(#12) { // LineNumberTable [] { // LineNumberTable - 0 155; + 0 371; } } // end LineNumberTable } // Attributes @@ -100,10 +109,10 @@ ; { // Member 0x000A; // access - #11; // name_cpx - #8; // sig_cpx + #13; // name_cpx + #10; // sig_cpx [] { // Attributes - Attr(#9) { // Code + Attr(#11) { // Code 2; // max_stack 0; // max_locals Bytes[]{ @@ -113,10 +122,10 @@ [] { // Traps } // end Traps [] { // Attributes - Attr(#10) { // LineNumberTable + Attr(#12) { // LineNumberTable [] { // LineNumberTable - 0 157; - 8 158; + 0 374; + 8 375; } } // end LineNumberTable } // Attributes @@ -126,17 +135,17 @@ } // methods [] { // Attributes - Attr(#12) { // SourceFile - #13; + Attr(#14) { // SourceFile + #15; } // end SourceFile ; - Attr(#14) { // NestHost + Attr(#16) { // NestHost 0x0006; // modified - #6 } // end NestHost ; - Attr(#24) { // InnerClasses + Attr(#26) { // InnerClasses [] { // InnerClasses - #5 #15 #23 8; + #5 #17 #25 8; } } // end InnerClasses } // Attributes --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TestNestmateMembership.java 2017-12-06 00:52:42.660847382 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TestNestmateMembership.java 2017-12-06 00:52:40.492723830 -0500 @@ -24,7 +24,8 @@ /* * @test * @bug 8046171 - * @summary Test the various rules for nest members and nest-hosts + * @summary Test the various rules for nest members and nest-hosts by + * triggering nestmate access checks on all possible paths * @compile TestNestmateMembership.java * PackagedNestHost.java * PackagedNestHost2.java @@ -41,7 +42,11 @@ * PackagedNestHost2Member.jcod * PackagedNestHostMember.jcod * - * @run main/othervm TestNestmateMembership + * @run main/othervm TestNestmateMembership method + * @run main/othervm TestNestmateMembership constructor + * @run main/othervm TestNestmateMembership getField + * @run main/othervm TestNestmateMembership putField + * @run main/othervm -Xcomp TestNestmateMembership getField */ // We test all the "illegal" relationships between a nest member and its nest-host @@ -54,6 +59,10 @@ // Note that all the .java files must be compiled in the same step, while all // .jcod files must be compiled in a later step. +// We test all the different nestmate access check paths: method invocation, constructor +// invocations, field get and field put. The test is invoked four times with each using +// a different test mode. Plus an extra Xcomp run for field access to hit ciField path. +// // As access checking requires resolution and validation of the nest-host of // both the caller class and the target class, we must check that all // combinations of good/bad caller/target are checked for each of the @@ -63,13 +72,33 @@ // - nest-host class is not an instance class // - class is not a member of nest-host's nest // - class and nest-host are in different packages +// +// To provide coverage for reflection and MethodHandle paths through +// JVM_AreNestmates, we add reflection/MH accesses to a subset of the tests. +// We only need to test one case (for Caller.xxx) as all cases use the same path; further +// we don't need to test all failure cases, as all exceptions are equivalent in that regard, +// but for good measure we test the four basic error situations (eliding the different +// package test for simplicity). +// + +import java.lang.invoke.*; +import static java.lang.invoke.MethodHandles.*; +import static java.lang.invoke.MethodType.*; public class TestNestmateMembership { + static final MethodType VOID_T = MethodType.methodType(void.class); + static class Caller { + + private Caller() {} + private static void m() { System.out.println("Caller.m()"); } + + // direct static method invocations + public static void invokeTarget() { Target.m(); } @@ -85,9 +114,184 @@ public static void invokeTargetNotOurHost() { TargetNotOurHost.m(); } + + // reflective static method invocations + + public static void invokeTargetNoHostReflectively() throws Throwable { + TargetNoHost.class.getDeclaredMethod("m", new Class[0]).invoke(null, new Object[0]); + } + public static void invokeTargetMissingHostReflectively() throws Throwable { + TargetMissingHost.class.getDeclaredMethod("m", new Class[0]).invoke(null, new Object[0]); + } + public static void invokeTargetNotInstanceHostReflectively() throws Throwable { + TargetNotInstanceHost.class.getDeclaredMethod("m", new Class[0]).invoke(null, new Object[0]); + } + public static void invokeTargetNotOurHostReflectively() throws Throwable { + TargetNotOurHost.class.getDeclaredMethod("m", new Class[0]).invoke(null, new Object[0]); + } + + // MethodHandle static method lookup (no invoke as the lookup should fail) + + public static void invokeTargetNoHostMH() throws Throwable { + MethodHandle mh = lookup().findStatic(TargetNoHost.class, "m", VOID_T); + } + public static void invokeTargetMissingHostMH() throws Throwable { + MethodHandle mh = lookup().findStatic(TargetMissingHost.class, "m", VOID_T); + } + public static void invokeTargetNotInstanceHostMH() throws Throwable { + MethodHandle mh = lookup().findStatic(TargetNotInstanceHost.class, "m", VOID_T); + } + public static void invokeTargetNotOurHostMH() throws Throwable { + MethodHandle mh = lookup().findStatic(TargetNotOurHost.class, "m", VOID_T); + } + + + // direct constructor invocations + + public static void newTarget() { + Object o = new Target(); + } + public static void newTargetNoHost() { + Object o = new TargetNoHost(); + } + public static void newTargetMissingHost() { + Object o = new TargetMissingHost(); + } + public static void newTargetNotInstanceHost() { + Object o = new TargetNotInstanceHost(); + } + public static void newTargetNotOurHost() { + Object o = new TargetNotOurHost(); + } + + // reflective constructor invocations + + public static void newTargetNoHostReflectively() throws Throwable { + Object o = TargetNoHost.class.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); + } + public static void newTargetMissingHostReflectively() throws Throwable { + Object o = TargetMissingHost.class.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); + } + public static void newTargetNotInstanceHostReflectively() throws Throwable { + Object o = TargetNotInstanceHost.class.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); + } + public static void newTargetNotOurHostReflectively() throws Throwable { + Object o = TargetNotOurHost.class.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); + } + + // MethodHandle constructor lookup (no invoke as the lookup should fail) + + public static void newTargetNoHostMH() throws Throwable { + MethodHandle mh = lookup().findConstructor(TargetNoHost.class, VOID_T); + } + public static void newTargetMissingHostMH() throws Throwable { + MethodHandle mh = lookup().findConstructor(TargetMissingHost.class, VOID_T); + } + public static void newTargetNotInstanceHostMH() throws Throwable { + MethodHandle mh = lookup().findConstructor(TargetNotInstanceHost.class, VOID_T); + } + public static void newTargetNotOurHostMH() throws Throwable { + MethodHandle mh = lookup().findConstructor(TargetNotOurHost.class, VOID_T); + } + + private static int f; + + // direct field accesses + + public static void getFieldTarget() { + int x = Target.f; + } + public static void getFieldTargetNoHost() { + int x = TargetNoHost.f; + } + public static void getFieldTargetMissingHost() { + int x = TargetMissingHost.f; + } + public static void getFieldTargetNotInstanceHost() { + int x = TargetNotInstanceHost.f; + } + public static void getFieldTargetNotOurHost() { + int x = TargetNotOurHost.f; + } + + public static void putFieldTarget() { + Target.f = 42; + } + public static void putFieldTargetNoHost() { + TargetNoHost.f = 42; + } + public static void putFieldTargetMissingHost() { + TargetMissingHost.f = 42; + } + public static void putFieldTargetNotInstanceHost() { + TargetNotInstanceHost.f = 42; + } + public static void putFieldTargetNotOurHost() { + TargetNotOurHost.f = 42; + } + + // reflective field accesses + + public static void getFieldTargetNoHostReflectively() throws Throwable { + int x = TargetNoHost.class.getDeclaredField("f").getInt(null); + } + public static void getFieldTargetMissingHostReflectively() throws Throwable { + int x = TargetMissingHost.class.getDeclaredField("f").getInt(null); + } + public static void getFieldTargetNotInstanceHostReflectively() throws Throwable { + int x = TargetNotInstanceHost.class.getDeclaredField("f").getInt(null); + } + public static void getFieldTargetNotOurHostReflectively() throws Throwable { + int x = TargetNotOurHost.class.getDeclaredField("f").getInt(null); + } + + public static void putFieldTargetNoHostReflectively() throws Throwable { + TargetNoHost.class.getDeclaredField("f").setInt(null, 42); + } + public static void putFieldTargetMissingHostReflectively() throws Throwable { + TargetMissingHost.class.getDeclaredField("f").setInt(null, 42); + } + public static void putFieldTargetNotInstanceHostReflectively() throws Throwable { + TargetNotInstanceHost.class.getDeclaredField("f").setInt(null, 42); + } + public static void putFieldTargetNotOurHostReflectively() throws Throwable { + TargetNotOurHost.class.getDeclaredField("f").setInt(null, 42); + } + + // MethodHandle field lookup (no access as the lookup will fail) + + public static void getFieldTargetNoHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticGetter(TargetNoHost.class, "f", int.class); + } + public static void getFieldTargetMissingHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticGetter(TargetMissingHost.class, "f", int.class); + } + public static void getFieldTargetNotInstanceHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticGetter(TargetNotInstanceHost.class, "f", int.class); + } + public static void getFieldTargetNotOurHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticGetter(TargetNotOurHost.class, "f", int.class); + } + + public static void putFieldTargetNoHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticSetter(TargetNoHost.class, "f", int.class); + } + public static void putFieldTargetMissingHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticSetter(TargetMissingHost.class, "f", int.class); + } + public static void putFieldTargetNotInstanceHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticSetter(TargetNotInstanceHost.class, "f", int.class); + } + public static void putFieldTargetNotOurHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticSetter(TargetNotOurHost.class, "f", int.class); + } + } static class CallerNoHost { + + // method invocations + private static void m() { System.out.println("CallerNoHost.m() - java version"); } @@ -97,10 +301,43 @@ public static void invokeTargetNoHost() { TargetNoHost.m(); } + + // constructor invocations + + private CallerNoHost() {} + + public static void newTarget() { + Object o = new Target(); + } + public static void newTargetNoHost() { + Object o = new TargetNoHost(); + } + + // field accesses + + private static int f; + + public static void getFieldTarget() { + int x = Target.f; + } + public static void getFieldTargetNoHost() { + int x = TargetNoHost.f; + } + + public static void putFieldTarget() { + Target.f = 42; + } + public static void putFieldTargetNoHost() { + TargetNoHost.f = 42; + } + } static class CallerMissingHost { String msg = "NoCallerMissingHost"; // for cp entry + + // method invocations + private static void m() { System.out.println("CallerMissingHost.m() - java version"); } @@ -110,10 +347,42 @@ public static void invokeTargetMissingHost() { TargetMissingHost.m(); } + + // constructor invocations + + private CallerMissingHost() {} + + public static void newTarget() { + Object o = new Target(); + } + public static void newTargetMissingHost() { + Object o = new TargetMissingHost(); + } + + // field accesses + + private static int f; + + public static void getFieldTarget() { + int x = Target.f; + } + public static void getFieldTargetMissingHost() { + int x = TargetMissingHost.f; + } + public static void putFieldTarget() { + Target.f = 42; + } + public static void putFieldTargetMissingHost() { + TargetMissingHost.f = 42; + } + } static class CallerNotInstanceHost { Object[] oa; // create CP entry to use in jcod change + + // method invocations + private static void m() { System.out.println("CallerNotInstanceHost.m() - java version"); } @@ -123,9 +392,40 @@ public static void invokeTargetNotInstanceHost() { TargetNotInstanceHost.m(); } + + // constructor invocations + + private CallerNotInstanceHost() {} + + public static void newTarget() { + Object o = new Target(); + } + public static void newTargetNotInstanceHost() { + Object o = new TargetNotInstanceHost(); + } + + // field accesses + + private static int f; + + public static void getFieldTarget() { + int x = Target.f; + } + public static void getFieldTargetNotInstanceHost() { + int x = TargetNotInstanceHost.f; + } + public static void putFieldTarget() { + Target.f = 42; + } + public static void putFieldTargetNotInstanceHost() { + TargetNotInstanceHost.f = 42; + } } static class CallerNotOurHost { + + // method invocations + private static void m() { System.out.println("CallerNotOurHost.m() - java version"); } @@ -135,15 +435,48 @@ public static void invokeTargetNotOurHost() { TargetNotOurHost.m(); } + + // constructor invocations + + private CallerNotOurHost() {} + + public static void newTarget() { + Object o = new Target(); + } + public static void newTargetNotOurHost() { + Object o = new TargetNotOurHost(); + } + + // field accesses + + private static int f; + + public static void getFieldTarget() { + int x = Target.f; + } + public static void getFieldTargetNotOurHost() { + int x = TargetNotOurHost.f; + } + public static void putFieldTarget() { + Target.f = 42; + } + public static void putFieldTargetNotOurHost() { + TargetNotOurHost.f = 42; + } + } static class Target { + private Target() {} + private static int f; private static void m() { System.out.println("Target.m()"); } } static class TargetNoHost { + private TargetNoHost() {} + private static int f; private static void m() { System.out.println("TargetNoHost.m() - java version"); } @@ -151,6 +484,8 @@ static class TargetMissingHost { String msg = "NoTargetMissingHost"; // for cp entry + private TargetMissingHost() {} + private static int f; private static void m() { System.out.println("TargetMissingHost.m() - java version"); } @@ -158,36 +493,78 @@ static class TargetNotInstanceHost { Object[] oa; // create CP entry to use in jcod change + private TargetNotInstanceHost() {} + private static int f; private static void m() { System.out.println("TargetNotInstanceHost.m() - java version"); } } static class TargetNotOurHost { + private TargetNotOurHost() {} + private static int f; private static void m() { System.out.println("TargetNotOurHost.m() - java version"); } } public static void main(String[] args) throws Throwable { - test_GoodCalls(); - test_NoHost(); - test_MissingHost(); - test_NotInstanceHost(); - test_NotOurHost(); - test_WrongPackageHost(); + if (args.length < 1) { + throw new Error("Test mode argument must be one of: method, constructor, getField or putField"); + } + switch(args[0]) { + case "method": + System.out.println("TESTING METHOD INVOCATIONS:"); + test_GoodInvoke(); + test_NoHostInvoke(); + test_MissingHostInvoke(); + test_NotInstanceHostInvoke(); + test_NotOurHostInvoke(); + test_WrongPackageHostInvoke(); + break; + case "constructor": + System.out.println("TESTING CONSTRUCTOR INVOCATIONS:"); + test_GoodConstruct(); + test_NoHostConstruct(); + test_MissingHostConstruct(); + test_NotInstanceHostConstruct(); + test_NotOurHostConstruct(); + test_WrongPackageHostConstruct(); + break; + case "getField": + System.out.println("TESTING GETFIELD INVOCATIONS:"); + test_GoodGetField(); + test_NoHostGetField(); + test_MissingHostGetField(); + test_NotInstanceHostGetField(); + test_NotOurHostGetField(); + test_WrongPackageHostGetField(); + break; + case "putField": + System.out.println("TESTING PUTFIELD INVOCATIONS:"); + test_GoodPutField(); + test_NoHostPutField(); + test_MissingHostPutField(); + test_NotInstanceHostPutField(); + test_NotOurHostPutField(); + test_WrongPackageHostPutField(); + break; + default: + throw new Error("Uknown mode: " + args[0] + + ". Must be one of: method, constructor, getField or putField"); + } } - static void test_GoodCalls(){ + static void test_GoodInvoke(){ try { Caller.invokeTarget(); } catch (Exception e) { - throw new Error("Unexpected exception on good calls: " + e); + throw new Error("Unexpected exception on good invocation " + e); } } - static void test_NoHost() throws Throwable { + static void test_NoHostInvoke() throws Throwable { System.out.println("Testing for missing nest-host attribute"); String msg = "tried to access method " + "TestNestmateMembership$TargetNoHost.m()V from class " + @@ -199,6 +576,24 @@ catch (IllegalAccessError expected) { check_expected(expected, msg); } + msg = "TestNestmateMembership$Caller cannot access a member of class " + + "TestNestmateMembership$TargetNoHost with modifiers \"private static\""; + try { + Caller.invokeTargetNoHostReflectively(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "no such method: TestNestmateMembership$TargetNoHost.m()void/invokeStatic"; + try { + Caller.invokeTargetNoHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "tried to access method TestNestmateMembership$Target.m()V" + " from class TestNestmateMembership$CallerNoHost"; try { @@ -219,7 +614,7 @@ } } - static void test_MissingHost() throws Throwable { + static void test_MissingHostInvoke() throws Throwable { System.out.println("Testing for nest-host class that does not exist"); String msg = "Unable to load nest-host class (NoTargetMissingHost) of " + "TestNestmateMembership$TargetMissingHost"; @@ -229,13 +624,32 @@ throw new Error("Missing NoClassDefFoundError: " + msg); } catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + try { + Caller.invokeTargetMissingHostReflectively(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + msg = "no such method: TestNestmateMembership$TargetMissingHost.m()void/invokeStatic"; + try { + Caller.invokeTargetMissingHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { check_expected(expected, msg); - Throwable cause = expected.getCause(); - if (cause instanceof NoClassDefFoundError) { - check_expected(cause, cause_msg); - } - else throw new Error("Unexpected NoClassDefFoundError", expected); } + msg = "no such method: TestNestmateMembership$TargetMissingHost.m()void/invokeStatic"; + try { + Caller.invokeTargetMissingHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "Unable to load nest-host class (NoCallerMissingHost) of " + "TestNestmateMembership$CallerMissingHost"; cause_msg = "NoCallerMissingHost"; @@ -244,12 +658,7 @@ throw new Error("Missing NoClassDefFoundError: " + msg); } catch (NoClassDefFoundError expected) { - check_expected(expected, msg); - Throwable cause = expected.getCause(); - if (cause instanceof NoClassDefFoundError) { - check_expected(cause, cause_msg); - } - else throw new Error("Unexpected NoClassDefFoundError", expected); + check_expected(expected, msg, cause_msg); } msg = "Unable to load nest-host class (NoCallerMissingHost) of "+ "TestNestmateMembership$CallerMissingHost"; @@ -259,16 +668,11 @@ throw new Error("Missing NoClassDefFoundError: " + msg); } catch (NoClassDefFoundError expected) { - check_expected(expected, msg); - Throwable cause = expected.getCause(); - if (cause instanceof NoClassDefFoundError) { - check_expected(cause, cause_msg); - } - else throw new Error("Unexpected NoClassDefFoundError", expected); + check_expected(expected, msg, cause_msg); } } - static void test_NotInstanceHost() throws Throwable { + static void test_NotInstanceHostInvoke() throws Throwable { System.out.println("Testing for nest-host class that is not an instance class"); String msg = "Type TestNestmateMembership$TargetNotInstanceHost is not a "+ "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; @@ -279,6 +683,22 @@ catch (IllegalAccessError expected) { check_expected(expected, msg); } + try { + Caller.invokeTargetNotInstanceHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "no such method: TestNestmateMembership$TargetNotInstanceHost.m()void/invokeStatic"; + try { + Caller.invokeTargetNotInstanceHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; try { @@ -299,7 +719,7 @@ } } - static void test_NotOurHost() throws Throwable { + static void test_NotOurHostInvoke() throws Throwable { System.out.println("Testing for nest-host class that does not list us in its nest"); String msg = "Type TestNestmateMembership$TargetNotOurHost is not a nest member" + " of java.lang.Object: current type is not listed as a nest member"; @@ -310,6 +730,22 @@ catch (IllegalAccessError expected) { check_expected(expected, msg); } + try { + Caller.invokeTargetNotOurHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "no such method: TestNestmateMembership$TargetNotOurHost.m()void/invokeStatic"; + try { + Caller.invokeTargetNotOurHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + " of java.lang.Object: current type is not listed as a nest member"; try { @@ -330,19 +766,19 @@ } } - static void test_WrongPackageHost() { + static void test_WrongPackageHostInvoke() { System.out.println("Testing for nest-host and nest-member in different packages"); String msg = "Type P2.PackagedNestHost2$Member is not a nest member of " + "P1.PackagedNestHost: types are in different packages"; try { - P1.PackagedNestHost.doAccess(); + P1.PackagedNestHost.doInvoke(); throw new Error("Missing IllegalAccessError: " + msg); } catch (IllegalAccessError expected) { check_expected(expected, msg); } try { - P2.PackagedNestHost2.Member.doAccess(); + P2.PackagedNestHost2.Member.doInvoke(); throw new Error("Missing IllegalAccessError: " + msg); } catch (IllegalAccessError expected) { @@ -350,11 +786,701 @@ } } - static void check_expected(Throwable expected, String msg) { - if (!expected.getMessage().contains(msg)) - throw new Error("Wrong " + expected.getClass().getSimpleName() +": \"" + - expected.getMessage() + "\" does not contain \"" + - msg + "\""); - System.out.println("OK - got expected exception: " + expected); + // constructor tests + + static void test_GoodConstruct(){ + try { + Caller.newTarget(); + } + catch (Exception e) { + throw new Error("Unexpected exception on good construction: " + e); + } + } + + static void test_NoHostConstruct() throws Throwable { + System.out.println("Testing for missing nest-host attribute"); + String msg = "tried to access method TestNestmateMembership$TargetNoHost.()V" + + " from class TestNestmateMembership$Caller"; + try { + Caller.newTargetNoHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "class TestNestmateMembership$Caller cannot access a member of class " + + "TestNestmateMembership$TargetNoHost with modifiers \"private\""; + try { + Caller.newTargetNoHostReflectively(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "no such constructor: TestNestmateMembership$TargetNoHost.()void/newInvokeSpecial"; + try { + Caller.newTargetNoHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "tried to access method TestNestmateMembership$Target.()V" + + " from class TestNestmateMembership$CallerNoHost"; + try { + CallerNoHost.newTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "tried to access method TestNestmateMembership$TargetNoHost.()V" + + " from class TestNestmateMembership$CallerNoHost"; + try { + CallerNoHost.newTargetNoHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } } + + static void test_MissingHostConstruct() throws Throwable { + System.out.println("Testing for nest-host class that does not exist"); + String msg = "Unable to load nest-host class (NoTargetMissingHost) of " + + "TestNestmateMembership$TargetMissingHost"; + String cause_msg = "NoTargetMissingHost"; + try { + Caller.newTargetMissingHost(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + try { + Caller.newTargetMissingHostReflectively(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + msg = "no such constructor: TestNestmateMembership$TargetMissingHost.()void/newInvokeSpecial"; + try { + Caller.newTargetMissingHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "Unable to load nest-host class (NoCallerMissingHost) of " + + "TestNestmateMembership$CallerMissingHost"; + cause_msg = "NoCallerMissingHost"; + try { + CallerMissingHost.newTarget(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + msg = "Unable to load nest-host class (NoCallerMissingHost) of "+ + "TestNestmateMembership$CallerMissingHost"; + cause_msg = "NoCallerMissingHost"; + try { + CallerMissingHost.newTargetMissingHost(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + } + + static void test_NotInstanceHostConstruct() throws Throwable { + System.out.println("Testing for nest-host class that is not an instance class"); + String msg = "Type TestNestmateMembership$TargetNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + Caller.newTargetNotInstanceHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.newTargetNotInstanceHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "no such constructor: TestNestmateMembership$TargetNotInstanceHost.()void/newInvokeSpecial"; + try { + Caller.newTargetNotInstanceHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + CallerNotInstanceHost.newTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + CallerNotInstanceHost.newTargetNotInstanceHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_NotOurHostConstruct() throws Throwable { + System.out.println("Testing for nest-host class that does not list us in its nest"); + String msg = "Type TestNestmateMembership$TargetNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + Caller.newTargetNotOurHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.newTargetNotOurHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "no such constructor: TestNestmateMembership$TargetNotOurHost.()void/newInvokeSpecial"; + try { + Caller.newTargetNotOurHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + CallerNotOurHost.newTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + CallerNotOurHost.newTargetNotOurHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_WrongPackageHostConstruct() { + System.out.println("Testing for nest-host and nest-member in different packages"); + String msg = "Type P2.PackagedNestHost2$Member is not a nest member of " + + "P1.PackagedNestHost: types are in different packages"; + try { + P1.PackagedNestHost.doConstruct(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + P2.PackagedNestHost2.Member.doConstruct(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + // field tests + + static void test_GoodGetField(){ + try { + Caller.getFieldTarget(); + } + catch (Exception e) { + throw new Error("Unexpected exception on good field access: " + e); + } + } + + static void test_NoHostGetField() throws Throwable { + System.out.println("Testing for missing nest-host attribute"); + String msg = "tried to access field TestNestmateMembership$TargetNoHost.f" + + " from class TestNestmateMembership$Caller"; + try { + Caller.getFieldTargetNoHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "class TestNestmateMembership$Caller cannot access a member of class " + + "TestNestmateMembership$TargetNoHost with modifiers \"private static\""; + try { + Caller.getFieldTargetNoHostReflectively(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "member is private: TestNestmateMembership$TargetNoHost.f/int/getStatic"; + try { + Caller.getFieldTargetNoHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "tried to access field TestNestmateMembership$Target.f" + + " from class TestNestmateMembership$CallerNoHost"; + try { + CallerNoHost.getFieldTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "tried to access field TestNestmateMembership$TargetNoHost.f" + + " from class TestNestmateMembership$CallerNoHost"; + try { + CallerNoHost.getFieldTargetNoHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_MissingHostGetField() throws Throwable { + System.out.println("Testing for nest-host class that does not exist"); + String msg = "Unable to load nest-host class (NoTargetMissingHost) of " + + "TestNestmateMembership$TargetMissingHost"; + String cause_msg = "NoTargetMissingHost"; + try { + Caller.getFieldTargetMissingHost(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + try { + Caller.getFieldTargetMissingHostReflectively(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + try { + Caller.getFieldTargetMissingHostMH(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + + msg = "Unable to load nest-host class (NoCallerMissingHost) of " + + "TestNestmateMembership$CallerMissingHost"; + cause_msg = "NoCallerMissingHost"; + try { + CallerMissingHost.getFieldTarget(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + msg = "Unable to load nest-host class (NoCallerMissingHost) of "+ + "TestNestmateMembership$CallerMissingHost"; + cause_msg = "NoCallerMissingHost"; + try { + CallerMissingHost.getFieldTargetMissingHost(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + } + + static void test_NotInstanceHostGetField() throws Throwable { + System.out.println("Testing for nest-host class that is not an instance class"); + String msg = "Type TestNestmateMembership$TargetNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + Caller.getFieldTargetNotInstanceHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.getFieldTargetNotInstanceHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.getFieldTargetNotInstanceHostMH(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + CallerNotInstanceHost.getFieldTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + CallerNotInstanceHost.getFieldTargetNotInstanceHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_NotOurHostGetField() throws Throwable { + System.out.println("Testing for nest-host class that does not list us in its nest"); + String msg = "Type TestNestmateMembership$TargetNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + Caller.getFieldTargetNotOurHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.getFieldTargetNotOurHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.getFieldTargetNotOurHostMH(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + CallerNotOurHost.getFieldTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + CallerNotOurHost.getFieldTargetNotOurHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_WrongPackageHostGetField() { + System.out.println("Testing for nest-host and nest-member in different packages"); + String msg = "Type P2.PackagedNestHost2$Member is not a nest member of " + + "P1.PackagedNestHost: types are in different packages"; + try { + P1.PackagedNestHost.doGetField(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + P2.PackagedNestHost2.Member.doGetField(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_GoodPutField(){ + try { + Caller.putFieldTarget(); + } + catch (Exception e) { + throw new Error("Unexpected exception on good field access: " + e); + } + } + + static void test_NoHostPutField() throws Throwable { + System.out.println("Testing for missing nest-host attribute"); + String msg = "tried to access field TestNestmateMembership$TargetNoHost.f" + + " from class TestNestmateMembership$Caller"; + try { + Caller.putFieldTargetNoHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "class TestNestmateMembership$Caller cannot access a member of class " + + "TestNestmateMembership$TargetNoHost with modifiers \"private static\""; + try { + Caller.putFieldTargetNoHostReflectively(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + msg = "member is private: TestNestmateMembership$TargetNoHost.f/int/putStatic"; + try { + Caller.putFieldTargetNoHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "tried to access field TestNestmateMembership$Target.f" + + " from class TestNestmateMembership$CallerNoHost"; + try { + CallerNoHost.putFieldTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "tried to access field TestNestmateMembership$TargetNoHost.f" + + " from class TestNestmateMembership$CallerNoHost"; + try { + CallerNoHost.putFieldTargetNoHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_MissingHostPutField() throws Throwable { + System.out.println("Testing for nest-host class that does not exist"); + String msg = "Unable to load nest-host class (NoTargetMissingHost) of " + + "TestNestmateMembership$TargetMissingHost"; + String cause_msg = "NoTargetMissingHost"; + try { + Caller.putFieldTargetMissingHost(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + try { + Caller.putFieldTargetMissingHostReflectively(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + try { + Caller.putFieldTargetMissingHostMH(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + + msg = "Unable to load nest-host class (NoCallerMissingHost) of " + + "TestNestmateMembership$CallerMissingHost"; + cause_msg = "NoCallerMissingHost"; + try { + CallerMissingHost.putFieldTarget(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + msg = "Unable to load nest-host class (NoCallerMissingHost) of "+ + "TestNestmateMembership$CallerMissingHost"; + cause_msg = "NoCallerMissingHost"; + try { + CallerMissingHost.putFieldTargetMissingHost(); + throw new Error("Missing NoClassDefFoundError: " + msg); + } + catch (NoClassDefFoundError expected) { + check_expected(expected, msg, cause_msg); + } + } + + static void test_NotInstanceHostPutField() throws Throwable { + System.out.println("Testing for nest-host class that is not an instance class"); + String msg = "Type TestNestmateMembership$TargetNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + Caller.putFieldTargetNotInstanceHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.putFieldTargetNotInstanceHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.putFieldTargetNotInstanceHostMH(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + CallerNotInstanceHost.putFieldTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ + "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + try { + CallerNotInstanceHost.putFieldTargetNotInstanceHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_NotOurHostPutField() throws Throwable { + System.out.println("Testing for nest-host class that does not list us in its nest"); + String msg = "Type TestNestmateMembership$TargetNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + Caller.putFieldTargetNotOurHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.putFieldTargetNotOurHostReflectively(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + Caller.putFieldTargetNotOurHostMH(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + CallerNotOurHost.putFieldTarget(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + + " of java.lang.Object: current type is not listed as a nest member"; + try { + CallerNotOurHost.putFieldTargetNotOurHost(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + static void test_WrongPackageHostPutField() { + System.out.println("Testing for nest-host and nest-member in different packages"); + String msg = "Type P2.PackagedNestHost2$Member is not a nest member of " + + "P1.PackagedNestHost: types are in different packages"; + try { + P1.PackagedNestHost.doPutField(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + try { + P2.PackagedNestHost2.Member.doPutField(); + throw new Error("Missing IllegalAccessError: " + msg); + } + catch (IllegalAccessError expected) { + check_expected(expected, msg); + } + } + + // utilities + + static void check_expected(Throwable expected, String msg) { + if (!expected.getMessage().contains(msg)) { + throw new Error("Wrong " + expected.getClass().getSimpleName() +": \"" + + expected.getMessage() + "\" does not contain \"" + + msg + "\""); + } + System.out.println("OK - got expected exception: " + expected); + } + + static void check_expected(Throwable expected, String msg, String cause_msg) { + if (!expected.getMessage().contains(msg)) { + throw new Error("Wrong " + expected.getClass().getSimpleName() +": \"" + + expected.getMessage() + "\" does not contain \"" + + msg + "\""); + } + Throwable cause = expected.getCause(); + if (cause instanceof NoClassDefFoundError) { + if (!cause.getMessage().contains(cause_msg)) { + throw new Error(expected.getClass().getSimpleName() + + " has wrong cause " + cause.getClass().getSimpleName() +": \"" + + cause.getMessage() + "\" does not contain \"" + + cause_msg + "\""); + } + } + else throw new Error(expected.getClass().getSimpleName() + + " has wrong cause " + cause.getClass().getSimpleName()); + + System.out.println("OK - got expected exception: " + expected + + " with cause " + cause); + } + } --- old/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/TestMethodHandles.java 2017-12-06 00:52:49.217221001 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/TestMethodHandles.java 2017-12-06 00:52:47.049097449 -0500 @@ -25,7 +25,7 @@ * @test * @bug 8046171 * @summary Test access to private constructors between nestmates and nest-host - * using different flavours of named nested types using method handles + * using different flavours of named nested types using MethodHandles * @run main TestMethodHandles */ --- old/test/hotspot/jtreg/runtime/Nestmates/privateFields/TestMethodHandles.java 2017-12-06 00:52:55.537581170 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateFields/TestMethodHandles.java 2017-12-06 00:52:53.369457618 -0500 @@ -25,7 +25,7 @@ * @test * @bug 8046171 * @summary Test access to private fields between nestmates and nest-host - * using different flavours of named nested types using method handles + * using different flavours of named nested types using MethodHandles * @run main TestMethodHandles */ --- old/test/hotspot/jtreg/runtime/Nestmates/privateStaticFields/TestMethodHandles.java 2017-12-06 00:53:01.497920823 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateStaticFields/TestMethodHandles.java 2017-12-06 00:52:59.329797271 -0500 @@ -25,7 +25,7 @@ * @test * @bug 8046171 * @summary Test access to private static fields between nestmates and nest-host - * using different flavours of named nested types using core reflection + * using different flavours of named nested types using MethodHandles * @run main TestMethodHandles */