8376477: Avoid loading empty Lock classes in Shutdown and ReferenceQueue

Reviewed-by: rriggs, shade
This commit is contained in:
Eirik Bjørsnøs 2026-02-26 16:33:51 +00:00
parent fcc2a2922f
commit 8b805630b4
2 changed files with 5 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2026, 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
@ -55,11 +55,10 @@ class Shutdown {
private static int currentRunningHook = -1;
/* The preceding static fields are protected by this lock */
private static class Lock { };
private static Object lock = new Lock();
private static final Object lock = new Object();
/* Lock object for the native halt method */
private static Object haltLock = new Lock();
private static final Object haltLock = new Object();
/**
* Add a new system shutdown hook. Checks the shutdown state and

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, 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,8 +60,7 @@ public class ReferenceQueue<@jdk.internal.RequiresIdentity T> {
private volatile Reference<? extends T> head;
private long queueLength = 0;
private static class Lock { };
private final Lock lock = new Lock();
private final Object lock = new Object();
/**
* Constructs a new reference-object queue.