24 package jdk.test.lib; 25 26 import java.io.File; 27 import static jdk.test.lib.Asserts.assertTrue; 28 import java.io.IOException; 29 import java.lang.reflect.Field; 30 import java.net.InetAddress; 31 import java.net.MalformedURLException; 32 import java.net.ServerSocket; 33 import java.net.URL; 34 import java.net.URLClassLoader; 35 import java.net.UnknownHostException; 36 import java.nio.file.Files; 37 import java.nio.file.Path; 38 import java.nio.file.Paths; 39 import java.util.ArrayList; 40 import java.util.Arrays; 41 import java.util.Collection; 42 import java.util.Collections; 43 import java.util.Iterator; 44 import java.util.List; 45 import java.util.Random; 46 import java.util.function.BooleanSupplier; 47 import java.util.concurrent.TimeUnit; 48 import java.util.function.Consumer; 49 import java.util.regex.Matcher; 50 import java.util.regex.Pattern; 51 import sun.misc.Unsafe; 52 53 /** 54 * Common library for various test helper functions. 55 */ 56 public final class Utils { 57 58 /** 59 * Returns the value of 'test.class.path' system property. 60 */ 61 public static final String TEST_CLASS_PATH = System.getProperty("test.class.path", "."); 62 63 /** 577 } else if (type == float.class) { 578 return "F"; 579 } else if (type == int.class) { 580 return "I"; 581 } else if (type == long.class) { 582 return "J"; 583 } else if (type == short.class) { 584 return "S"; 585 } else if (type == void.class) { 586 return "V"; 587 } else { 588 throw new Error("Unsupported type: " + type); 589 } 590 } 591 String result = type.getName().replaceAll("\\.", "/"); 592 if (!type.isArray()) { 593 return "L" + result + ";"; 594 } 595 return result; 596 } 597 } 598 | 24 package jdk.test.lib; 25 26 import java.io.File; 27 import static jdk.test.lib.Asserts.assertTrue; 28 import java.io.IOException; 29 import java.lang.reflect.Field; 30 import java.net.InetAddress; 31 import java.net.MalformedURLException; 32 import java.net.ServerSocket; 33 import java.net.URL; 34 import java.net.URLClassLoader; 35 import java.net.UnknownHostException; 36 import java.nio.file.Files; 37 import java.nio.file.Path; 38 import java.nio.file.Paths; 39 import java.util.ArrayList; 40 import java.util.Arrays; 41 import java.util.Collection; 42 import java.util.Collections; 43 import java.util.Iterator; 44 import java.util.Map; 45 import java.util.HashMap; 46 import java.util.List; 47 import java.util.Random; 48 import java.util.function.BooleanSupplier; 49 import java.util.concurrent.TimeUnit; 50 import java.util.function.Consumer; 51 import java.util.regex.Matcher; 52 import java.util.regex.Pattern; 53 import sun.misc.Unsafe; 54 55 /** 56 * Common library for various test helper functions. 57 */ 58 public final class Utils { 59 60 /** 61 * Returns the value of 'test.class.path' system property. 62 */ 63 public static final String TEST_CLASS_PATH = System.getProperty("test.class.path", "."); 64 65 /** 579 } else if (type == float.class) { 580 return "F"; 581 } else if (type == int.class) { 582 return "I"; 583 } else if (type == long.class) { 584 return "J"; 585 } else if (type == short.class) { 586 return "S"; 587 } else if (type == void.class) { 588 return "V"; 589 } else { 590 throw new Error("Unsupported type: " + type); 591 } 592 } 593 String result = type.getName().replaceAll("\\.", "/"); 594 if (!type.isArray()) { 595 return "L" + result + ";"; 596 } 597 return result; 598 } 599 600 public static Object[] getNullValues(Class<?>... types) { 601 Object[] result = new Object[types.length]; 602 int i = 0; 603 for (Class<?> type : types) { 604 result[i++] = NULL_VALUES.get(type); 605 } 606 return result; 607 } 608 private static Map<Class<?>, Object> NULL_VALUES = new HashMap<>(); 609 static { 610 NULL_VALUES.put(boolean.class, false); 611 NULL_VALUES.put(byte.class, (byte) 0); 612 NULL_VALUES.put(short.class, (short) 0); 613 NULL_VALUES.put(char.class, '\0'); 614 NULL_VALUES.put(int.class, 0); 615 NULL_VALUES.put(long.class, 0L); 616 NULL_VALUES.put(float.class, 0.0f); 617 NULL_VALUES.put(double.class, 0.0d); 618 } 619 } 620 |