1 /* |
1 /* |
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
4392 builder.hier.addInherit(C2, I); |
4392 builder.hier.addInherit(C2, I); |
4393 builder.expected = C3; |
4393 builder.expected = C3; |
4394 builder.objectref = C1; |
4394 builder.objectref = C1; |
4395 }); |
4395 }); |
4396 |
4396 |
|
4397 // NOTE: The selection changes in JVMS 11 mean that private class methods |
|
4398 // are never selected to satisfy an interface method invocation, and so no |
|
4399 // IllegalAccessError is subsequently thrown. Because of this all the |
|
4400 // "private" cases below are commented out. At some point in the future |
|
4401 // these should be factored out and moved to a test that expects success |
|
4402 // but it is not that simple as the commented out cases result in 2600 |
|
4403 // testcases being excluded, but only ~150 failing cases were seen. Though |
|
4404 // it is not clear from the test if a single failure can result in further |
|
4405 // testcases being skipped. |
4397 public static final Template IfaceMethodrefSelectionOverrideNonPublic = |
4406 public static final Template IfaceMethodrefSelectionOverrideNonPublic = |
4398 new Template("IfaceMethodrefSelection", |
4407 new Template("IfaceMethodrefSelection", |
4399 /* Case 1: Objectref overrides. |
4408 /* Case 1: Objectref overrides. |
4400 * |
4409 * |
4401 * I[](*) = mref |
4410 * I[](*) = mref |
4402 * C[I](priv) = oref = expected |
4411 * C[I](priv) = oref = expected |
4403 */ |
4412 */ |
4404 (final SelectionResolutionTestCase.Builder builder) -> { |
4413 // (final SelectionResolutionTestCase.Builder builder) -> { |
4405 final ClassData.Package pck = |
4414 // final ClassData.Package pck = |
4406 builder.classdata.get(builder.methodref).packageId; |
4415 // builder.classdata.get(builder.methodref).packageId; |
4407 final ClassData oldexpected = |
4416 // final ClassData oldexpected = |
4408 builder.classdata.get(builder.expected); |
4417 // builder.classdata.get(builder.expected); |
4409 final MethodData meth = |
4418 // final MethodData meth = |
4410 new MethodData(MethodData.Access.PRIVATE, |
4419 // new MethodData(MethodData.Access.PRIVATE, |
4411 MethodData.Context.INSTANCE); |
4420 // MethodData.Context.INSTANCE); |
4412 final ClassData withDef = |
4421 // final ClassData withDef = |
4413 new ClassData(pck, meth); |
4422 // new ClassData(pck, meth); |
4414 final int I = builder.methodref; |
4423 // final int I = builder.methodref; |
4415 final int C = builder.addClass(withDef); |
4424 // final int C = builder.addClass(withDef); |
4416 builder.hier.addInherit(C, I); |
4425 // builder.hier.addInherit(C, I); |
4417 builder.objectref = C; |
4426 // builder.objectref = C; |
4418 builder.expected = C; |
4427 // builder.expected = C; |
4419 }, |
4428 // }, |
4420 /* Case 2: Objectref overrides. |
4429 /* Case 2: Objectref overrides. |
4421 * |
4430 * |
4422 * I[](*) = mref |
4431 * I[](*) = mref |
4423 * C[I](prot) = oref = expected |
4432 * C[I](prot) = oref = expected |
4424 */ |
4433 */ |
4464 * |
4473 * |
4465 * I2[](*) = mref |
4474 * I2[](*) = mref |
4466 * C2[I2](priv) = expected, I1[I2]() |
4475 * C2[I2](priv) = expected, I1[I2]() |
4467 * C1[I1,C2]() = oref |
4476 * C1[I1,C2]() = oref |
4468 */ |
4477 */ |
4469 (final SelectionResolutionTestCase.Builder builder) -> { |
4478 // (final SelectionResolutionTestCase.Builder builder) -> { |
4470 final ClassData.Package pck = |
4479 // final ClassData.Package pck = |
4471 builder.classdata.get(builder.expected).packageId; |
4480 // builder.classdata.get(builder.expected).packageId; |
4472 final ClassData oldexpected = |
4481 // final ClassData oldexpected = |
4473 builder.classdata.get(builder.expected); |
4482 // builder.classdata.get(builder.expected); |
4474 final MethodData meth = |
4483 // final MethodData meth = |
4475 new MethodData(MethodData.Access.PRIVATE, |
4484 // new MethodData(MethodData.Access.PRIVATE, |
4476 MethodData.Context.INSTANCE); |
4485 // MethodData.Context.INSTANCE); |
4477 final ClassData withDef = |
4486 // final ClassData withDef = |
4478 new ClassData(pck, meth); |
4487 // new ClassData(pck, meth); |
4479 final int I2 = builder.methodref; |
4488 // final int I2 = builder.methodref; |
4480 final int I1 = builder.addInterface(emptyClass(pck)); |
4489 // final int I1 = builder.addInterface(emptyClass(pck)); |
4481 final int C2 = builder.addClass(withDef); |
4490 // final int C2 = builder.addClass(withDef); |
4482 final int C1 = builder.addClass(emptyClass(pck)); |
4491 // final int C1 = builder.addClass(emptyClass(pck)); |
4483 builder.hier.addInherit(C1, I1); |
4492 // builder.hier.addInherit(C1, I1); |
4484 builder.hier.addInherit(C1, C2); |
4493 // builder.hier.addInherit(C1, C2); |
4485 builder.hier.addInherit(I1, I2); |
4494 // builder.hier.addInherit(I1, I2); |
4486 builder.hier.addInherit(C2, I2); |
4495 // builder.hier.addInherit(C2, I2); |
4487 builder.objectref = C1; |
4496 // builder.objectref = C1; |
4488 builder.expected = C2; |
4497 // builder.expected = C2; |
4489 }, |
4498 // }, |
4490 /* Case 5: Diamond, with superclass, expected at top, |
4499 /* Case 5: Diamond, with superclass, expected at top, |
4491 * class overriding with package private. |
4500 * class overriding with package private. |
4492 * |
4501 * |
4493 * I2[](*) = mref |
4502 * I2[](*) = mref |
4494 * C2[I2](pack) = expected, I1[I2]() |
4503 * C2[I2](pack) = expected, I1[I2]() |
4547 * at top, class overrides |
4556 * at top, class overrides |
4548 * |
4557 * |
4549 * C2[](priv) = expected, I1[](*) = mref |
4558 * C2[](priv) = expected, I1[](*) = mref |
4550 * C1[I1,C2]() = oref |
4559 * C1[I1,C2]() = oref |
4551 */ |
4560 */ |
4552 (final SelectionResolutionTestCase.Builder builder) -> { |
4561 // (final SelectionResolutionTestCase.Builder builder) -> { |
4553 final ClassData.Package pck = |
4562 // final ClassData.Package pck = |
4554 builder.classdata.get(builder.expected).packageId; |
4563 // builder.classdata.get(builder.expected).packageId; |
4555 final ClassData oldexpected = |
4564 // final ClassData oldexpected = |
4556 builder.classdata.get(builder.expected); |
4565 // builder.classdata.get(builder.expected); |
4557 final MethodData meth = |
4566 // final MethodData meth = |
4558 new MethodData(MethodData.Access.PRIVATE, |
4567 // new MethodData(MethodData.Access.PRIVATE, |
4559 MethodData.Context.INSTANCE); |
4568 // MethodData.Context.INSTANCE); |
4560 final ClassData withDef = |
4569 // final ClassData withDef = |
4561 new ClassData(pck, meth); |
4570 // new ClassData(pck, meth); |
4562 final int I1 = builder.methodref; |
4571 // final int I1 = builder.methodref; |
4563 final int C2 = builder.addClass(withDef); |
4572 // final int C2 = builder.addClass(withDef); |
4564 final int C1 = builder.addClass(emptyClass(pck)); |
4573 // final int C1 = builder.addClass(emptyClass(pck)); |
4565 builder.hier.addInherit(C1, I1); |
4574 // builder.hier.addInherit(C1, I1); |
4566 builder.hier.addInherit(C1, C2); |
4575 // builder.hier.addInherit(C1, C2); |
4567 builder.objectref = C1; |
4576 // builder.objectref = C1; |
4568 builder.expected = C2; |
4577 // builder.expected = C2; |
4569 }, |
4578 // }, |
4570 /* Case 8: Y, with superclass, overlaping, expected |
4579 /* Case 8: Y, with superclass, overlaping, expected |
4571 * at top, class overrides |
4580 * at top, class overrides |
4572 * |
4581 * |
4573 * C2[](prot) = expected, I1[](*) = mref |
4582 * C2[](prot) = expected, I1[](*) = mref |
4574 * C1[I1,C2]() = oref |
4583 * C1[I1,C2]() = oref |
4620 * |
4629 * |
4621 * I2[](def) = old expected |
4630 * I2[](def) = old expected |
4622 * C2[I2](priv) = expected, I1[](*) = mref |
4631 * C2[I2](priv) = expected, I1[](*) = mref |
4623 * C1[I1,C2]() = oref |
4632 * C1[I1,C2]() = oref |
4624 */ |
4633 */ |
4625 (final SelectionResolutionTestCase.Builder builder) -> { |
4634 // (final SelectionResolutionTestCase.Builder builder) -> { |
4626 final ClassData.Package pck = |
4635 // final ClassData.Package pck = |
4627 builder.classdata.get(builder.expected).packageId; |
4636 // builder.classdata.get(builder.expected).packageId; |
4628 final ClassData oldexpected = |
4637 // final ClassData oldexpected = |
4629 builder.classdata.get(builder.expected); |
4638 // builder.classdata.get(builder.expected); |
4630 final MethodData meth = |
4639 // final MethodData meth = |
4631 new MethodData(MethodData.Access.PRIVATE, |
4640 // new MethodData(MethodData.Access.PRIVATE, |
4632 MethodData.Context.INSTANCE); |
4641 // MethodData.Context.INSTANCE); |
4633 final ClassData withDef = |
4642 // final ClassData withDef = |
4634 new ClassData(pck, meth); |
4643 // new ClassData(pck, meth); |
4635 final int I2 = builder.expected; |
4644 // final int I2 = builder.expected; |
4636 final int I1 = builder.methodref; |
4645 // final int I1 = builder.methodref; |
4637 final int C2 = builder.addClass(withDef); |
4646 // final int C2 = builder.addClass(withDef); |
4638 final int C1 = builder.addClass(emptyClass(pck)); |
4647 // final int C1 = builder.addClass(emptyClass(pck)); |
4639 builder.hier.addInherit(C1, I1); |
4648 // builder.hier.addInherit(C1, I1); |
4640 builder.hier.addInherit(C1, C2); |
4649 // builder.hier.addInherit(C1, C2); |
4641 builder.hier.addInherit(C2, I2); |
4650 // builder.hier.addInherit(C2, I2); |
4642 builder.objectref = C1; |
4651 // builder.objectref = C1; |
4643 builder.expected = C2; |
4652 // builder.expected = C2; |
4644 }, |
4653 // }, |
4645 /* Case 11: Diamond, with superclass, overlaping, expected |
4654 /* Case 11: Diamond, with superclass, overlaping, expected |
4646 * at top, class overrides |
4655 * at top, class overrides |
4647 * |
4656 * |
4648 * I2[](def) = old expected |
4657 * I2[](def) = old expected |
4649 * C2[I2](pack) = expected, I1[](*) = mref |
4658 * C2[I2](pack) = expected, I1[](*) = mref |
4700 * |
4709 * |
4701 * I[](*) = mref |
4710 * I[](*) = mref |
4702 * C2[I](priv) = expected |
4711 * C2[I](priv) = expected |
4703 * C1[C2]() = oref |
4712 * C1[C2]() = oref |
4704 */ |
4713 */ |
4705 (final SelectionResolutionTestCase.Builder builder) -> { |
4714 // (final SelectionResolutionTestCase.Builder builder) -> { |
4706 final ClassData.Package pck = |
4715 // final ClassData.Package pck = |
4707 builder.classdata.get(builder.expected).packageId; |
4716 // builder.classdata.get(builder.expected).packageId; |
4708 final ClassData oldexpected = |
4717 // final ClassData oldexpected = |
4709 builder.classdata.get(builder.expected); |
4718 // builder.classdata.get(builder.expected); |
4710 final MethodData meth = |
4719 // final MethodData meth = |
4711 new MethodData(MethodData.Access.PRIVATE, |
4720 // new MethodData(MethodData.Access.PRIVATE, |
4712 MethodData.Context.INSTANCE); |
4721 // MethodData.Context.INSTANCE); |
4713 final ClassData withDef = |
4722 // final ClassData withDef = |
4714 new ClassData(pck, meth); |
4723 // new ClassData(pck, meth); |
4715 final int I = builder.methodref; |
4724 // final int I = builder.methodref; |
4716 final int C2 = builder.addClass(withDef); |
4725 // final int C2 = builder.addClass(withDef); |
4717 final int C1 = builder.addClass(emptyClass(pck)); |
4726 // final int C1 = builder.addClass(emptyClass(pck)); |
4718 builder.hier.addInherit(C1, I); |
4727 // builder.hier.addInherit(C1, I); |
4719 builder.hier.addInherit(C1, C2); |
4728 // builder.hier.addInherit(C1, C2); |
4720 builder.hier.addInherit(C2, I); |
4729 // builder.hier.addInherit(C2, I); |
4721 builder.expected = C2; |
4730 // builder.expected = C2; |
4722 builder.objectref = C1; |
4731 // builder.objectref = C1; |
4723 }, |
4732 // }, |
4724 /* Case 14: Superclass overrides. |
4733 /* Case 14: Superclass overrides. |
4725 * |
4734 * |
4726 * I[](*) = mref |
4735 * I[](*) = mref |
4727 * C2[I](prot) = expected |
4736 * C2[I](prot) = expected |
4728 * C1[C2]() = oref |
4737 * C1[C2]() = oref |