The three AtomicXxxFieldUpdater classes (AtomicIntegerFieldUpdater, AtomicLongFieldUpdater, and AtomicReferenceFieldUpdater) contain duplicate field validation and access checking logic in their constructors and helper methods.
This change extracts the common validation and utility methods into a new package-private class FieldUpdaterUtil to eliminate code duplication and improve maintainability. Changes: - Added new FieldUpdaterUtil class with static utility methods: * validateField() - validates field type, volatile, and static checks * computeAccessClass() - determines correct class for access checks * isSamePackage() - checks if two classes are in same package * isAncestor() - checks classloader delegation chain - Updated AtomicIntegerFieldUpdater to use FieldUpdaterUtil * Simplified constructor to use validateField() and computeAccessClass() * Removed duplicate isAncestor() and isSamePackage() methods - Updated AtomicLongFieldUpdater to use FieldUpdaterUtil * Simplified constructor to use validateField() and computeAccessClass() * Removed duplicate isAncestor() and isSamePackage() methods - Updated AtomicReferenceFieldUpdater to use FieldUpdaterUtil * Simplified constructor to use validateField() and computeAccessClass() * Removed duplicate isAncestor() and isSamePackage() methods Existing tests in test/jdk/java/util/concurrent/tck and test/jdk/java/util/concurrent/atomic verify that the refactoring preserves the original behavior. ------------- Commit messages: - 8364544: Extract the checks of AtomicXxxFieldUpdater into a common place Changes: https://git.openjdk.org/jdk/pull/28464/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28464&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8364544 Stats: 263 lines in 4 files changed: 134 ins; 122 del; 7 mod Patch: https://git.openjdk.org/jdk/pull/28464.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/28464/head:pull/28464 PR: https://git.openjdk.org/jdk/pull/28464
