When instanceof as a type comparison operator is used without any patterns in the current compilation unit, desugaring is skipped.
Sample 1:
import java.util.List;
public class Test {
public static void main(String argv[]) {
List<Short> ls = List.of((short) 42);
System.out.println(ls.get(0) instanceof int);
//System.out.println(ls.get(0) instanceof int p);
}
}
output:
false
Sample 2:
import java.util.List;
public class Test {
public static void main(String argv[]) {
List<Short> ls = List.of((short) 42);
System.out.println(ls.get(0) instanceof int);
System.out.println(ls.get(0) instanceof int p);
}
}
Output:
true
true
Sample 1:
import java.util.List;
public class Test {
public static void main(String argv[]) {
List<Short> ls = List.of((short) 42);
System.out.println(ls.get(0) instanceof int);
//System.out.println(ls.get(0) instanceof int p);
}
}
output:
false
Sample 2:
import java.util.List;
public class Test {
public static void main(String argv[]) {
List<Short> ls = List.of((short) 42);
System.out.println(ls.get(0) instanceof int);
System.out.println(ls.get(0) instanceof int p);
}
}
Output:
true
true
- links to
-
Commit(master) openjdk/jdk/6c1ed0bb
-
Review(master) openjdk/jdk/22541