import java.util.List;

public class YieldTest {

    public static void main(String[] args) {
        List.of("a", "b", "c").forEach((k) -> {
            Object value = switch ("123") {
                case "123" -> {
                    Object temp = new Object();
                  AXMEntity axmEntity = new AXMEntity();
                    axmEntity.addListener(new Runnable() {
                        @Override
                        public void run() {
                            temp.hashCode();
                            //
                            //Accessing objects in the case will result in an error
                        }
                    });
                    yield "null";
                }
                default -> null;
            };
        });
    }

    static class AXMEntity {
        public void addListener(Runnable runnable) {
        }
    }

} 