1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
|
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.beans.Introspector;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.AbstractCollection;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.RandomAccess;
/**
* @test
* @bug 8211147
* @modules java.desktop/com.sun.beans.introspect:open
*/
public final class MethodOrderException {
public static void main(final String[] args) throws Exception {
// Public API, fails rarely
testPublicAPI();
// Test using internal API, fails always
testPrivateAPI();
}
private static void testPublicAPI() throws Exception {
Introspector.getBeanInfo(X.class);
}
private static void testPrivateAPI() throws Exception {
Class<?> name = Class.forName(
"com.sun.beans.introspect.MethodInfo$MethodOrder");
Field instance = name.getDeclaredField("instance");
instance.setAccessible(true);
Comparator<Method> o = (Comparator) instance.get(name);
List<Method> methods = List.of(X.class.getDeclaredMethods());
methods.forEach(m1 -> {
methods.forEach(m2 -> {
if (o.compare(m1, m2) != -o.compare(m2, m1)) {
System.err.println("Method1 = "+ m1);
System.err.println("Method2 = "+ m2);
throw new RuntimeException("Broken contract!");
}
});
});
}
interface X_1 {
AbstractList x_8();
}
interface X_2 {
Cloneable x_0();
}
interface X_3 {
Serializable x_1();
}
interface X_4 {
Object x_7();
}
interface X_5 {
RandomAccess x_6();
}
interface X_6 {
RandomAccess x_0();
}
interface X_7 {
Serializable x_5();
}
interface X_8 {
Object x_4();
}
interface X_9 {
RandomAccess x_5();
}
interface X_10 {
Cloneable x_5();
}
interface X_11 {
RandomAccess x_9();
}
interface X_12 {
Cloneable x_9();
}
interface X_13 {
Iterable x_2();
}
interface X_14 {
Collection x_7();
}
interface X_15 {
Serializable x_4();
}
interface X_16 {
Cloneable x_7();
}
interface X_17 {
Object x_1();
}
interface X_18 {
ArrayList x_6();
}
interface X_19 {
List x_5();
}
interface X_20 {
Collection x_2();
}
interface X_21 {
List x_1();
}
interface X_22 {
List x_3();
}
interface X_23 {
RandomAccess x_3();
}
interface X_24 {
RandomAccess x_1();
}
interface X_25 {
Object x_6();
}
interface X_26 {
Cloneable x_7();
}
interface X_27 {
Iterable x_0();
}
interface X_28 {
Iterable x_1();
}
interface X_29 {
AbstractList x_7();
}
interface X_30 {
AbstractList x_1();
}
interface X_31 {
Cloneable x_9();
}
interface X_32 {
ArrayList x_6();
}
interface X_33 {
Cloneable x_2();
}
interface X_34 {
Iterable x_6();
}
interface X_35 {
Iterable x_9();
}
interface X_36 {
AbstractList x_9();
}
interface X_37 {
Iterable x_7();
}
interface X_38 {
Iterable x_3();
}
interface X_39 {
Iterable x_9();
}
interface X_40 {
AbstractList x_3();
}
interface X_41 {
List x_0();
}
interface X_42 {
Iterable x_0();
}
interface X_43 {
Iterable x_2();
}
interface X_44 {
ArrayList x_4();
}
interface X_45 {
AbstractList x_4();
}
interface X_46 {
Collection x_4();
}
interface X_47 {
ArrayList x_2();
}
interface X_48 {
ArrayList x_6();
}
interface X_49 {
Serializable x_1();
}
interface X_50 {
Cloneable x_7();
}
interface X_51 {
Collection x_5();
}
interface X_52 {
RandomAccess x_5();
}
interface X_53 {
Collection x_5();
}
interface X_54 {
RandomAccess x_4();
}
interface X_55 {
Collection x_0();
}
interface X_56 {
Collection x_7();
}
interface X_57 {
Iterable x_9();
}
interface X_58 {
List x_3();
}
interface X_59 {
Serializable x_7();
}
interface X_60 {
AbstractCollection x_6();
}
interface X_61 {
AbstractList x_9();
}
interface X_62 {
List x_7();
}
interface X_63 {
AbstractCollection x_3();
}
interface X_64 {
RandomAccess x_4();
}
interface X_65 {
Object x_3();
}
interface X_66 {
RandomAccess x_6();
}
interface X_67 {
Cloneable x_6();
}
interface X_68 {
Cloneable x_3();
}
interface X_69 {
Collection x_5();
}
interface X_70 {
AbstractCollection x_0();
}
interface X_71 {
Object x_8();
}
interface X_72 {
AbstractCollection x_3();
}
interface X_73 {
Serializable x_4();
}
interface X_74 {
AbstractList x_8();
}
interface X_75 {
ArrayList x_1();
}
interface X_76 {
List x_5();
}
interface X_77 {
Object x_0();
}
interface X_78 {
Collection x_0();
}
interface X_79 {
ArrayList x_2();
}
interface X_80 {
ArrayList x_8();
}
interface X_81 {
Cloneable x_3();
}
interface X_82 {
Serializable x_1();
}
interface X_83 {
List x_1();
}
interface X_84 {
Collection x_5();
}
interface X_85 {
RandomAccess x_9();
}
interface X_86 {
AbstractList x_3();
}
interface X_87 {
Cloneable x_6();
}
interface X_88 {
Object x_2();
}
interface X_89 {
ArrayList x_5();
}
interface X_90 {
Iterable x_1();
}
interface X_91 {
ArrayList x_4();
}
interface X_92 {
Iterable x_6();
}
interface X_93 {
Collection x_7();
}
interface X_94 {
Iterable x_2();
}
interface X_95 {
AbstractList x_7();
}
interface X_96 {
RandomAccess x_2();
}
interface X_97 {
RandomAccess x_2();
}
interface X_98 {
List x_6();
}
interface X_99 {
Object x_4();
}
interface X_100 {
Collection x_7();
}
static class X
implements X_1, X_2, X_3, X_4, X_5, X_6, X_7, X_8, X_9, X_10, X_11,
X_12, X_13, X_14, X_15, X_16, X_17, X_18, X_19, X_20,
X_21, X_22, X_23, X_24, X_25, X_26, X_27, X_28, X_29,
X_30, X_31, X_32, X_33, X_34, X_35, X_36, X_37, X_38,
X_39, X_40, X_41, X_42, X_43, X_44, X_45, X_46, X_47,
X_48, X_49, X_50, X_51, X_52, X_53, X_54, X_55, X_56,
X_57, X_58, X_59, X_60, X_61, X_62, X_63, X_64, X_65,
X_66, X_67, X_68, X_69, X_70, X_71, X_72, X_73, X_74,
X_75, X_76, X_77, X_78, X_79, X_80, X_81, X_82, X_83,
X_84, X_85, X_86, X_87, X_88, X_89, X_90, X_91, X_92,
X_93, X_94, X_95, X_96, X_97, X_98, X_99, X_100 {
public ArrayList x_0() {
return null;
}
public ArrayList x_1() {
return null;
}
public ArrayList x_2() {
return null;
}
public ArrayList x_3() {
return null;
}
public ArrayList x_4() {
return null;
}
public ArrayList x_5() {
return null;
}
public ArrayList x_6() {
return null;
}
public ArrayList x_7() {
return null;
}
public ArrayList x_8() {
return null;
}
public ArrayList x_9() {
return null;
}
}
}
|