diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java index 8e8dfd00058..2fb21a17a2d 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, 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 @@ -1807,11 +1807,7 @@ public class Code { for (int i=0; i switch (e2) { + case A -> new Impl1a(); + case B -> new Impl1b(); + case C -> new Impl1c(); + }; + case B -> switch (e2) { + case A -> new Impl2a(); + case B -> new Impl2b(); + case C -> new Impl2c(); + }; + case C -> switch (e2) { + case A -> new Impl3a(); + case B -> new Impl3b(); + case C -> new Impl3c(); + }; + }; + } + + private int runMethodForInterfaceTypeAtMergePoint1(E e1, E e2) { + return (switch (e1) { + case A -> switch (e2) { + case A -> new C1(); + case B -> new C1(); + case C -> new C1(); + }; + case B -> switch (e2) { + case A -> new C2(); + case B -> new C2(); + case C -> new C2(); + }; + case C -> switch (e2) { + case A -> new C3(); + case B -> new C3(); + case C -> new C3(); + }; + }).test1(); + } + + private int runMethodForInterfaceTypeAtMergePoint2(E e1, E e2) { + return (switch (e1) { + case A -> switch (e2) { + case A -> new C1(); + case B -> new C1(); + case C -> new C1(); + }; + case B -> switch (e2) { + case A -> new C2(); + case B -> new C2(); + case C -> new C2(); + }; + case C -> switch (e2) { + case A -> new C3(); + case B -> new C3(); + case C -> new C3(); + }; + }).test2(); + } + + private static class Root {} + private static class Base1 extends Root {} + private static class Impl1a extends Base1 {} + private static class Impl1b extends Base1 {} + private static class Impl1c extends Base1 {} + private static class Base2 extends Root {} + private static class Impl2a extends Base2 {} + private static class Impl2b extends Base2 {} + private static class Impl2c extends Base2 {} + private static class Base3 extends Root {} + private static class Impl3a extends Base3 {} + private static class Impl3b extends Base3 {} + private static class Impl3c extends Base3 {} + + private static interface RootInterface1 { + public default int test1() { + return 1; + } + } + private static interface RootInterface2 { + public default int test2() { + return 2; + } + } + private static class C1 implements RootInterface1, RootInterface2 {} + private static class C2 implements RootInterface1, RootInterface2 {} + private static class C3 implements RootInterface1, RootInterface2 {} + + enum E {A, B, C;} + private void throwException() { throw new RuntimeException(); }