|
package fixtures;
|
|
|
|
import java.util.*;
|
|
import java.nio.charset.*;
|
|
|
|
// Unicode comment: δ½ ε₯½δΈη ππ
|
|
|
|
public class EdgeCases {
|
|
public static void main(String[] args) throws Exception {
|
|
// Unicode string literals
|
|
String unicode = "γγγ«γ‘γ―δΈη";
|
|
System.out.println(unicode);
|
|
|
|
// Null byte in string
|
|
String nullStr = "hello\u0000world";
|
|
System.out.println("Null-str length: " + nullStr.length());
|
|
|
|
// Deeply nested classes
|
|
Map<Integer, Map<Integer, Map<Integer, Map<Integer, Map<Integer, String>>>>> deep =
|
|
new HashMap<>();
|
|
Map<Integer, Map<Integer, Map<Integer, Map<Integer, String>>>> l4 = new HashMap<>();
|
|
Map<Integer, Map<Integer, Map<Integer, String>>> l3 = new HashMap<>();
|
|
Map<Integer, Map<Integer, String>> l2 = new HashMap<>();
|
|
Map<Integer, String> l1 = new HashMap<>();
|
|
l1.put(5, "deep");
|
|
l2.put(4, l1);
|
|
l3.put(3, l2);
|
|
l4.put(2, l3);
|
|
deep.put(1, l4);
|
|
System.out.println(deep.get(1).get(2).get(3).get(4).get(5));
|
|
|
|
// Very long string
|
|
StringBuilder sb = new StringBuilder(10000);
|
|
for (int i = 0; i < 10000; i++) sb.append('x');
|
|
System.out.println("Long string length: " + sb.length());
|
|
|
|
// BOM prefix
|
|
byte[] bom = {(byte)0xEF, (byte)0xBB, (byte)0xBF, (byte)'H', (byte)'i'};
|
|
System.out.println(new String(bom, StandardCharsets.UTF_8));
|
|
|
|
// Deep exception chaining
|
|
try {
|
|
try {
|
|
try {
|
|
throw new RuntimeException("inner");
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("middle", e);
|
|
}
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("outer", e);
|
|
}
|
|
} catch (Exception e) {
|
|
System.out.println("Chained: " + e.getMessage());
|
|
}
|
|
|
|
// Deep array nesting
|
|
int[][][][][][] deepArray = new int[2][2][2][2][2][2];
|
|
deepArray[0][0][0][0][0][0] = 42;
|
|
System.out.println("Deep array: " + deepArray[0][0][0][0][0][0]);
|
|
}
|
|
}
|