Skip to content

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: dholmes, darcy
  • Loading branch information
Mandy Chung committed Jul 3, 2023
1 parent f393975 commit b9198f9
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

3 comments on commit b9198f9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@mlchung
Copy link
Member

@mlchung mlchung commented on b9198f9 Jul 3, 2023

Choose a reason for hiding this comment

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

/backport jdk21

@openjdk
Copy link

@openjdk openjdk bot commented on b9198f9 Jul 3, 2023

Choose a reason for hiding this comment

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

@mlchung the backport was successfully created on the branch mlchung-backport-b9198f99 in my personal fork of openjdk/jdk21. To create a pull request with this backport targeting openjdk/jdk21:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit b9198f99 from the openjdk/jdk repository.

The commit being backported was authored by Mandy Chung on 3 Jul 2023 and was reviewed by David Holmes and Joe Darcy.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21:

$ git fetch https://github.com/openjdk-bots/jdk21.git mlchung-backport-b9198f99:mlchung-backport-b9198f99
$ git checkout mlchung-backport-b9198f99
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21.git mlchung-backport-b9198f99

Please sign in to comment.