Вот созданный мной тестовый класс:
Код: Выделить всё
public class Test {
static void checkType(T value) {
switch (value) {
case Integer i -> System.out.println("Integer");
case String s -> System.out.println("String");
default -> throw new IllegalArgumentException("Unsupported type: " + value.getClass());
}
}
public static void main(String[] args) {
checkType("Some string");
checkType(21);
}
}
Код: Выделить всё
java Test.javaКод: Выделить всё
String
Integer
Код: Выделить всё
An exception has occurred in the compiler (21.0.3). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.lang.runtime.SwitchBootstraps not found
Я также установил соответствующие параметры в свой build.gradle.kts (
Код: Выделить всё
compileOptionsПодробнее здесь: https://stackoverflow.com/questions/786 ... in-android
Мобильная версия