From a87ea95fcfd19346806dab771cfebddf3eb08c8c Mon Sep 17 00:00:00 2001 From: David Schachter Date: Thu, 23 Jul 2026 14:51:16 -0700 Subject: [PATCH] ADFA-4551: Remove dead serialver tool and unused public-suffix data SerialVer and its resource bundles (sun/tools/serialver) have no callers anywhere outside their own module - dead code vendored from OpenJDK. Also exclude httpclient's bundled public-suffix cookie-domain list: no code in this repo calls Apache HttpClient directly, so the data is pure dead weight pulled in transitively. Co-Authored-By: Claude Sonnet 5 --- app/build.gradle.kts | 3 + .../java/sun/tools/serialver/SerialVer.java | 289 ------------------ .../serialver/resources/serialver.properties | 37 --- .../resources/serialver_ja.properties | 31 -- .../resources/serialver_zh_CN.properties | 31 -- 5 files changed, 3 insertions(+), 388 deletions(-) delete mode 100644 composite-builds/build-deps/jdk-compiler/src/main/java/sun/tools/serialver/SerialVer.java delete mode 100644 composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver.properties delete mode 100644 composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_ja.properties delete mode 100644 composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_zh_CN.properties diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b1a8d310cc..447699a3d0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -117,6 +117,9 @@ android { excludes += "META-INF/DEPENDENCIES" excludes += "META-INF/gradle/incremental.annotation.processors" + // httpclient's public-suffix cookie-domain data; unused, no code touches Apache HttpClient directly. + excludes += "mozilla/public-suffix-list.txt" + pickFirsts += "kotlin/internal/internal.kotlin_builtins" pickFirsts += "kotlin/reflect/reflect.kotlin_builtins" pickFirsts += "kotlin/kotlin.kotlin_builtins" diff --git a/composite-builds/build-deps/jdk-compiler/src/main/java/sun/tools/serialver/SerialVer.java b/composite-builds/build-deps/jdk-compiler/src/main/java/sun/tools/serialver/SerialVer.java deleted file mode 100644 index 3491e9ea57..0000000000 --- a/composite-builds/build-deps/jdk-compiler/src/main/java/sun/tools/serialver/SerialVer.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.tools.serialver; - -import java.io.*; -import java.io.ObjectStreamClass; -import java.nio.file.Paths; -import java.text.MessageFormat; -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import java.net.URLClassLoader; -import java.net.URL; -import java.net.MalformedURLException; - -/** - * Supporting class for the serialver tool. - */ -public class SerialVer { - - /* - * A class loader that will load from the CLASSPATH environment - * variable set by the user. - */ - static URLClassLoader loader = null; - - /* - * Create a URL class loader that will load classes from the - * specified classpath. - */ - static void initializeLoader(String cp) throws IOException { - String[] paths = cp.split(File.pathSeparator); - int count = paths.length; - URL[] urls = new URL[count]; - for (int i = 0; i < count; i++) { - urls[i] = Paths.get(paths[i]).toUri().toURL(); - } - loader = new URLClassLoader(urls); - } - - /* - * From the classname find the serialVersionUID string formatted - * for to be copied to a java class. - */ - static String serialSyntax(String classname) throws ClassNotFoundException { - String ret = null; - boolean classFound = false; - - // If using old style of qualifying inner classes with '$'s. - if (classname.indexOf('$') != -1) { - ret = resolveClass(classname); - } else { - /* Try to resolve the fully qualified name and if that fails, start - * replacing the '.'s with '$'s starting from the last '.', until - * the class is resolved. - */ - try { - ret = resolveClass(classname); - classFound = true; - } catch (ClassNotFoundException e) { - /* Class not found so far */ - } - if (!classFound) { - StringBuilder workBuffer = new StringBuilder(classname); - String workName = workBuffer.toString(); - int i; - while ((i = workName.lastIndexOf('.')) != -1 && !classFound) { - workBuffer.setCharAt(i, '$'); - try { - workName = workBuffer.toString(); - ret = resolveClass(workName); - classFound = true; - } catch (ClassNotFoundException e) { - /* Continue searching */ - } - } - } - if (!classFound) { - throw new ClassNotFoundException(); - } - } - return ret; - } - - static String resolveClass(String classname) throws ClassNotFoundException { - Class cl = Class.forName(classname, false, loader); - ObjectStreamClass desc = ObjectStreamClass.lookup(cl); - if (desc != null) { - return " private static final long serialVersionUID = " + - desc.getSerialVersionUID() + "L;"; - } else { - return null; - } - } - - /** - * Entry point for serialver tool. - * @param args the arguments - */ - public static void main(String[] args) { - String envcp = null; - int i = 0; - - if (args.length == 0) { - usage(); - System.exit(1); - } - - for (i = 0; i < args.length; i++) { - if (args[i].equals("-classpath")) { - if ((i+1 == args.length) || args[i+1].startsWith("-")) { - System.err.println(Res.getText("error.missing.classpath")); - usage(); - System.exit(1); - } - envcp = new String(args[i+1]); - i++; - } else if (args[i].startsWith("-")) { - System.err.println(Res.getText("invalid.flag", args[i])); - usage(); - System.exit(1); - } else { - break; // drop into processing class names - } - } - - - /* - * Get user's CLASSPATH environment variable, if the -classpath option - * is not defined, and make a loader that can read from that path. - */ - if (envcp == null) { - envcp = System.getProperty("env.class.path"); - /* - * If environment variable not set, add current directory to path. - */ - if (envcp == null) { - envcp = "."; - } - } - - try { - initializeLoader(envcp); - } catch (MalformedURLException mue) { - System.err.println(Res.getText("error.parsing.classpath", envcp)); - System.exit(2); - } catch (IOException ioe) { - System.err.println(Res.getText("error.parsing.classpath", envcp)); - System.exit(3); - } - - /* - * Check if there are any class names specified - */ - if (i == args.length) { - usage(); - System.exit(1); - } - - /* - * The rest of the parameters are classnames. - */ - boolean exitFlag = false; - for (i = i; i < args.length; i++ ) { - try { - String syntax = serialSyntax(args[i]); - if (syntax != null) - System.out.println(args[i] + ":" + syntax); - else { - System.err.println(Res.getText("NotSerializable", - args[i])); - exitFlag = true; - } - } catch (ClassNotFoundException cnf) { - System.err.println(Res.getText("ClassNotFound", args[i])); - exitFlag = true; - } - } - if (exitFlag) { - System.exit(1); - } - } - - - /** - * Usage - */ - public static void usage() { - System.err.println(Res.getText("usage")); - } - -} - -/** - * Utility for integrating with serialver and for localization. - * Handle Resources. Access to error and warning counts. - * Message formatting. - * - * @see java.util.ResourceBundle - * @see java.text.MessageFormat - */ -class Res { - - private static ResourceBundle messageRB; - - /** - * Initialize ResourceBundle - */ - static void initResource() { - try { - messageRB = - ResourceBundle.getBundle("sun.tools.serialver.resources.serialver"); - } catch (MissingResourceException e) { - throw new Error("Fatal: Resource for serialver is missing"); - } - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - */ - static String getText(String key) { - return getText(key, (String)null); - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument - */ - static String getText(String key, String a1) { - return getText(key, a1, null); - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - */ - static String getText(String key, String a1, String a2) { - return getText(key, a1, a2, null); - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - * @param a3 third argument - */ - static String getText(String key, String a1, String a2, String a3) { - if (messageRB == null) { - initResource(); - } - try { - String message = messageRB.getString(key); - return MessageFormat.format(message, a1, a2, a3); - } catch (MissingResourceException e) { - throw new Error("Fatal: Resource for serialver is broken. There is no " + key + " key in resource."); - } - } -} diff --git a/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver.properties b/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver.properties deleted file mode 100644 index 0d5242018d..0000000000 --- a/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver.properties +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -NotSerializable=\ - Class {0} is not Serializable. -ClassNotFound=\ - Class {0} not found. -error.parsing.classpath=\ - Error parsing classpath {0}. -error.missing.classpath=\ - Missing argument for -classpath option -invalid.flag=\ - Invalid flag {0}. -usage=\ - use: serialver [-classpath classpath] [classname...] diff --git a/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_ja.properties b/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_ja.properties deleted file mode 100644 index 6899736c4e..0000000000 --- a/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_ja.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -NotSerializable=\u30AF\u30E9\u30B9{0}\u306F\u76F4\u5217\u5316\u3067\u304D\u307E\u305B\u3093\u3002 -ClassNotFound=\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 -error.parsing.classpath=\u30AF\u30E9\u30B9\u30D1\u30B9{0}\u306E\u89E3\u6790\u30A8\u30E9\u30FC\u3067\u3059\u3002 -error.missing.classpath=-classpath\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 -invalid.flag=\u7121\u52B9\u306A\u30D5\u30E9\u30B0{0}\u3002 -usage=\u4F7F\u7528\u65B9\u6CD5: serialver [-classpath classpath] [classname...] diff --git a/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_zh_CN.properties b/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_zh_CN.properties deleted file mode 100644 index 804118ea73..0000000000 --- a/composite-builds/build-deps/jdk-compiler/src/main/resources/sun/tools/serialver/resources/serialver_zh_CN.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -NotSerializable=\u7C7B{0}\u65E0\u6CD5\u5E8F\u5217\u5316\u3002 -ClassNotFound=\u627E\u4E0D\u5230\u7C7B{0}\u3002 -error.parsing.classpath=\u5BF9\u7C7B\u8DEF\u5F84 {0} \u8FDB\u884C\u8BED\u6CD5\u5206\u6790\u65F6\u51FA\u9519\u3002 -error.missing.classpath=\u7F3A\u5C11 -classpath \u9009\u9879\u7684\u53C2\u6570 -invalid.flag=\u65E0\u6548\u6807\u8BB0{0}\u3002 -usage=\u7528\u6CD5: serialver [-classpath classpath] [classname...]