From e91f2d70a5e810c856889fab7776df1ca4790dc4 Mon Sep 17 00:00:00 2001 From: Martin Kellogg Date: Mon, 29 Jul 2024 17:24:04 -0400 Subject: [PATCH] formatting, make ErrorProne happy --- .../specimin/JavaLangUtils.java | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/checkerframework/specimin/JavaLangUtils.java b/src/main/java/org/checkerframework/specimin/JavaLangUtils.java index 635d893b..be6f8ff1 100644 --- a/src/main/java/org/checkerframework/specimin/JavaLangUtils.java +++ b/src/main/java/org/checkerframework/specimin/JavaLangUtils.java @@ -43,6 +43,12 @@ private JavaLangUtils() { /** Internal set for the names of the primitive types. */ private static final Set primitives = new HashSet<>(8); + /** + * This is an (incomplete) list of classes that we know are final in the JDK. The idea is that + * Specimin should never try to extend a class in this list. + */ + private static final Set knownFinalJdkTypes = new HashSet<>(); + static { primitives.add("int"); primitives.add("short"); @@ -178,6 +184,34 @@ private JavaLangUtils() { javaLangClassesAndInterfaces.add("VirtualMachineError"); javaLangClassesAndInterfaces.add("Void"); javaLangClassesAndInterfaces.add("WrongThreadException"); + + // I made this list by going through the members of + // java.lang and checking which were final classes. We + // can do the same for other packages as needed. + knownFinalJdkTypes.add("String"); + knownFinalJdkTypes.add("Class"); + knownFinalJdkTypes.add("Integer"); + knownFinalJdkTypes.add("Byte"); + knownFinalJdkTypes.add("Short"); + knownFinalJdkTypes.add("Long"); + knownFinalJdkTypes.add("Double"); + knownFinalJdkTypes.add("Float"); + knownFinalJdkTypes.add("Character"); + knownFinalJdkTypes.add("Character.UnicodeBlock"); + knownFinalJdkTypes.add("Boolean"); + knownFinalJdkTypes.add("Compiler"); + knownFinalJdkTypes.add("Math"); + knownFinalJdkTypes.add("ProcessBuilder"); + knownFinalJdkTypes.add("RuntimePermission"); + knownFinalJdkTypes.add("StackTraceElement"); + knownFinalJdkTypes.add("StrictMath"); + knownFinalJdkTypes.add("StringBuffer"); + knownFinalJdkTypes.add("StringBuilder"); + knownFinalJdkTypes.add("System"); + knownFinalJdkTypes.add("Void"); + for (String s : knownFinalJdkTypes) { + knownFinalJdkTypes.add("java.lang." + s); + } } /** The integral primitives. */ @@ -297,48 +331,13 @@ public static boolean inJdkPackage(String qualifiedName) { || qualifiedName.startsWith("jdk."); } - /** - * This is an (incomplete) list of classes that we know are final in the JDK. - * The idea is that Specimin should never try to extend a class in this list. - */ - private static final Set knownFinalJdkTypes = - new HashSet<>() {{ - // I made this list by going through the members of - // java.lang and checking which were final classes. We - // can do the same for other packages as needed. - add("String"); - add("Class"); - add("Integer"); - add("Byte"); - add("Short"); - add("Long"); - add("Double"); - add("Float"); - add("Character"); - add("Character.UnicodeBlock"); - add("Boolean"); - add("Compiler"); - add("Math"); - add("ProcessBuilder"); - add("RuntimePermission"); - add("StackTraceElement"); - add("StrictMath"); - add("StringBuffer"); - add("StringBuilder"); - add("System"); - add("Void"); - for (String s : this) { - add("java.lang." + s); - } - }}; - /** * Could the given name be a final class from the JDK, like String? * * @param name a simple or fully-qualified name * @return true if the input might be a final JDK class */ - public static boolean isFinalJdkClass(String name) { - return knownFinalJdkTypes.contains(name); - } + public static boolean isFinalJdkClass(String name) { + return knownFinalJdkTypes.contains(name); + } }