diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index 56594238261..1a13e191468 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2025, 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 @@ -64,7 +64,6 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \ HEADERS := $(TEST_LIB_SUPPORT)/test-lib_headers, \ JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \ - DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast removal preview restricted dangling-doc-comments, \ JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ diff --git a/test/lib/jdk/test/lib/Asserts.java b/test/lib/jdk/test/lib/Asserts.java index 1f23a64f811..e7228ace7be 100644 --- a/test/lib/jdk/test/lib/Asserts.java +++ b/test/lib/jdk/test/lib/Asserts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -638,7 +638,7 @@ public class Asserts { testMethod.execute(); } catch (Throwable exc) { if (expected.isInstance(exc)) { - return (T) exc; + return expected.cast(exc); } else { fail(Objects.toString(msg, "An unexpected exception was thrown.") + " Expected " + expected.getName(), exc); diff --git a/test/lib/jdk/test/lib/apps/LingeredApp.java b/test/lib/jdk/test/lib/apps/LingeredApp.java index 73904b81848..13008e68c54 100644 --- a/test/lib/jdk/test/lib/apps/LingeredApp.java +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, 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 @@ -429,7 +429,7 @@ public class LingeredApp { } } - /** + /* * High level interface for test writers */ @@ -599,6 +599,7 @@ public class LingeredApp { * This part is the application itself. First arg is optional "forceCrash". * Following arg is the lock file name. */ + @SuppressWarnings("restricted") public static void main(String args[]) { boolean forceCrash = false; diff --git a/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java b/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java index d8be12d86c2..cac371b482b 100644 --- a/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java +++ b/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -33,7 +33,7 @@ public class ArtifactResolver { try { String managerName = System.getProperty("jdk.test.lib.artifacts.artifactmanager"); if (managerName != null) { - manager = (ArtifactManager) Class.forName(managerName).newInstance(); + manager = (ArtifactManager) Class.forName(managerName).getDeclaredConstructor().newInstance(); } else if (System.getenv().containsKey(JibArtifactManager.JIB_HOME_ENV_NAME)) { manager = JibArtifactManager.newInstance(); } else { diff --git a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java index c06f5d7b70f..6cc010f3b63 100644 --- a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java +++ b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -23,10 +23,14 @@ package jdk.test.lib.artifacts; +import java.io.Serial; + /** * Thrown by the ArtifactResolver when failing to resolve an Artifact. */ public class ArtifactResolverException extends Exception { + @Serial + private static final long serialVersionUID = 8341884506180926911L; public ArtifactResolverException(String message) { super(message); diff --git a/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java b/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java index a66be9b4826..3d27709ce03 100644 --- a/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java +++ b/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -75,7 +75,7 @@ public class JibArtifactManager implements ArtifactManager { ClassLoader oldContextLoader = currentThread.getContextClassLoader(); currentThread.setContextClassLoader(classLoader); - Class jibServiceFactory = classLoader.loadClass(JIB_SERVICE_FACTORY); + Class jibServiceFactory = classLoader.loadClass(JIB_SERVICE_FACTORY); try { Object jibArtifactInstaller = jibServiceFactory.getMethod("createJibArtifactInstaller").invoke(null); return new JibArtifactManager(jibArtifactInstaller, classLoader); diff --git a/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java b/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java index 11bea44fa33..89c1ea9e4ac 100644 --- a/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java +++ b/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -32,6 +32,7 @@ package jdk.test.lib.classloader; import jdk.test.whitebox.WhiteBox; import java.io.File; +import java.io.Serial; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; @@ -45,6 +46,9 @@ import java.util.stream.Stream; public class ClassUnloadCommon { public static class TestFailure extends RuntimeException { + @Serial + private static final long serialVersionUID = -8108935949624559549L; + TestFailure(String msg) { super(msg); } diff --git a/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java b/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java index ee1089bac4d..19dd4df9591 100644 --- a/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java +++ b/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, 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 @@ -38,13 +38,13 @@ class TemplateClass { public class GeneratingClassLoader extends ClassLoader { - public synchronized Class loadClass(String name) throws ClassNotFoundException { + public synchronized Class loadClass(String name) throws ClassNotFoundException { return loadClass(name, false); } - public synchronized Class loadClass(String name, boolean resolve) + public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - Class c = findLoadedClass(name); + Class c = findLoadedClass(name); if (c != null) { return c; } @@ -129,7 +129,7 @@ public class GeneratingClassLoader extends ClassLoader { throw new RuntimeException("Class name not found in template class file"); } } - return (byte[]) bytecode.clone(); + return bytecode.clone(); } private void readByteCode() throws ClassNotFoundException { diff --git a/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java b/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java index 34e3a250cdd..5e040b689f0 100644 --- a/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java +++ b/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -202,7 +202,7 @@ public class GeneratingCompilingClassLoader extends ClassLoader { */ public Class[] getGeneratedClasses(int sizeFactor, int numClasses) throws IOException { GeneratedClass[] gc = getGeneratedClass(sizeFactor, numClasses); - Class[] classes = new Class[numClasses]; + Class[] classes = new Class[numClasses]; for (int i = 0; i < numClasses; ++i) { classes[i] = defineClass(gc[i].name, gc[i].bytes, 0 , gc[i].bytes.length); } diff --git a/test/lib/jdk/test/lib/format/ArrayDiff.java b/test/lib/jdk/test/lib/format/ArrayDiff.java index 1e0aedad94b..67b75ef3dce 100644 --- a/test/lib/jdk/test/lib/format/ArrayDiff.java +++ b/test/lib/jdk/test/lib/format/ArrayDiff.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -107,7 +107,7 @@ public class ArrayDiff implements Diff { * @throws NullPointerException if at least one of the arrays is null * @return an ArrayDiff instance for the two arrays and formatting parameters provided */ - @SuppressWarnings("rawtypes") + @SuppressWarnings({"rawtypes", "unchecked"}) public static ArrayDiff of(Object first, Object second, int width, int contextBefore) { Objects.requireNonNull(first); Objects.requireNonNull(second); diff --git a/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java index b50045a7287..9841e1b01c5 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -35,12 +35,6 @@ import java.util.HashMap; import java.util.Map; import jdk.test.lib.hprof.util.Misc; - -/** - * - * @author Bill Foote - */ - /** * Represents an object that's allocated out of the Java heap. It occupies * memory in the VM, and is the sort of thing that in a JDK 1.1 VM had diff --git a/test/lib/jdk/test/lib/hprof/model/JavaStatic.java b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java index 0fa3fbb06dc..fbb794def56 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaStatic.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -30,11 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - /** * Represents the value of a static field of a JavaClass */ diff --git a/test/lib/jdk/test/lib/hprof/model/JavaThing.java b/test/lib/jdk/test/lib/hprof/model/JavaThing.java index a76c9cc3198..9674a413d24 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaThing.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaThing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -30,12 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - - /** * Represents a java "Thing". A thing is anything that can be the value of * a field. This includes JavaHeapObject, JavaObjectRef, and JavaValue. diff --git a/test/lib/jdk/test/lib/hprof/model/Root.java b/test/lib/jdk/test/lib/hprof/model/Root.java index 3e87eb22a44..c3b821be076 100644 --- a/test/lib/jdk/test/lib/hprof/model/Root.java +++ b/test/lib/jdk/test/lib/hprof/model/Root.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -32,12 +32,6 @@ package jdk.test.lib.hprof.model; import jdk.test.lib.hprof.util.Misc; -/** - * - * @author Bill Foote - */ - - /** * Represents a member of the rootset, that is, one of the objects that * the GC starts from when marking reachable objects. diff --git a/test/lib/jdk/test/lib/hprof/model/Snapshot.java b/test/lib/jdk/test/lib/hprof/model/Snapshot.java index 3ea77b876fd..dbb9c7fd1f3 100644 --- a/test/lib/jdk/test/lib/hprof/model/Snapshot.java +++ b/test/lib/jdk/test/lib/hprof/model/Snapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -30,17 +30,13 @@ package jdk.test.lib.hprof.model; +import java.io.IOException; import java.lang.ref.SoftReference; import java.util.*; import jdk.test.lib.hprof.parser.ReadBuffer; import jdk.test.lib.hprof.util.Misc; -/** - * - * @author Bill Foote - */ - /** * Represents a snapshot of the Java objects in the VM at one instant. * This is the top-level "model" object read out of a single .hprof or .bod @@ -637,7 +633,7 @@ public class Snapshot implements AutoCloseable { } @Override - public void close() throws Exception { + public void close() throws IOException { readBuf.close(); } diff --git a/test/lib/jdk/test/lib/hprof/model/StackFrame.java b/test/lib/jdk/test/lib/hprof/model/StackFrame.java index 0ea2b0e4716..851faffd67c 100644 --- a/test/lib/jdk/test/lib/hprof/model/StackFrame.java +++ b/test/lib/jdk/test/lib/hprof/model/StackFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -30,12 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - - /** * Represents a stack frame. */ diff --git a/test/lib/jdk/test/lib/hprof/model/StackTrace.java b/test/lib/jdk/test/lib/hprof/model/StackTrace.java index ecab592e342..b4a9c667812 100644 --- a/test/lib/jdk/test/lib/hprof/model/StackTrace.java +++ b/test/lib/jdk/test/lib/hprof/model/StackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -30,12 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - - /** * Represents a stack trace, that is, an ordered collection of stack frames. */ diff --git a/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java index eab5cff84c8..be7672170b6 100644 --- a/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -86,7 +86,7 @@ class FileReadBuffer implements ReadBuffer { } @Override - public void close() throws Exception { + public void close() throws IOException { file.close(); } } diff --git a/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java index d91c453a0f6..96da03a4057 100644 --- a/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -127,7 +127,7 @@ class MappedReadBuffer implements ReadBuffer { } @Override - public void close() throws Exception { + public void close() throws IOException { file.close(); } diff --git a/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java index 4b06b79a53b..03c9d5d4a42 100644 --- a/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -43,4 +43,5 @@ public interface ReadBuffer extends AutoCloseable { public short getShort(long pos) throws IOException; public int getInt(long pos) throws IOException; public long getLong(long pos) throws IOException; + public void close() throws IOException; } diff --git a/test/lib/jdk/test/lib/hprof/parser/Reader.java b/test/lib/jdk/test/lib/hprof/parser/Reader.java index 447d96e770e..7732befe503 100644 --- a/test/lib/jdk/test/lib/hprof/parser/Reader.java +++ b/test/lib/jdk/test/lib/hprof/parser/Reader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, 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 @@ -63,6 +63,7 @@ public abstract class Reader { * @param heapFile The name of a file containing a heap dump * @param callStack If true, read the call stack of allocaation sites */ + @SuppressWarnings("try") public static Snapshot readFile(String heapFile, boolean callStack, int debugLevel) throws IOException { @@ -136,6 +137,7 @@ public abstract class Reader { * * @param heapFile The name of a file containing a heap dump */ + @SuppressWarnings("try") public static String getStack(String heapFile, int debugLevel) throws IOException { int dumpNumber = 1; diff --git a/test/lib/jdk/test/lib/jfr/Events.java b/test/lib/jdk/test/lib/jfr/Events.java index 5a180659f9f..5676b7021d6 100644 --- a/test/lib/jdk/test/lib/jfr/Events.java +++ b/test/lib/jdk/test/lib/jfr/Events.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -233,7 +233,7 @@ public class Events { private static void assertThread(RecordedThread eventThread, Thread thread) { assertNotNull(eventThread, "Thread in event was null"); - assertEquals(eventThread.getJavaThreadId(), thread.getId(), "Wrong thread id"); + assertEquals(eventThread.getJavaThreadId(), thread.threadId(), "Wrong thread id"); assertEquals(eventThread.getJavaName(), thread.getName(), "Wrong thread name"); ThreadGroup threadGroup = thread.getThreadGroup(); diff --git a/test/lib/jdk/test/lib/jvmti/DebugeeClass.java b/test/lib/jdk/test/lib/jvmti/DebugeeClass.java index c71e25edd99..9025d5eefe8 100644 --- a/test/lib/jdk/test/lib/jvmti/DebugeeClass.java +++ b/test/lib/jdk/test/lib/jvmti/DebugeeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -23,6 +23,8 @@ package jdk.test.lib.jvmti; +import java.io.Serial; + /** * Base class for debuggee class in JVMTI tests. * @@ -49,6 +51,7 @@ public class DebugeeClass { /** * This method is used to load library with native methods implementation, if needed. */ + @SuppressWarnings("restricted") public static void loadLibrary(String name) { try { System.loadLibrary(name); @@ -70,6 +73,9 @@ public class DebugeeClass { } public class Failure extends RuntimeException { + @Serial + private static final long serialVersionUID = -4069390356498980839L; + public Failure() { } diff --git a/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java index eeb4297f500..c42d78ad177 100644 --- a/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java +++ b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, 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 @@ -45,7 +45,7 @@ public final class ThreadMXBeanTool { + Integer.toHexString(System.identityHashCode(object)); ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); while (thread.isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + ThreadInfo ti = tmx.getThreadInfo(thread.threadId()); if (ti.getThreadState() == state && (want == null || want.equals(ti.getLockName()))) { return; @@ -60,7 +60,7 @@ public final class ThreadMXBeanTool { public static void waitUntilInNative(Thread thread) throws InterruptedException { ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); while (thread.isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + ThreadInfo ti = tmx.getThreadInfo(thread.threadId()); if (ti.isInNative()) { return; } diff --git a/test/lib/jdk/test/lib/net/IPSupport.java b/test/lib/jdk/test/lib/net/IPSupport.java index 4c606fe9b42..31255e20c6a 100644 --- a/test/lib/jdk/test/lib/net/IPSupport.java +++ b/test/lib/jdk/test/lib/net/IPSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -60,6 +60,7 @@ public class IPSupport { } } + @SuppressWarnings("try") private static boolean isSupported(Class addressType) { ProtocolFamily family = addressType == Inet4Address.class ? StandardProtocolFamily.INET : StandardProtocolFamily.INET6; diff --git a/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java b/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java index 0bb6db16021..0873cb2b5d0 100644 --- a/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java +++ b/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -160,7 +160,6 @@ public class HugePageConfiguration { while (scanner.hasNextLine()) { Matcher mat = pat.matcher(scanner.nextLine()); if (mat.matches()) { - scanner.close(); return Long.parseLong(mat.group(1)) * 1024; } } diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java index bfee1d1820d..7d03268cac4 100644 --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -981,7 +981,7 @@ public final class ProcessTools { String[] classArgs = new String[args.length - 2]; System.arraycopy(args, 2, classArgs, 0, args.length - 2); Class c = Class.forName(className); - Method mainMethod = c.getMethod("main", new Class[] { String[].class }); + Method mainMethod = c.getMethod("main", new Class[] { String[].class }); mainMethod.setAccessible(true); if (testThreadFactoryName.equals("Virtual")) { diff --git a/test/lib/jdk/test/lib/thread/VThreadPinner.java b/test/lib/jdk/test/lib/thread/VThreadPinner.java index f77dba978ef..c6b332d2791 100644 --- a/test/lib/jdk/test/lib/thread/VThreadPinner.java +++ b/test/lib/jdk/test/lib/thread/VThreadPinner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -114,7 +114,9 @@ public class VThreadPinner { throw e; if (ex instanceof Error e) throw e; - throw (X) ex; + @SuppressWarnings("unchecked") + var x = (X) ex; + throw x; } } diff --git a/test/lib/jdk/test/lib/thread/VThreadRunner.java b/test/lib/jdk/test/lib/thread/VThreadRunner.java index 1b09e5e0d12..3c1a076659a 100644 --- a/test/lib/jdk/test/lib/thread/VThreadRunner.java +++ b/test/lib/jdk/test/lib/thread/VThreadRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -94,7 +94,9 @@ public class VThreadRunner { throw e; if (ex instanceof Error e) throw e; - throw (X) ex; + @SuppressWarnings("unchecked") + var x = (X) ex; + throw x; } } diff --git a/test/lib/jdk/test/lib/util/FileUtils.java b/test/lib/jdk/test/lib/util/FileUtils.java index 191cb46f9c2..7b2ab434af2 100644 --- a/test/lib/jdk/test/lib/util/FileUtils.java +++ b/test/lib/jdk/test/lib/util/FileUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -266,7 +266,7 @@ public final class FileUtils { (new InputStreamReader(proc.getInputStream())); // Skip the first line as it is the "df" output header. if (reader.readLine() != null ) { - Set mountPoints = new HashSet(); + Set mountPoints = new HashSet<>(); String mountPoint = null; while ((mountPoint = reader.readLine()) != null) { if (!mountPoints.add(mountPoint)) { @@ -299,8 +299,8 @@ public final class FileUtils { }; }); - final AtomicReference throwableReference = - new AtomicReference(); + final AtomicReference throwableReference = + new AtomicReference<>(); thr.setUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { @@ -315,7 +315,7 @@ public final class FileUtils { throw new RuntimeException(ie); } - Throwable uncaughtException = (Throwable)throwableReference.get(); + Throwable uncaughtException = throwableReference.get(); if (uncaughtException != null) { throw new RuntimeException(uncaughtException); } @@ -365,6 +365,7 @@ public final class FileUtils { } // Return the current process handle count + @SuppressWarnings("restricted") public static long getProcessHandleCount() { if (IS_WINDOWS) { if (!nativeLibLoaded) {