179 // Hosts with "bad" members 180 Class<?>[] bad = { 181 HostOfMemberNoHost.class, 182 HostOfMemberMissingHost.class, 183 HostOfMemberNotOurHost.class, 184 HostOfMemberNotInstanceHost.class, 185 HostOfMemberMalformedHost.class, 186 }; 187 Class<?>[] exceptions = { 188 IncompatibleClassChangeError.class, 189 NoClassDefFoundError.class, 190 IncompatibleClassChangeError.class, 191 IncompatibleClassChangeError.class, 192 ClassFormatError.class, 193 }; 194 String[] messages = { 195 "Nest member HostOfMemberNoHost$MemberNoHost in HostOfMemberNoHost " + 196 "declares a different nest host of HostOfMemberNoHost$MemberNoHost", 197 "Unable to load nest-host class (NestHost) of " + 198 "HostOfMemberMissingHost$MemberMissingHost", 199 "Type HostOfMemberNotOurHost$MemberNotOurHost is not a nest member " + 200 "of InvalidNestHost: current type is not listed as a nest member", 201 "Type HostOfMemberNotInstanceHost$MemberNotInstanceHost is not a nest " + 202 "member of [LInvalidNestHost;: current type is not listed as a nest member", 203 "Incompatible magic value 3735928559 in class file MalformedHost", 204 }; 205 for (int i = 0; i < bad.length; i++) { 206 try { 207 bad[i].getNestMembers(); 208 throw new Error("getNestMembers() succeeded for class " + 209 bad[i].getName()); 210 } catch (LinkageError e) { 211 checkException(e, messages[i], exceptions[i]); 212 } 213 } 214 } 215 216 static void checkException(Throwable actual, String msg, Class<?> expected) { 217 if (!actual.getClass().equals(expected)) 218 throw new Error("Unexpected exception: got " + actual.getClass().getName() 219 + " but expected " + expected.getName()); 220 if (!actual.getMessage().contains(msg)) 221 throw new Error("Wrong " + actual.getClass().getSimpleName() +": \"" + 222 actual.getMessage() + "\" does not contain \"" + | 179 // Hosts with "bad" members 180 Class<?>[] bad = { 181 HostOfMemberNoHost.class, 182 HostOfMemberMissingHost.class, 183 HostOfMemberNotOurHost.class, 184 HostOfMemberNotInstanceHost.class, 185 HostOfMemberMalformedHost.class, 186 }; 187 Class<?>[] exceptions = { 188 IncompatibleClassChangeError.class, 189 NoClassDefFoundError.class, 190 IncompatibleClassChangeError.class, 191 IncompatibleClassChangeError.class, 192 ClassFormatError.class, 193 }; 194 String[] messages = { 195 "Nest member HostOfMemberNoHost$MemberNoHost in HostOfMemberNoHost " + 196 "declares a different nest host of HostOfMemberNoHost$MemberNoHost", 197 "Unable to load nest-host class (NestHost) of " + 198 "HostOfMemberMissingHost$MemberMissingHost", 199 "Type HostOfMemberNotOurHost$MemberNotOurHost (loader: 'app') is not a nest member " + 200 "of InvalidNestHost (loader: 'app'): current type is not listed as a nest member", 201 "Type HostOfMemberNotInstanceHost$MemberNotInstanceHost (loader: 'app') is not a nest " + 202 "member of [LInvalidNestHost; (loader: 'app'): current type is not listed as a nest member", 203 "Incompatible magic value 3735928559 in class file MalformedHost", 204 }; 205 for (int i = 0; i < bad.length; i++) { 206 try { 207 bad[i].getNestMembers(); 208 throw new Error("getNestMembers() succeeded for class " + 209 bad[i].getName()); 210 } catch (LinkageError e) { 211 checkException(e, messages[i], exceptions[i]); 212 } 213 } 214 } 215 216 static void checkException(Throwable actual, String msg, Class<?> expected) { 217 if (!actual.getClass().equals(expected)) 218 throw new Error("Unexpected exception: got " + actual.getClass().getName() 219 + " but expected " + expected.getName()); 220 if (!actual.getMessage().contains(msg)) 221 throw new Error("Wrong " + actual.getClass().getSimpleName() +": \"" + 222 actual.getMessage() + "\" does not contain \"" + |