--- old/src/hotspot/share/classfile/classFileParser.cpp 2017-12-15 03:44:23.861575005 -0500 +++ new/src/hotspot/share/classfile/classFileParser.cpp 2017-12-15 03:44:21.713452479 -0500 @@ -3178,15 +3178,6 @@ class_info_index, CHECK_0); nest_members->at_put(index++, class_info_index); } - if (_need_verify) { - for (int i = 0; i < length; i++) { - for (int j = i + 1; j < length; j++) { - guarantee_property((nest_members->at(i) != nest_members->at(j)), - "Duplicate entry in NestMembers in class file %s", - CHECK_0); - } - } - } assert(index == size, "wrong size"); // Restore buffer's current position. @@ -3369,35 +3360,6 @@ inner_classes_attribute_start = cfs->current(); inner_classes_attribute_length = attribute_length; cfs->skip_u1(inner_classes_attribute_length, CHECK); - } else if (tag == vmSymbols::tag_nest_members()) { - // Check for NestMembers tag - if (parsed_nest_members_attribute) { - classfile_parse_error("Multiple NestMembers attributes in class file %s", CHECK); - } else { - parsed_nest_members_attribute = true; - } - if (parsed_nest_host_attribute) { - classfile_parse_error("Conflicting NestHost and NestMembers attributes in class file %s", CHECK); - } - nest_members_attribute_start = cfs->current(); - nest_members_attribute_length = attribute_length; - cfs->skip_u1(nest_members_attribute_length, CHECK); - } else if (tag == vmSymbols::tag_nest_host()) { - if (parsed_nest_host_attribute) { - classfile_parse_error("Multiple NestHost attributes in class file %s", CHECK); - } else { - parsed_nest_host_attribute = true; - } - if (parsed_nest_members_attribute) { - classfile_parse_error("Conflicting NestMembers and NestHost attributes in class file %s", CHECK); - } - cfs->guarantee_more(2, CHECK); - u2 class_info_index = cfs->get_u2_fast(); - check_property( - valid_klass_reference_at(class_info_index), - "Nest-host class_info_index %u has bad constant type in class file %s", - class_info_index, CHECK); - _nest_host = class_info_index; } else if (tag == vmSymbols::tag_synthetic()) { // Check for Synthetic tag // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec @@ -3507,6 +3469,37 @@ assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); } cfs->skip_u1(attribute_length, CHECK); + } else if (_major_version >= JAVA_10_VERSION) { + if (tag == vmSymbols::tag_nest_members()) { + // Check for NestMembers tag + if (parsed_nest_members_attribute) { + classfile_parse_error("Multiple NestMembers attributes in class file %s", CHECK); + } else { + parsed_nest_members_attribute = true; + } + if (parsed_nest_host_attribute) { + classfile_parse_error("Conflicting NestHost and NestMembers attributes in class file %s", CHECK); + } + nest_members_attribute_start = cfs->current(); + nest_members_attribute_length = attribute_length; + cfs->skip_u1(nest_members_attribute_length, CHECK); + } else if (tag == vmSymbols::tag_nest_host()) { + if (parsed_nest_host_attribute) { + classfile_parse_error("Multiple NestHost attributes in class file %s", CHECK); + } else { + parsed_nest_host_attribute = true; + } + if (parsed_nest_members_attribute) { + classfile_parse_error("Conflicting NestMembers and NestHost attributes in class file %s", CHECK); + } + cfs->guarantee_more(2, CHECK); + u2 class_info_index = cfs->get_u2_fast(); + check_property( + valid_klass_reference_at(class_info_index), + "Nest-host class_info_index %u has bad constant type in class file %s", + class_info_index, CHECK); + _nest_host = class_info_index; + } } else { // Unknown attribute cfs->skip_u1(attribute_length, CHECK); @@ -3547,7 +3540,7 @@ cfs, nest_members_attribute_start, CHECK); - if (_need_verify && _major_version >= JAVA_10_VERSION) { + if (_need_verify) { guarantee_property( nest_members_attribute_length == sizeof(num_of_classes) + sizeof(u2) * num_of_classes, "Wrong NestMembers attribute length in class file %s", CHECK); --- old/src/hotspot/share/classfile/stackMapFrame.hpp 2017-12-15 03:44:30.581958328 -0500 +++ new/src/hotspot/share/classfile/stackMapFrame.hpp 2017-12-15 03:44:28.441836258 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it --- old/src/hotspot/share/classfile/verifier.cpp 2017-12-15 03:44:37.110330697 -0500 +++ new/src/hotspot/share/classfile/verifier.cpp 2017-12-15 03:44:34.978209084 -0500 @@ -2786,35 +2786,38 @@ } } else if (opcode == Bytecodes::_invokespecial && !is_same_or_direct_interface(current_class(), current_type(), ref_class_type) - && !ref_class_type.equals(VerificationType::reference_type(current_class()->super()->name()))) { - bool subtype = false; - bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; - if (!current_class()->is_anonymous()) { - subtype = ref_class_type.is_assignable_from(current_type(), this, false, CHECK_VERIFY(this)); - } else { - VerificationType host_klass_type = - VerificationType::reference_type(current_class()->host_klass()->name()); - subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this)); + && !ref_class_type.equals(VerificationType::reference_type( + current_class()->super()->name()))) { + bool subtype = false; + bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; + if (!current_class()->is_anonymous()) { + subtype = ref_class_type.is_assignable_from( + current_type(), this, false, CHECK_VERIFY(this)); + } else { + VerificationType host_klass_type = + VerificationType::reference_type(current_class()->host_klass()->name()); + subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this)); - // If invokespecial of IMR, need to recheck for same or - // direct interface relative to the host class - have_imr_indirect = (have_imr_indirect && - !is_same_or_direct_interface(current_class()->host_klass(), - host_klass_type, ref_class_type)); - } - if (!subtype) { - verify_error(ErrorContext::bad_code(bci), - "Bad invokespecial instruction: " - "current class isn't assignable to reference class."); - return; - } else if (have_imr_indirect) { - verify_error(ErrorContext::bad_code(bci), - "Bad invokespecial instruction: " - "interface method reference is in an indirect superinterface."); + // If invokespecial of IMR, need to recheck for same or + // direct interface relative to the host class + have_imr_indirect = (have_imr_indirect && + !is_same_or_direct_interface( + current_class()->host_klass(), + host_klass_type, ref_class_type)); + } + if (!subtype) { + verify_error(ErrorContext::bad_code(bci), + "Bad invokespecial instruction: " + "current class isn't assignable to reference class."); return; - } - } + } else if (have_imr_indirect) { + verify_error(ErrorContext::bad_code(bci), + "Bad invokespecial instruction: " + "interface method reference is in an indirect superinterface."); + return; + } + } // Match method descriptor with operand stack for (int i = nargs - 1; i >= 0; i--) { // Run backwards current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this)); @@ -2828,7 +2831,7 @@ CHECK_VERIFY(this)); if (was_recursively_verified()) return; } else { // other methods - // Ensures that target class is assignable to current class (4.9.2) + // Ensures that target class is assignable to method class. if (opcode == Bytecodes::_invokespecial) { if (!current_class()->is_anonymous()) { current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); @@ -2841,10 +2844,10 @@ VerificationType::reference_type(current_class()->host_klass()->name()); bool subtype = hosttype.is_assignable_from(top, this, false, CHECK_VERIFY(this)); if (!subtype) { - verify_error(ErrorContext::bad_type(current_frame->offset(), - current_frame->stack_top_ctx(), - TypeOrigin::implicit(top)), - "Bad type on operand stack"); + verify_error( ErrorContext::bad_type(current_frame->offset(), + current_frame->stack_top_ctx(), + TypeOrigin::implicit(top)), + "Bad type on operand stack"); return; } } --- old/src/hotspot/share/interpreter/linkResolver.cpp 2017-12-15 03:44:43.702706718 -0500 +++ new/src/hotspot/share/interpreter/linkResolver.cpp 2017-12-15 03:44:41.562584648 -0500 @@ -818,9 +818,6 @@ #endif // PRODUCT } -// FIXME: update to correct version -#define VIRTUAL_PRIVATE_ACCESS_VERSION 53 - // Do linktime resolution of a method in the interface within the context of the specied bytecode. methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) { @@ -885,21 +882,6 @@ THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } - if (code == Bytecodes::_invokeinterface && resolved_method->is_private()) { - Klass* current_klass = link_info.current_klass(); - assert(current_klass != NULL, "current_klass should not be null for invokeinterface"); - if (InstanceKlass::cast(current_klass)->major_version() < VIRTUAL_PRIVATE_ACCESS_VERSION) { - ResourceMark rm(THREAD); - char buf[200]; - jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s, caller-class:%s", - Method::name_and_sig_as_C_string(resolved_klass, - resolved_method->name(), - resolved_method->signature()), - current_klass->internal_name()); - THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); - } - } - if (log_develop_is_enabled(Trace, itables)) { char buf[200]; jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:", --- old/src/hotspot/share/oops/instanceKlass.cpp 2017-12-15 03:44:50.267081140 -0500 +++ new/src/hotspot/share/oops/instanceKlass.cpp 2017-12-15 03:44:48.130959299 -0500 @@ -242,16 +242,17 @@ const char* error = NULL; - // Need to check we have an instance class first - if (k->is_instance_klass()) { - nest_host_k = InstanceKlass::cast(k); - - // FIXME: an exception from this is perhaps impossible - bool is_member = nest_host_k->has_nest_member(this, CHECK_NULL); - if (is_member) { - // Finally check we're in the same package - as there could be collusion - // between untrusted types. - if (is_same_class_package(nest_host_k)) { + // JVMS 5.4.4 indicates package check comes first + if (is_same_class_package(k)) { + + // Now check actual membership. We can't be a member if our "host" is + // not an instance class. + if (k->is_instance_klass()) { + nest_host_k = InstanceKlass::cast(k); + + // FIXME: an exception from this is perhaps impossible + bool is_member = nest_host_k->has_nest_member(this, CHECK_NULL); + if (is_member) { // save resolved nest-host value _nest_host = nest_host_k; @@ -262,16 +263,11 @@ } return nest_host_k; } - else { - error = "types are in different packages"; - } - } - else { - error = "current type is not listed as a nest member"; } + error = "current type is not listed as a nest member"; } else { - error = "nest-host is not an instance class!"; + error = "types are in different packages"; } if (log_is_enabled(Trace, class, nestmates)) { @@ -314,18 +310,18 @@ assert(this != k, "this should be handled by higher-level code"); - // Per the JVMS we first resolve and validate the current class, then + // Per JVMS 5.4.4 we first resolve and validate the current class, then // the target class k. Resolution exceptions will be passed on by upper - // layers. IllegalAccessErrors from membership validation failures will - // also be passed through. + // layers. IncompatibleClassChangeErrors from membership validation failures + // will also be passed through. - Symbol* iae = vmSymbols::java_lang_IllegalAccessError(); - InstanceKlass* cur_host = nest_host(iae, THREAD); + Symbol* icce = vmSymbols::java_lang_IncompatibleClassChangeError(); + InstanceKlass* cur_host = nest_host(icce, THREAD); if (cur_host == NULL || HAS_PENDING_EXCEPTION) { return false; } - Klass* k_nest_host = k->nest_host(iae, THREAD); + Klass* k_nest_host = k->nest_host(icce, THREAD); if (k_nest_host == NULL || HAS_PENDING_EXCEPTION) { return false; } --- old/src/hotspot/share/oops/instanceKlass.hpp 2017-12-15 03:44:58.935575577 -0500 +++ new/src/hotspot/share/oops/instanceKlass.hpp 2017-12-15 03:44:55.359371595 -0500 @@ -458,7 +458,7 @@ // Called to verify that k is a member of this nest - does not look at k's nest-host bool has_nest_member(InstanceKlass* k, TRAPS) const; - // Check if this klass is a nestmate of k + // Check if this klass is a nestmate of k - resolves this nest-host and k's bool has_nestmate_access_to(InstanceKlass* k, TRAPS); enum InnerClassAttributeOffset { --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/BadNestHost.jcod 2017-12-15 03:45:05.515950910 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/BadNestHost.jcod 2017-12-15 03:45:03.359827930 -0500 @@ -34,7 +34,7 @@ class NestmateAttributeHolder$BadNestHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/BadNestMembersEntry.jcod 2017-12-15 03:45:12.240334459 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/BadNestMembersEntry.jcod 2017-12-15 03:45:10.056209880 -0500 @@ -34,7 +34,7 @@ class BadNestMembersEntry { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #14; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/BadNestMembersLength.jcod 2017-12-15 03:45:18.792708194 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/BadNestMembersLength.jcod 2017-12-15 03:45:16.624584528 -0500 @@ -34,7 +34,7 @@ class BadNestMembersLength { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #14; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/ConflictingAttributesInNestHost.jcod 2017-12-15 03:45:25.413085808 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/ConflictingAttributesInNestHost.jcod 2017-12-15 03:45:23.168957807 -0500 @@ -34,7 +34,7 @@ class ConflictingAttributesInNestHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #14; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/ConflictingAttributesInNestMember.jcod 2017-12-15 03:45:31.989460912 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/ConflictingAttributesInNestMember.jcod 2017-12-15 03:45:29.821337246 -0500 @@ -32,7 +32,7 @@ class NestmateAttributeHolder$ConflictingAttributesInNestMember { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TestNestmateAttributes.java 2017-12-15 03:45:38.537834418 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TestNestmateAttributes.java 2017-12-15 03:45:36.365710524 -0500 @@ -31,7 +31,6 @@ * ConflictingAttributesInNestMember.jcod * BadNestMembersLength.jcod * BadNestMembersEntry.jcod - * DuplicateNestMemberEntry.jcod * BadNestHost.jcod * @run main TestNestmateAttributes */ @@ -45,7 +44,6 @@ "NestmateAttributeHolder$ConflictingAttributesInNestMember", "BadNestMembersLength", "BadNestMembersEntry", - "DuplicateNestMemberEntry", "NestmateAttributeHolder$BadNestHost", }; @@ -54,12 +52,11 @@ "Multiple NestMembers attributes in class file", "Conflicting NestMembers and NestHost attributes", "Conflicting NestHost and NestMembers attributes", - "Wrong NestMembers attribute length", + "Wrong NestMembers attribute length", "Nest member class_info_index 9 has bad constant type", - "Duplicate entry in NestMembers ", "Nest-host class_info_index 10 has bad constant type", }; - + for (int i = 0; i < badClasses.length; i++ ) { try { Class c = Class.forName(badClasses[i]); --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TwoNestHost.jcod 2017-12-15 03:45:45.106209064 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TwoNestHost.jcod 2017-12-15 03:45:42.930084942 -0500 @@ -33,7 +33,7 @@ class NestmateAttributeHolder$TwoNestHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TwoNestMembers.jcod 2017-12-15 03:45:51.646582112 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/TwoNestMembers.jcod 2017-12-15 03:45:49.486458904 -0500 @@ -34,7 +34,7 @@ class NestmateAttributeHolder { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #14; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerMissingHost.jcod 2017-12-15 03:46:00.231071752 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerMissingHost.jcod 2017-12-15 03:45:56.634866633 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$CallerMissingHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Field #38 #39; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNoHost.jcod 2017-12-15 03:46:06.807446852 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNoHost.jcod 2017-12-15 03:46:04.619322047 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$CallerNoHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Field #34 #35; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotInstanceHost.jcod 2017-12-15 03:46:13.631836099 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotInstanceHost.jcod 2017-12-15 03:46:11.191696918 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$CallerNotInstanceHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Field #36 #37; // #1 @@ -44,7 +44,7 @@ class #49; // #13 class #51; // #14 Utf8 "oa"; // #15 - Utf8 "[Ljava/lang/Object;"; // #16 + Utf8 "[LInvalidNestHost;"; // #16 Utf8 "f"; // #17 Utf8 "I"; // #18 Utf8 "m"; // #19 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotOurHost.jcod 2017-12-15 03:46:20.180209601 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerNotOurHost.jcod 2017-12-15 03:46:18.020086393 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$CallerNotOurHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Field #34 #35; // #1 @@ -85,6 +85,9 @@ Utf8 "java/io/PrintStream"; // #54 Utf8 "println"; // #55 Utf8 "(Ljava/lang/String;)V"; // #56 + // Added + Utf8 "InvalidNestHost"; // #57 + class #57; // #58 } // Constant Pool 0x0020; // access @@ -364,7 +367,7 @@ } // end SourceFile ; Attr(#32) { // NestHost - 0x000E; // modified - #14 + 0x003A; // modified - #58 } // end NestHost ; Attr(#43) { // InnerClasses --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost.jcod 2017-12-15 03:46:26.820588351 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost.jcod 2017-12-15 03:46:24.580460580 -0500 @@ -26,7 +26,7 @@ class P1/PackagedNestHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #7 #22; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost2Member.jcod 2017-12-15 03:46:33.368961853 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHost2Member.jcod 2017-12-15 03:46:31.204838417 -0500 @@ -27,7 +27,7 @@ class P2/PackagedNestHost2$Member { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #10 #26; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHostMember.jcod 2017-12-15 03:46:39.913335126 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/PackagedNestHostMember.jcod 2017-12-15 03:46:37.749211690 -0500 @@ -26,7 +26,7 @@ class P1/PackagedNestHost$Member { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #18; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetMissingHost.jcod 2017-12-15 03:46:46.461708626 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetMissingHost.jcod 2017-12-15 03:46:44.293584963 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$TargetMissingHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #8 #22; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNoHost.jcod 2017-12-15 03:46:53.262096500 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNoHost.jcod 2017-12-15 03:46:50.849958919 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$TargetNoHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #18; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotInstanceHost.jcod 2017-12-15 03:47:01.590571531 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotInstanceHost.jcod 2017-12-15 03:46:57.990366186 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$TargetNotInstanceHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #20; // #1 @@ -36,7 +36,7 @@ class #26; // #5 class #29; // #6 Utf8 "oa"; // #7 - Utf8 "[Ljava/lang/Object;"; // #8 + Utf8 "[LInvalidNestHost;"; // #8 - modified Utf8 "f"; // #9 Utf8 "I"; // #10 Utf8 ""; // #11 --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotOurHost.jcod 2017-12-15 03:47:08.126944345 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetNotOurHost.jcod 2017-12-15 03:47:05.958820683 -0500 @@ -26,7 +26,7 @@ class TestNestmateMembership$TargetNotOurHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #18; // #1 @@ -63,6 +63,9 @@ Utf8 "java/io/PrintStream"; // #32 Utf8 "println"; // #33 Utf8 "(Ljava/lang/String;)V"; // #34 + // Added + Utf8 "InvalidNestHost"; // #35 + class #35; // #36 } // Constant Pool 0x0020; // access @@ -140,7 +143,7 @@ } // end SourceFile ; Attr(#16) { // NestHost - 0x0006; // modified - #6 + 0x0024; // modified - #36 } // end NestHost ; Attr(#26) { // InnerClasses --- old/test/hotspot/jtreg/runtime/Nestmates/membership/TestNestmateMembership.java 2017-12-15 03:47:14.675317844 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TestNestmateMembership.java 2017-12-15 03:47:12.507194181 -0500 @@ -29,15 +29,18 @@ * @compile TestNestmateMembership.java * PackagedNestHost.java * PackagedNestHost2.java + * InvalidNestHost.java * * @compile TargetNoHost.jcod * CallerNoHost.jcod + * TargetSelfHost.jcod + * CallerSelfHost.jcod * TargetMissingHost.jcod * CallerMissingHost.jcod - * CallerNotInstanceHost.jcod * TargetNotInstanceHost.jcod - * CallerNotOurHost.jcod + * CallerNotInstanceHost.jcod * TargetNotOurHost.jcod + * CallerNotOurHost.jcod * PackagedNestHost.jcod * PackagedNestHost2Member.jcod * PackagedNestHostMember.jcod @@ -55,7 +58,8 @@ // be a way to construct that scenario. // For each nested class below there is a corresponding .jcod file which breaks one // of the rules regarding nest membership. For the package related tests we have -// additional PackageNestHost*.java sources. +// additional PackageNestHost*.java sources.[1] +// // Note that all the .java files must be compiled in the same step, while all // .jcod files must be compiled in a later step. @@ -68,9 +72,10 @@ // combinations of good/bad caller/target are checked for each of the // possible errors: // - no nest-host attribute +// - nest-host refers to self // - nest-host class can not be found -// - nest-host class is not an instance class -// - class is not a member of nest-host's nest +// - nest-host class is not an instance class (but is in same package) +// - class is not a member of nest-host's nest (but is in same package) // - class and nest-host are in different packages // // To provide coverage for reflection and MethodHandle paths through @@ -80,6 +85,12 @@ // but for good measure we test the four basic error situations (eliding the different // package test for simplicity). // +// [1] In earlier versions the package-test was the final check done in nest membership +// validation, so we needed actual test classes in different packages that claimed +// membership. The final spec requires the package test to be done first, so it can +// be trivially tested by using Object as the nest-host. But we leave the explicit +// package tests as they are, and adjust the other tests so that a "bad host" is +// always in the same package. import java.lang.invoke.*; import static java.lang.invoke.MethodHandles.*; @@ -105,6 +116,9 @@ public static void invokeTargetNoHost() { TargetNoHost.m(); } + public static void invokeTargetSelfHost() { + TargetSelfHost.m(); + } public static void invokeTargetMissingHost() { TargetMissingHost.m(); } @@ -120,6 +134,9 @@ public static void invokeTargetNoHostReflectively() throws Throwable { TargetNoHost.class.getDeclaredMethod("m", new Class[0]).invoke(null, new Object[0]); } + public static void invokeTargetSelfHostReflectively() throws Throwable { + TargetSelfHost.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]); } @@ -135,6 +152,9 @@ public static void invokeTargetNoHostMH() throws Throwable { MethodHandle mh = lookup().findStatic(TargetNoHost.class, "m", VOID_T); } + public static void invokeTargetSelfHostMH() throws Throwable { + MethodHandle mh = lookup().findStatic(TargetSelfHost.class, "m", VOID_T); + } public static void invokeTargetMissingHostMH() throws Throwable { MethodHandle mh = lookup().findStatic(TargetMissingHost.class, "m", VOID_T); } @@ -154,6 +174,9 @@ public static void newTargetNoHost() { Object o = new TargetNoHost(); } + public static void newTargetSelfHost() { + Object o = new TargetSelfHost(); + } public static void newTargetMissingHost() { Object o = new TargetMissingHost(); } @@ -169,6 +192,9 @@ public static void newTargetNoHostReflectively() throws Throwable { Object o = TargetNoHost.class.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); } + public static void newTargetSelfHostReflectively() throws Throwable { + Object o = TargetSelfHost.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]); } @@ -184,6 +210,9 @@ public static void newTargetNoHostMH() throws Throwable { MethodHandle mh = lookup().findConstructor(TargetNoHost.class, VOID_T); } + public static void newTargetSelfHostMH() throws Throwable { + MethodHandle mh = lookup().findConstructor(TargetSelfHost.class, VOID_T); + } public static void newTargetMissingHostMH() throws Throwable { MethodHandle mh = lookup().findConstructor(TargetMissingHost.class, VOID_T); } @@ -204,6 +233,9 @@ public static void getFieldTargetNoHost() { int x = TargetNoHost.f; } + public static void getFieldTargetSelfHost() { + int x = TargetSelfHost.f; + } public static void getFieldTargetMissingHost() { int x = TargetMissingHost.f; } @@ -220,6 +252,9 @@ public static void putFieldTargetNoHost() { TargetNoHost.f = 42; } + public static void putFieldTargetSelfHost() { + TargetSelfHost.f = 42; + } public static void putFieldTargetMissingHost() { TargetMissingHost.f = 42; } @@ -235,6 +270,9 @@ public static void getFieldTargetNoHostReflectively() throws Throwable { int x = TargetNoHost.class.getDeclaredField("f").getInt(null); } + public static void getFieldTargetSelfHostReflectively() throws Throwable { + int x = TargetSelfHost.class.getDeclaredField("f").getInt(null); + } public static void getFieldTargetMissingHostReflectively() throws Throwable { int x = TargetMissingHost.class.getDeclaredField("f").getInt(null); } @@ -248,6 +286,9 @@ public static void putFieldTargetNoHostReflectively() throws Throwable { TargetNoHost.class.getDeclaredField("f").setInt(null, 42); } + public static void putFieldTargetSelfHostReflectively() throws Throwable { + TargetSelfHost.class.getDeclaredField("f").setInt(null, 42); + } public static void putFieldTargetMissingHostReflectively() throws Throwable { TargetMissingHost.class.getDeclaredField("f").setInt(null, 42); } @@ -263,6 +304,9 @@ public static void getFieldTargetNoHostMH() throws Throwable { MethodHandle mh = lookup().findStaticGetter(TargetNoHost.class, "f", int.class); } + public static void getFieldTargetSelfHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticGetter(TargetSelfHost.class, "f", int.class); + } public static void getFieldTargetMissingHostMH() throws Throwable { MethodHandle mh = lookup().findStaticGetter(TargetMissingHost.class, "f", int.class); } @@ -276,6 +320,9 @@ public static void putFieldTargetNoHostMH() throws Throwable { MethodHandle mh = lookup().findStaticSetter(TargetNoHost.class, "f", int.class); } + public static void putFieldTargetSelfHostMH() throws Throwable { + MethodHandle mh = lookup().findStaticSetter(TargetSelfHost.class, "f", int.class); + } public static void putFieldTargetMissingHostMH() throws Throwable { MethodHandle mh = lookup().findStaticSetter(TargetMissingHost.class, "f", int.class); } @@ -333,6 +380,51 @@ } + static class CallerSelfHost { + + // method invocations + + private static void m() { + System.out.println("CallerSelfHost.m() - java version"); + } + public static void invokeTarget() { + Target.m(); + } + public static void invokeTargetSelfHost() { + TargetSelfHost.m(); + } + + // constructor invocations + + private CallerSelfHost() {} + + public static void newTarget() { + Object o = new Target(); + } + public static void newTargetSelfHost() { + Object o = new TargetSelfHost(); + } + + // field accesses + + private static int f; + + public static void getFieldTarget() { + int x = Target.f; + } + public static void getFieldTargetSelfHost() { + int x = TargetSelfHost.f; + } + + public static void putFieldTarget() { + Target.f = 42; + } + public static void putFieldTargetSelfHost() { + TargetSelfHost.f = 42; + } + + } + static class CallerMissingHost { String msg = "NoCallerMissingHost"; // for cp entry @@ -482,6 +574,14 @@ } } + static class TargetSelfHost { + private TargetSelfHost() {} + private static int f; + private static void m() { + System.out.println("TargetSelfHost.m() - java version"); + } + } + static class TargetMissingHost { String msg = "NoTargetMissingHost"; // for cp entry private TargetMissingHost() {} @@ -517,6 +617,7 @@ System.out.println("TESTING METHOD INVOCATIONS:"); test_GoodInvoke(); test_NoHostInvoke(); + test_SelfHostInvoke(); test_MissingHostInvoke(); test_NotInstanceHostInvoke(); test_NotOurHostInvoke(); @@ -526,6 +627,7 @@ System.out.println("TESTING CONSTRUCTOR INVOCATIONS:"); test_GoodConstruct(); test_NoHostConstruct(); + test_SelfHostConstruct(); test_MissingHostConstruct(); test_NotInstanceHostConstruct(); test_NotOurHostConstruct(); @@ -535,6 +637,7 @@ System.out.println("TESTING GETFIELD INVOCATIONS:"); test_GoodGetField(); test_NoHostGetField(); + test_SelfHostGetField(); test_MissingHostGetField(); test_NotInstanceHostGetField(); test_NotOurHostGetField(); @@ -544,6 +647,7 @@ System.out.println("TESTING PUTFIELD INVOCATIONS:"); test_GoodPutField(); test_NoHostPutField(); + test_SelfHostPutField(); test_MissingHostPutField(); test_NotInstanceHostPutField(); test_NotOurHostPutField(); @@ -614,6 +718,53 @@ } } + static void test_SelfHostInvoke() throws Throwable { + System.out.println("Testing for class that lists itself as nest-host"); + String msg = "Type TestNestmateMembership$TargetSelfHost is not a nest member" + + " of TestNestmateMembership$TargetSelfHost: current type is not listed as a nest member"; + try { + Caller.invokeTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + try { + Caller.invokeTargetSelfHostReflectively(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + msg = "no such method: TestNestmateMembership$TargetSelfHost.m()void/invokeStatic"; + try { + Caller.invokeTargetSelfHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.invokeTarget(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.invokeTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + } + 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 " + @@ -675,19 +826,19 @@ 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { Caller.invokeTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.invokeTargetNotInstanceHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } msg = "no such method: TestNestmateMembership$TargetNotInstanceHost.m()void/invokeStatic"; @@ -700,21 +851,21 @@ } msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ - "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.invokeTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.invokeTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -722,19 +873,19 @@ 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { Caller.invokeTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.invokeTargetNotOurHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } msg = "no such method: TestNestmateMembership$TargetNotOurHost.m()void/invokeStatic"; @@ -747,21 +898,21 @@ } msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + - " of java.lang.Object: current type is not listed as a nest member"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.invokeTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.invokeTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -772,16 +923,16 @@ "P1.PackagedNestHost: types are in different packages"; try { P1.PackagedNestHost.doInvoke(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { P2.PackagedNestHost2.Member.doInvoke(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -803,9 +954,9 @@ " from class TestNestmateMembership$Caller"; try { Caller.newTargetNoHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } msg = "class TestNestmateMembership$Caller cannot access a member of class " + @@ -830,18 +981,65 @@ " from class TestNestmateMembership$CallerNoHost"; try { CallerNoHost.newTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + } + + static void test_SelfHostConstruct() throws Throwable { + System.out.println("Testing for class that lists itself as nest-host"); + String msg = "Type TestNestmateMembership$TargetSelfHost is not a nest member" + + " of TestNestmateMembership$TargetSelfHost: current type is not listed as a nest member"; + try { + Caller.newTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + try { + Caller.newTargetSelfHostReflectively(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + msg = "no such constructor: TestNestmateMembership$TargetSelfHost.()void/newInvokeSpecial"; + try { + Caller.newTargetSelfHostMH(); + throw new Error("Missing IllegalAccessException: " + msg); + } + catch (IllegalAccessException expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.newTarget(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.newTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -899,19 +1097,19 @@ 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { Caller.newTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.newTargetNotInstanceHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } msg = "no such constructor: TestNestmateMembership$TargetNotInstanceHost.()void/newInvokeSpecial"; @@ -924,21 +1122,21 @@ } msg = "Type TestNestmateMembership$CallerNotInstanceHost is not a "+ - "nest member of [Ljava.lang.Object;: nest-host is not an instance class"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.newTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.newTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -946,19 +1144,19 @@ 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { Caller.newTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.newTargetNotOurHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } msg = "no such constructor: TestNestmateMembership$TargetNotOurHost.()void/newInvokeSpecial"; @@ -971,21 +1169,21 @@ } msg = "Type TestNestmateMembership$CallerNotOurHost is not a nest member" + - " of java.lang.Object: current type is not listed as a nest member"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.newTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.newTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -996,16 +1194,16 @@ "P1.PackagedNestHost: types are in different packages"; try { P1.PackagedNestHost.doConstruct(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { P2.PackagedNestHost2.Member.doConstruct(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1027,9 +1225,9 @@ " from class TestNestmateMembership$Caller"; try { Caller.getFieldTargetNoHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } msg = "class TestNestmateMembership$Caller cannot access a member of class " + @@ -1054,18 +1252,64 @@ " from class TestNestmateMembership$CallerNoHost"; try { CallerNoHost.getFieldTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + } + + static void test_SelfHostGetField() throws Throwable { + System.out.println("Testing for class that lists itself as nest-host"); + String msg = "Type TestNestmateMembership$TargetSelfHost is not a nest member" + + " of TestNestmateMembership$TargetSelfHost: current type is not listed as a nest member"; + try { + Caller.getFieldTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + try { + Caller.getFieldTargetSelfHostReflectively(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + try { + Caller.getFieldTargetSelfHostMH(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.getFieldTarget(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.getFieldTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1122,45 +1366,45 @@ 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { Caller.getFieldTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.getFieldTargetNotInstanceHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.getFieldTargetNotInstanceHostMH(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.getFieldTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.getFieldTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1168,45 +1412,45 @@ 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { Caller.getFieldTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.getFieldTargetNotOurHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.getFieldTargetNotOurHostMH(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.getFieldTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.getFieldTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1217,16 +1461,16 @@ "P1.PackagedNestHost: types are in different packages"; try { P1.PackagedNestHost.doGetField(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { P2.PackagedNestHost2.Member.doGetField(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1246,9 +1490,9 @@ " from class TestNestmateMembership$Caller"; try { Caller.putFieldTargetNoHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } msg = "class TestNestmateMembership$Caller cannot access a member of class " + @@ -1273,18 +1517,64 @@ " from class TestNestmateMembership$CallerNoHost"; try { CallerNoHost.putFieldTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + } + + static void test_SelfHostPutField() throws Throwable { + System.out.println("Testing for class that lists itself as nest-host"); + String msg = "Type TestNestmateMembership$TargetSelfHost is not a nest member" + + " of TestNestmateMembership$TargetSelfHost: current type is not listed as a nest member"; + try { + Caller.putFieldTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + try { + Caller.putFieldTargetSelfHostReflectively(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + try { + Caller.putFieldTargetSelfHostMH(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.putFieldTarget(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { + check_expected(expected, msg); + } + msg = "Type TestNestmateMembership$CallerSelfHost is not a nest member" + + " of TestNestmateMembership$CallerSelfHost: current type is not listed as a nest member"; + try { + CallerSelfHost.putFieldTargetSelfHost(); + throw new Error("Missing IncompatibleClassChangeError: " + msg); + } + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1341,45 +1631,45 @@ 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { Caller.putFieldTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.putFieldTargetNotInstanceHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.putFieldTargetNotInstanceHostMH(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.putFieldTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + "nest member of [LInvalidNestHost;: current type is not listed as a nest member"; try { CallerNotInstanceHost.putFieldTargetNotInstanceHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1387,45 +1677,45 @@ 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { Caller.putFieldTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.putFieldTargetNotOurHostReflectively(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { Caller.putFieldTargetNotOurHostMH(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.putFieldTarget(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError 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"; + " of InvalidNestHost: current type is not listed as a nest member"; try { CallerNotOurHost.putFieldTargetNotOurHost(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } @@ -1436,16 +1726,16 @@ "P1.PackagedNestHost: types are in different packages"; try { P1.PackagedNestHost.doPutField(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } try { P2.PackagedNestHost2.Member.doPutField(); - throw new Error("Missing IllegalAccessError: " + msg); + throw new Error("Missing IncompatibleClassChangeError: " + msg); } - catch (IllegalAccessError expected) { + catch (IncompatibleClassChangeError expected) { check_expected(expected, msg); } } --- old/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/ExternalSub.jcod 2017-12-15 03:47:21.383700468 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/ExternalSub.jcod 2017-12-15 03:47:19.215576805 -0500 @@ -30,7 +30,7 @@ class ExternalSub { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #10; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/ExternalSuper.jcod 2017-12-15 03:47:28.052080810 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/ExternalSuper.jcod 2017-12-15 03:47:25.815953269 -0500 @@ -29,7 +29,7 @@ class ExternalSuper { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #10; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/ExternalSub.jcod 2017-12-15 03:47:34.596454079 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateMethods/ExternalSub.jcod 2017-12-15 03:47:32.428330416 -0500 @@ -27,7 +27,7 @@ class ExternalSub { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #4 #16; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/ExternalSuper.jcod 2017-12-15 03:47:41.120826206 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateMethods/ExternalSuper.jcod 2017-12-15 03:47:38.960703000 -0500 @@ -27,7 +27,7 @@ class ExternalSuper { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #4 #16; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/MissingMethod.jcod 2017-12-15 03:47:47.677200224 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateMethods/MissingMethod.jcod 2017-12-15 03:47:45.509076496 -0500 @@ -27,7 +27,7 @@ class TestInvokeErrors$MissingMethod { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #16; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/MissingMethodWithSuper.jcod 2017-12-15 03:47:54.573595767 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateMethods/MissingMethodWithSuper.jcod 2017-12-15 03:47:52.157457167 -0500 @@ -27,7 +27,7 @@ class TestInvokeErrors$MissingMethodWithSuper { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #16; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/MissingNestHost.jcod 2017-12-15 03:48:02.942075816 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/privateMethods/MissingNestHost.jcod 2017-12-15 03:47:59.337869065 -0500 @@ -27,7 +27,7 @@ class TestInvokeErrors$MissingNestHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #16; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberMalformedHost.jcod 2017-12-15 03:48:09.494451683 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberMalformedHost.jcod 2017-12-15 03:48:07.322327083 -0500 @@ -21,12 +21,12 @@ * questions. */ -// NestHost attribute refers to class with invalid class file formatt +// NestHost attribute refers to class with invalid class file format class HostOfMemberMalformedHost$MemberMalformedHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberMissingHost.jcod 2017-12-15 03:48:16.034826860 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberMissingHost.jcod 2017-12-15 03:48:13.870702719 -0500 @@ -26,7 +26,7 @@ class HostOfMemberMissingHost$MemberMissingHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberNoHost.jcod 2017-12-15 03:48:22.575202030 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberNoHost.jcod 2017-12-15 03:48:20.407077664 -0500 @@ -26,7 +26,7 @@ class HostOfMemberNoHost$MemberNoHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberNotInstanceHost.jcod 2017-12-15 03:48:29.239584319 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberNotInstanceHost.jcod 2017-12-15 03:48:27.003456046 -0500 @@ -26,14 +26,14 @@ class HostOfMemberNotInstanceHost$MemberNotInstanceHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #14; // #1 class #15; // #2 class #18; // #3 Utf8 "oa"; // #4 - Utf8 "[Ljava/lang/Object;"; // #5 + Utf8 "[LInvalidNestHost;"; // #5 Utf8 ""; // #6 Utf8 "()V"; // #7 Utf8 "Code"; // #8 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberNotOurHost.jcod 2017-12-15 03:48:35.795960403 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostOfMemberNotOurHost.jcod 2017-12-15 03:48:33.631836267 -0500 @@ -26,7 +26,7 @@ class HostOfMemberNotOurHost$MemberNotOurHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 @@ -46,6 +46,9 @@ Utf8 "InnerClasses"; // #15 Utf8 "java/lang/Object"; // #16 Utf8 "HostOfMemberNotOurHost"; // #17 + // Added + Utf8 "InvalidNestHost"; // #18 + class #18; // #19 } // Constant Pool 0x0020; // access @@ -90,7 +93,7 @@ } // end SourceFile ; Attr(#10) { // NestHost - 0x0003; // Modified #3 + 0x0013; // Modified #19 } // end NestHost ; Attr(#15) { // InnerClasses --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/Hosts.java 2017-12-15 03:48:42.340335798 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/Hosts.java 2017-12-15 03:48:40.176211663 -0500 @@ -49,3 +49,15 @@ // Malformed NestHost class static class MemberMalformedHost {} } + +// Host lists itself as a member along +// with real member. +class HostWithSelfMember { + static class Member {} +} + +// Host lists duplicate members. +class HostWithDuplicateMembers { + static class Member1 {} + static interface Member2 {} +} --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MalformedHost.jcod 2017-12-15 03:48:48.888711420 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MalformedHost.jcod 2017-12-15 03:48:46.724587284 -0500 @@ -26,7 +26,7 @@ class MalformedHost { 0xDEADBEEF; // bad magic number 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberMalformedHost.jcod 2017-12-15 03:48:55.793107462 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberMalformedHost.jcod 2017-12-15 03:48:53.620982867 -0500 @@ -21,12 +21,12 @@ * questions. */ -// NestHost attribute refers to class with invalid class file formatt +// NestHost attribute refers to class with invalid class file format class TestReflectionAPI$MemberMalformedHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberMissingHost.jcod 2017-12-15 03:49:04.149586794 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberMissingHost.jcod 2017-12-15 03:49:00.545380054 -0500 @@ -26,7 +26,7 @@ class TestReflectionAPI$MemberMissingHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberNoHost.jcod 2017-12-15 03:49:10.701962637 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberNoHost.jcod 2017-12-15 03:49:08.529838044 -0500 @@ -26,7 +26,7 @@ class TestReflectionAPI$MemberNoHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberNotInstanceHost.jcod 2017-12-15 03:49:17.246338018 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberNotInstanceHost.jcod 2017-12-15 03:49:15.082213885 -0500 @@ -26,14 +26,14 @@ class TestReflectionAPI$MemberNotInstanceHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #14; // #1 class #15; // #2 class #18; // #3 Utf8 "oa"; // #4 - Utf8 "[Ljava/lang/Object;"; // #5 + Utf8 "[LInvalidNestHost;"; // #5 Utf8 ""; // #6 Utf8 "()V"; // #7 Utf8 "Code"; // #8 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberNotOurHost.jcod 2017-12-15 03:49:23.782712938 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/MemberNotOurHost.jcod 2017-12-15 03:49:21.622589036 -0500 @@ -26,7 +26,7 @@ class TestReflectionAPI$MemberNotOurHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #3 #12; // #1 @@ -46,6 +46,9 @@ Utf8 "InnerClasses"; // #15 Utf8 "java/lang/Object"; // #16 Utf8 "TestReflectionAPI"; // #17 + // Added + Utf8 "InvalidNestHost"; // #18 + class #18; // #19 } // Constant Pool 0x0020; // access @@ -90,7 +93,7 @@ } // end SourceFile ; Attr(#10) { // NestHost - 0x0003; // Modified #3 + 0x0013; // Modified #19 } // end NestHost ; Attr(#15) { // InnerClasses --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/PackagedNestHost.jcod 2017-12-15 03:49:30.479097034 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/PackagedNestHost.jcod 2017-12-15 03:49:28.242968773 -0500 @@ -26,7 +26,7 @@ class P1/PackagedNestHost { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #4 #16; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/PackagedNestHost2Member.jcod 2017-12-15 03:49:37.015471949 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/PackagedNestHost2Member.jcod 2017-12-15 03:49:34.855348047 -0500 @@ -27,7 +27,7 @@ class P2/PackagedNestHost2$Member { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #7 #18; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/PackagedNestHostMember.jcod 2017-12-15 03:49:43.575848238 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/PackagedNestHostMember.jcod 2017-12-15 03:49:41.403723649 -0500 @@ -26,7 +26,7 @@ class P1/PackagedNestHost$Member { 0xCAFEBABE; 0; // minor version - 53; // version + 54; // version [] { // Constant Pool ; // first element is empty Method #6 #16; // #1 --- old/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/TestReflectionAPI.java 2017-12-15 03:49:50.112223147 -0500 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/TestReflectionAPI.java 2017-12-15 03:49:47.944098791 -0500 @@ -30,6 +30,7 @@ * PackagedNestHost2.java * SampleNest.java * Hosts.java + * InvalidNestHost.java * * @compile MemberNoHost.jcod * MemberMissingHost.jcod @@ -45,6 +46,8 @@ * HostOfMemberNotInstanceHost.jcod * HostOfMemberNotOurHost.jcod * HostOfMemberMalformedHost.jcod + * HostWithSelfMember.jcod + * HostWithDuplicateMembers.jcod * * @run main/othervm TestReflectionAPI */ @@ -61,6 +64,7 @@ import java.util.Arrays; import java.util.Comparator; +import java.util.HashSet; public class TestReflectionAPI { @@ -154,7 +158,18 @@ checkSingletonNests(good); // More thorough correctness check - checkNest(SampleNest.class, SampleNest.nestedTypes()); + checkNest(SampleNest.class, SampleNest.nestedTypes(), false); + + // Special cases - legal but not produced by javac + checkNest(HostWithSelfMember.class, + new Class[] { HostWithSelfMember.class, + HostWithSelfMember.Member.class }, + true); + checkNest(HostWithDuplicateMembers.class, + new Class[] { HostWithDuplicateMembers.class, + HostWithDuplicateMembers.Member1.class, + HostWithDuplicateMembers.Member2.class }, + true); // Hosts with "bad" members Class[] bad = { @@ -177,9 +192,9 @@ "Unable to load nest-host class (NestHost) of " + "HostOfMemberMissingHost$MemberMissingHost", "Type HostOfMemberNotOurHost$MemberNotOurHost is not a nest member " + - "of java.lang.Object: current type is not listed as a nest member", + "of InvalidNestHost: current type is not listed as a nest member", "Type HostOfMemberNotInstanceHost$MemberNotInstanceHost is not a nest " + - "member of [Ljava.lang.Object;: nest-host is not an instance class!", + "member of [LInvalidNestHost;: current type is not listed as a nest member", "Incompatible magic value 3735928559 in class file MalformedHost", }; for (int i = 0; i < bad.length; i++) { @@ -226,7 +241,7 @@ static Comparator> cmp = Comparator.comparing(Class::getName); - static void checkNest(Class host, Class[] unsortedTypes) { + static void checkNest(Class host, Class[] unsortedTypes, boolean expectDups) { Class[] members = host.getNestMembers(); Arrays.sort(members, cmp); Class[] nestedTypes = unsortedTypes.clone(); @@ -234,8 +249,20 @@ printMembers(host, members); printDeclared(host, nestedTypes); if (!Arrays.equals(members, nestedTypes)) { - throw new Error("Class " + host.getName() + " has different members " + - "compared to declared classes"); + if (!expectDups) { + throw new Error("Class " + host.getName() + " has different members " + + "compared to declared classes"); + } + else { + // get rid of duplicates + Class[] memberSet = + new HashSet>(Arrays.asList(members)).toArray(new Class[0]); + Arrays.sort(memberSet, cmp); + if (!Arrays.equals(memberSet, nestedTypes)) { + throw new Error("Class " + host.getName() + " has different members " + + "compared to declared classes, even after duplicate removal"); + } + } } // verify all the relationships that must hold for nest members for (Class a : members) { --- old/test/hotspot/jtreg/runtime/SelectionResolution/InvokeInterfaceICCE.java 2017-12-15 03:49:56.900612509 -0500 +++ new/test/hotspot/jtreg/runtime/SelectionResolution/InvokeInterfaceICCE.java 2017-12-15 03:49:54.740488611 -0500 @@ -153,20 +153,7 @@ Template.IfaceMethodrefNotEqualsExpected, Template.IgnoredAbstract, Template.AllCallsiteCases, - Template.IfaceMethodrefAmbiguousResolvedIsIface), - - /* Group 175: private method in interface */ - new TestGroup.Simple(initBuilder, - Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE), - Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE), - EnumSet.of(MethodData.Access.PRIVATE), - EnumSet.of(MethodData.Context.INSTANCE), - EnumSet.of(ClassData.Package.SAME)), - Template.OverrideAbstractExpectedIface, - Template.MethodrefEqualsExpected, - Template.IgnoredAbstract, - Template.CallsiteEqualsMethodref, - Template.IfaceMethodrefSelection) + Template.IfaceMethodrefAmbiguousResolvedIsIface) ); private InvokeInterfaceICCE() { --- old/test/hotspot/jtreg/runtime/SelectionResolution/InvokeInterfaceSuccessTest.java 2017-12-15 03:50:05.233090434 -0500 +++ new/test/hotspot/jtreg/runtime/SelectionResolution/InvokeInterfaceSuccessTest.java 2017-12-15 03:50:01.640884396 -0500 @@ -135,6 +135,20 @@ Template.CallsiteUnrelatedToMethodref, Template.IfaceMethodrefSelection, Template.SelectionOverrideAbstract) + /*, + // Group 175: private method in interface [was ICCE case up to JDK 10] + // Can't get this to work for some reason. + new TestGroup.Simple(initBuilder, + Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE), + EnumSet.of(MethodData.Access.PRIVATE), + EnumSet.of(MethodData.Context.INSTANCE), + EnumSet.of(ClassData.Package.SAME)), + Template.OverrideAbstractExpectedIface, + Template.MethodrefEqualsExpected, + Template.IgnoredAbstract, + Template.CallsiteEqualsMethodref, + Template.IfaceMethodrefSelection) + */ ); private InvokeInterfaceSuccessTest() { --- /dev/null 2017-10-30 09:28:08.303210998 -0400 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/CallerSelfHost.jcod 2017-12-15 03:50:09.297323542 -0500 @@ -0,0 +1,378 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// NestHost attribute refers to current class + +class TestNestmateMembership$CallerSelfHost { + 0xCAFEBABE; + 0; // minor version + 54; // version + [] { // Constant Pool + ; // first element is empty + 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 "invokeTargetSelfHost"; // #22 + Utf8 ""; // #23 + Utf8 "newTarget"; // #24 + Utf8 "newTargetSelfHost"; // #25 + Utf8 "getFieldTarget"; // #26 + Utf8 "getFieldTargetSelfHost"; // #27 + Utf8 "putFieldTarget"; // #28 + Utf8 "putFieldTargetSelfHost"; // #29 + Utf8 "SourceFile"; // #30 + Utf8 "TestNestmateMembership.java"; // #31 + Utf8 "NestHost"; // #32 + class #50; // #33 + class #51; // #34 + NameAndType #52 #53; // #35 + Utf8 "CallerSelfHost.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$TargetSelfHost"; // #44 + Utf8 "TargetSelfHost"; // #45 + NameAndType #15 #16; // #46 + Utf8 "TestNestmateMembership$CallerSelfHost"; // #47 + Utf8 "CallerSelfHost"; // #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 + #13;// this_cpx + #14;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + { // Member + 0x000A; // access + #15; // name_cpx + #16; // sig_cpx + [] { // Attributes + } // Attributes + } // Member + } // fields + + [] { // methods + { // Member + 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(#19) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70006B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 308; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #24; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xBB000759B700084B; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 311; + 8 312; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #25; // name_cpx + #18; // sig_cpx + [] { // Attributes + 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[]{ + 0x102AB3000BB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 328; + 5 329; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #29; // name_cpx + #18; // sig_cpx + [] { // Attributes + Attr(#19) { // Code + 1; // max_stack + 0; // max_locals + Bytes[]{ + 0x102AB3000CB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#20) { // LineNumberTable + [] { // LineNumberTable + 0 331; + 5 332; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#30) { // SourceFile + #31; + } // end SourceFile + ; + Attr(#32) { // NestHost + 0x000D; // modified - #13 + } // end NestHost + ; + Attr(#43) { // InnerClasses + [] { // InnerClasses + #7 #33 #42 8; + #9 #33 #45 8; + #13 #33 #48 8; + } + } // end InnerClasses + } // Attributes +} // end class TestNestmateMembership$CallerSelfHost --- /dev/null 2017-10-30 09:28:08.303210998 -0400 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/InvalidNestHost.java 2017-12-15 03:50:15.217663109 -0500 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Empty class to use as an invalid nest-host class, in the same package as + * the test classes. + */ +public class InvalidNestHost { +} + --- /dev/null 2017-10-30 09:28:08.303210998 -0400 +++ new/test/hotspot/jtreg/runtime/Nestmates/membership/TargetSelfHost.jcod 2017-12-15 03:50:21.146003134 -0500 @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// NestHost attribute refers to current class + +class TestNestmateMembership$TargetSelfHost { + 0xCAFEBABE; + 0; // minor version + 54; // 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 + 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 "TargetSelfHost.m() - java version"; // #21 + class #32; // #22 + NameAndType #33 #34; // #23 + Utf8 "TestNestmateMembership$TargetSelfHost"; // #24 + Utf8 "TargetSelfHost"; // #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 + // Added + class #24; // #35 + } // Constant Pool + + 0x0020; // access + #5;// this_cpx + #6;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + { // Member + 0x000A; // access + #7; // name_cpx + #8; // sig_cpx + [] { // Attributes + } // Attributes + } // Member + } // fields + + [] { // methods + { // Member + 0x0002; // access + #9; // name_cpx + #10; // sig_cpx + [] { // Attributes + Attr(#11) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#12) { // LineNumberTable + [] { // LineNumberTable + 0 371; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x000A; // access + #13; // name_cpx + #10; // sig_cpx + [] { // Attributes + Attr(#11) { // Code + 2; // max_stack + 0; // max_locals + Bytes[]{ + 0xB200021203B60004; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#12) { // LineNumberTable + [] { // LineNumberTable + 0 374; + 8 375; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#14) { // SourceFile + #15; + } // end SourceFile + ; + Attr(#16) { // NestHost + 0x0023; // modified - #35 + } // end NestHost + ; + Attr(#26) { // InnerClasses + [] { // InnerClasses + #5 #17 #25 8; + } + } // end InnerClasses + } // Attributes +} // end class TestNestmateMembership$TargetSelfHost --- /dev/null 2017-10-30 09:28:08.303210998 -0400 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostWithDuplicateMembers.jcod 2017-12-15 03:50:27.058342238 -0500 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// Modify NestMembers attribute to contain multiple duplicates + +class HostWithDuplicateMembers { + 0xCAFEBABE; + 0; // minor version + 54; // version + [] { // Constant Pool + ; // first element is empty + Method #3 #16; // #1 + class #17; // #2 + class #18; // #3 + class #19; // #4 + Utf8 "Member2"; // #5 + Utf8 "InnerClasses"; // #6 + class #20; // #7 + Utf8 "Member1"; // #8 + Utf8 ""; // #9 + Utf8 "()V"; // #10 + Utf8 "Code"; // #11 + Utf8 "LineNumberTable"; // #12 + Utf8 "SourceFile"; // #13 + Utf8 "Hosts.java"; // #14 + Utf8 "NestMembers"; // #15 + NameAndType #9 #10; // #16 + Utf8 "HostWithDuplicateMembers"; // #17 + Utf8 "java/lang/Object"; // #18 + Utf8 "HostWithDuplicateMembers$Member2"; // #19 + Utf8 "HostWithDuplicateMembers$Member1"; // #20 + } // Constant Pool + + 0x0020; // access + #2;// this_cpx + #3;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + { // Member + 0x0000; // access + #9; // name_cpx + #10; // sig_cpx + [] { // Attributes + Attr(#11) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#12) { // LineNumberTable + [] { // LineNumberTable + 0 60; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#13) { // SourceFile + #14; + } // end SourceFile + ; + Attr(#15) { // NestMembers + 0x0006000700040007; // modified + 0x000400070004; + } // end NestMembers + ; + Attr(#6) { // InnerClasses + [] { // InnerClasses + #4 #2 #5 1544; + #7 #2 #8 8; + } + } // end InnerClasses + } // Attributes +} // end class HostWithDuplicateMembers --- /dev/null 2017-10-30 09:28:08.303210998 -0400 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/HostWithSelfMember.jcod 2017-12-15 03:50:33.058686388 -0500 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// Modify NestMembers attribute to include reference to the currnet class + +class HostWithSelfMember { + 0xCAFEBABE; + 0; // minor version + 54; // version + [] { // Constant Pool + ; // first element is empty + Method #3 #14; // #1 + class #15; // #2 + class #16; // #3 + class #17; // #4 + Utf8 "Member"; // #5 + Utf8 "InnerClasses"; // #6 + Utf8 ""; // #7 + Utf8 "()V"; // #8 + Utf8 "Code"; // #9 + Utf8 "LineNumberTable"; // #10 + Utf8 "SourceFile"; // #11 + Utf8 "Hosts.java"; // #12 + Utf8 "NestMembers"; // #13 + NameAndType #7 #8; // #14 + Utf8 "HostWithSelfMember"; // #15 + Utf8 "java/lang/Object"; // #16 + Utf8 "HostWithSelfMember$Member"; // #17 + } // Constant Pool + + 0x0020; // access + #2;// this_cpx + #3;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + { // Member + 0x0000; // access + #7; // name_cpx + #8; // sig_cpx + [] { // Attributes + Attr(#9) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#10) { // LineNumberTable + [] { // LineNumberTable + 0 55; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#11) { // SourceFile + #12; + } // end SourceFile + ; + Attr(#13) { // NestMembers + 0x000200040002; // modified - added self + } // end NestMembers + ; + Attr(#6) { // InnerClasses + [] { // InnerClasses + #4 #2 #5 8; + } + } // end InnerClasses + } // Attributes +} // end class HostWithSelfMember --- /dev/null 2017-10-30 09:28:08.303210998 -0400 +++ new/test/hotspot/jtreg/runtime/Nestmates/reflectionAPI/InvalidNestHost.java 2017-12-15 03:50:38.983026176 -0500 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Empty class to use as an invalid nest-host class, in the same package as + * the test classes. + */ +public class InvalidNestHost { +} + --- old/test/hotspot/jtreg/runtime/Nestmates/classFileParsing/DuplicateNestMemberEntry.jcod 2017-12-15 03:50:47.075490313 -0500 +++ /dev/null 2017-10-30 09:28:08.303210998 -0400 @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* Source: NestmateAttributeHolder.java - -public class NestmateAttributeHolder { - public static class TwoNestHost { - } -} -*/ - -// NestMembers attribute has two entries for the same class - -class DuplicateNestMemberEntry { - 0xCAFEBABE; - 0; // minor version - 53; // version - [] { // Constant Pool - ; // first element is empty - Method #3 #14; // #1 - class #15; // #2 - class #16; // #3 - class #17; // #4 - Utf8 "TwoNestHost"; // #5 - Utf8 "InnerClasses"; // #6 - Utf8 ""; // #7 - Utf8 "()V"; // #8 - Utf8 "Code"; // #9 - Utf8 "LineNumberTable"; // #10 - Utf8 "SourceFile"; // #11 - Utf8 "DuplicateNestMemberEntry.java"; // #12 - Utf8 "NestMembers"; // #13 - NameAndType #7 #8; // #14 - Utf8 "DuplicateNestMemberEntry"; // #15 - Utf8 "java/lang/Object"; // #16 - Utf8 "DuplicateNestMemberEntry$TwoNestHost"; // #17 - } // Constant Pool - - 0x0021; // access - #2;// this_cpx - #3;// super_cpx - - [] { // Interfaces - } // Interfaces - - [] { // fields - } // fields - - [] { // methods - { // Member - 0x0001; // access - #7; // name_cpx - #8; // sig_cpx - [] { // Attributes - Attr(#9) { // Code - 1; // max_stack - 1; // max_locals - Bytes[]{ - 0x2AB70001B1; - }; - [] { // Traps - } // end Traps - [] { // Attributes - Attr(#10) { // LineNumberTable - [] { // LineNumberTable - 0 1; - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - } // methods - - [] { // Attributes - Attr(#11) { // SourceFile - #12; - } // end SourceFile - ; - Attr(#13) { // NestMembers - 0x000200040004; // duplicate entry - } // end NestMembers - ; - Attr(#6) { // InnerClasses - [] { // InnerClasses - #4 #2 #5 9; - } - } // end InnerClasses - } // Attributes -} // end class DuplicateNestMemberEntry --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/StaticIfaceError.jcod 2017-12-15 03:50:51.163724787 -0500 +++ /dev/null 2017-10-30 09:28:08.303210998 -0400 @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// Generated from the source in TestInvokeInterface.java, compiled for -// nestmates, but edited to set classfile version back to 52 - where -// use of invokeinterface for private interface methods is not permitted. - -class TestInvokeInterface$StaticIface { - 0xCAFEBABE; - 0; // minor version - 52; // version - [] { // Constant Pool - ; // first element is empty - Field #19 #20; // #1 - String #21; // #2 - Method #22 #23; // #3 - InterfaceMethod #5 #24; // #4 - class #25; // #5 - class #26; // #6 - Utf8 "priv_invoke"; // #7 - Utf8 "()V"; // #8 - Utf8 "Code"; // #9 - Utf8 "LineNumberTable"; // #10 - Utf8 "access_priv"; // #11 - Utf8 "StaticIface"; // #12 - Utf8 "InnerClasses"; // #13 - Utf8 "(LTestInvokeInterface$StaticIface;)V"; // #14 - Utf8 "SourceFile"; // #15 - Utf8 "TestInvokeInterface.java"; // #16 - Utf8 "NestHost"; // #17 - class #27; // #18 - class #28; // #19 - NameAndType #29 #30; // #20 - Utf8 "StaticIface::priv_invoke"; // #21 - class #31; // #22 - NameAndType #32 #33; // #23 - NameAndType #7 #8; // #24 - Utf8 "TestInvokeInterface$StaticIface"; // #25 - Utf8 "java/lang/Object"; // #26 - Utf8 "TestInvokeInterface"; // #27 - Utf8 "java/lang/System"; // #28 - Utf8 "out"; // #29 - Utf8 "Ljava/io/PrintStream;"; // #30 - Utf8 "java/io/PrintStream"; // #31 - Utf8 "println"; // #32 - Utf8 "(Ljava/lang/String;)V"; // #33 - } // Constant Pool - - 0x0600; // access - #5;// this_cpx - #6;// super_cpx - - [] { // Interfaces - } // Interfaces - - [] { // fields - } // fields - - [] { // methods - { // Member - 0x0002; // access - #7; // name_cpx - #8; // sig_cpx - [] { // Attributes - Attr(#9) { // Code - 2; // max_stack - 1; // max_locals - Bytes[]{ - 0xB200011202B60003; - 0xB1; - }; - [] { // Traps - } // end Traps - [] { // Attributes - Attr(#10) { // LineNumberTable - [] { // LineNumberTable - 0 42; - 8 43; - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - ; - { // Member - 0x0001; // access - #11; // name_cpx - #14; // sig_cpx - [] { // Attributes - Attr(#9) { // Code - 1; // max_stack - 2; // max_locals - Bytes[]{ - 0x2BB900040100B1; - }; - [] { // Traps - } // end Traps - [] { // Attributes - Attr(#10) { // LineNumberTable - [] { // LineNumberTable - 0 46; - 6 47; - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - } // methods - - [] { // Attributes - Attr(#15) { // SourceFile - #16; - } // end SourceFile - ; - Attr(#17) { // NestHost - 0x0012; - } // end NestHost - ; - Attr(#13) { // InnerClasses - [] { // InnerClasses - #5 #18 #12 1544; - } - } // end InnerClasses - } // Attributes -} // end class TestInvokeInterface$StaticIface --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/StaticIfaceGood.jcod 2017-12-15 03:50:55.487972800 -0500 +++ /dev/null 2017-10-30 09:28:08.303210998 -0400 @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// Generated from the source in TestInvokeInterface.java, compiled for -// nestmates. The code is not modified from that but exists as a jcod file -// to ensure we don't accidentally compile it dynamically for the wrong -// release. - -class TestInvokeInterface$StaticIface { - 0xCAFEBABE; - 0; // minor version - 53; // version - FXME: will need to be real nestmate release version - [] { // Constant Pool - ; // first element is empty - Field #19 #20; // #1 - String #21; // #2 - Method #22 #23; // #3 - InterfaceMethod #5 #24; // #4 - class #25; // #5 - class #26; // #6 - Utf8 "priv_invoke"; // #7 - Utf8 "()V"; // #8 - Utf8 "Code"; // #9 - Utf8 "LineNumberTable"; // #10 - Utf8 "access_priv"; // #11 - Utf8 "StaticIface"; // #12 - Utf8 "InnerClasses"; // #13 - Utf8 "(LTestInvokeInterface$StaticIface;)V"; // #14 - Utf8 "SourceFile"; // #15 - Utf8 "TestInvokeInterface.java"; // #16 - Utf8 "NestHost"; // #17 - class #27; // #18 - class #28; // #19 - NameAndType #29 #30; // #20 - Utf8 "StaticIface::priv_invoke"; // #21 - class #31; // #22 - NameAndType #32 #33; // #23 - NameAndType #7 #8; // #24 - Utf8 "TestInvokeInterface$StaticIface"; // #25 - Utf8 "java/lang/Object"; // #26 - Utf8 "TestInvokeInterface"; // #27 - Utf8 "java/lang/System"; // #28 - Utf8 "out"; // #29 - Utf8 "Ljava/io/PrintStream;"; // #30 - Utf8 "java/io/PrintStream"; // #31 - Utf8 "println"; // #32 - Utf8 "(Ljava/lang/String;)V"; // #33 - } // Constant Pool - - 0x0600; // access - #5;// this_cpx - #6;// super_cpx - - [] { // Interfaces - } // Interfaces - - [] { // fields - } // fields - - [] { // methods - { // Member - 0x0002; // access - #7; // name_cpx - #8; // sig_cpx - [] { // Attributes - Attr(#9) { // Code - 2; // max_stack - 1; // max_locals - Bytes[]{ - 0xB200011202B60003; - 0xB1; - }; - [] { // Traps - } // end Traps - [] { // Attributes - Attr(#10) { // LineNumberTable - [] { // LineNumberTable - 0 42; - 8 43; - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - ; - { // Member - 0x0001; // access - #11; // name_cpx - #14; // sig_cpx - [] { // Attributes - Attr(#9) { // Code - 1; // max_stack - 2; // max_locals - Bytes[]{ - 0x2BB900040100B1; - }; - [] { // Traps - } // end Traps - [] { // Attributes - Attr(#10) { // LineNumberTable - [] { // LineNumberTable - 0 46; - 6 47; - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - } // methods - - [] { // Attributes - Attr(#15) { // SourceFile - #16; - } // end SourceFile - ; - Attr(#17) { // NestHost - 0x0012; - } // end NestHost - ; - Attr(#13) { // InnerClasses - [] { // InnerClasses - #5 #18 #12 1544; - } - } // end InnerClasses - } // Attributes -} // end class TestInvokeInterface$StaticIface --- old/test/hotspot/jtreg/runtime/Nestmates/privateMethods/TestInvokeInterface.java 2017-12-15 03:50:59.864223791 -0500 +++ /dev/null 2017-10-30 09:28:08.303210998 -0400 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// We compile two versions of the nested StaticIface which contains a call -// to a private interface method. Both versions are compiled to use -// invokeinterface, but one is modified to declare a lower classfile version, -// which makes the use of invokeinterface illegal in that context. -// We run the test twice, each time using a different version of the -// StaticIface class. - -/* - * @test - * @bug 8046171 - * @summary Test use of invokeinterface versus invokespecial for private - * interface method invocation - * @compile TestInvokeInterface.java - * @compile StaticIfaceGood.jcod - * @run main TestInvokeInterface pass - * @compile StaticIfaceError.jcod - * @run main TestInvokeInterface fail - */ - -public class TestInvokeInterface { - - static interface StaticIface { - - private void priv_invoke() { - System.out.println("StaticIface::priv_invoke"); - } - - default void access_priv(StaticIface o) { - o.priv_invoke(); - } - } - - public static void main(String[] args) { - boolean shouldFail = args[0].equals("fail"); - String icce = "IncompatibleClassChangeError: private interface method requires invokespecial"; - StaticIface intf = new StaticIface() {}; - try { - intf.access_priv(new StaticIface(){}); - if (shouldFail) - throw new Error("Do not get expected exception: " + icce); - else - System.out.println("Invocation succeeded as expected"); - } - catch (IncompatibleClassChangeError e) { - if (shouldFail && e.toString().contains(icce)) - System.out.println("Got expected exception: " + e); - else - throw new Error("Unexpected cause of exception: " + e); - } - } -}