Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
/ jdk21 Public archive

Commit

Permalink
8254566: Clarify the spec of ClassLoader::getClassLoadingLock for non…
Browse files Browse the repository at this point in the history
…-parallel capable loader

Reviewed-by: iris
Backport-of: b9198f993173b0fbdc7ff1400e2205d3969370da
  • Loading branch information
Mandy Chung committed Jul 3, 2023
1 parent 6de4e8f commit 205dffe
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/java.base/share/classes/java/lang/ClassLoader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, Azul Systems, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -647,19 +647,28 @@ final Class<?> loadClass(Module module, String name) {

/**
* Returns the lock object for class loading operations.
* For backward compatibility, the default implementation of this method
* behaves as follows. If this ClassLoader object is registered as
* parallel capable, the method returns a dedicated object associated
* with the specified class name. Otherwise, the method returns this
* ClassLoader object.
*
* @implSpec
* If this {@code ClassLoader} object is registered as parallel capable,
* this method returns a dedicated object associated with the specified
* class name. Otherwise, this method returns this {@code ClassLoader} object.
*
* @apiNote
* This method allows parallel capable class loaders to implement
* finer-grained locking schemes such that multiple threads may load classes
* concurrently without deadlocks. For non-parallel-capable class loaders,
* the {@code ClassLoader} object is synchronized on during the class loading
* operations. Class loaders with non-hierarchical delegation should be
* {@linkplain #registerAsParallelCapable() registered as parallel capable}
* to prevent deadlocks.
*
* @param className
* The name of the to-be-loaded class
*
* @return the lock for class loading operations
*
* @throws NullPointerException
* If registered as parallel capable and {@code className} is null
* If registered as parallel capable and {@code className} is {@code null}
*
* @see #loadClass(String, boolean)
*
Expand Down

1 comment on commit 205dffe

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.