8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not thread safe
Reviewed-by: stsypanov, redestad
This commit is contained in:
parent
c6f20db945
commit
be36096a19
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -73,7 +73,7 @@ public final class Constructor<T> extends Executable {
|
|||||||
// Generics and annotations support
|
// Generics and annotations support
|
||||||
private final transient String signature;
|
private final transient String signature;
|
||||||
// generic info repository; lazily initialized
|
// generic info repository; lazily initialized
|
||||||
private transient ConstructorRepository genericInfo;
|
private transient volatile ConstructorRepository genericInfo;
|
||||||
private final byte[] annotations;
|
private final byte[] annotations;
|
||||||
private final byte[] parameterAnnotations;
|
private final byte[] parameterAnnotations;
|
||||||
|
|
||||||
@ -87,12 +87,14 @@ public final class Constructor<T> extends Executable {
|
|||||||
// Accessor for generic info repository
|
// Accessor for generic info repository
|
||||||
@Override
|
@Override
|
||||||
ConstructorRepository getGenericInfo() {
|
ConstructorRepository getGenericInfo() {
|
||||||
|
var genericInfo = this.genericInfo;
|
||||||
// lazily initialize repository if necessary
|
// lazily initialize repository if necessary
|
||||||
if (genericInfo == null) {
|
if (genericInfo == null) {
|
||||||
// create and cache generic info repository
|
// create and cache generic info repository
|
||||||
genericInfo =
|
genericInfo =
|
||||||
ConstructorRepository.make(getSignature(),
|
ConstructorRepository.make(getSignature(),
|
||||||
getFactory());
|
getFactory());
|
||||||
|
this.genericInfo = genericInfo;
|
||||||
}
|
}
|
||||||
return genericInfo; //return cached repository
|
return genericInfo; //return cached repository
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -77,7 +77,7 @@ class Field extends AccessibleObject implements Member {
|
|||||||
// Generics and annotations support
|
// Generics and annotations support
|
||||||
private final transient String signature;
|
private final transient String signature;
|
||||||
// generic info repository; lazily initialized
|
// generic info repository; lazily initialized
|
||||||
private transient FieldRepository genericInfo;
|
private transient volatile FieldRepository genericInfo;
|
||||||
private final byte[] annotations;
|
private final byte[] annotations;
|
||||||
// Cached field accessor created without override
|
// Cached field accessor created without override
|
||||||
@Stable
|
@Stable
|
||||||
@ -106,11 +106,13 @@ class Field extends AccessibleObject implements Member {
|
|||||||
|
|
||||||
// Accessor for generic info repository
|
// Accessor for generic info repository
|
||||||
private FieldRepository getGenericInfo() {
|
private FieldRepository getGenericInfo() {
|
||||||
|
var genericInfo = this.genericInfo;
|
||||||
// lazily initialize repository if necessary
|
// lazily initialize repository if necessary
|
||||||
if (genericInfo == null) {
|
if (genericInfo == null) {
|
||||||
// create and cache generic info repository
|
// create and cache generic info repository
|
||||||
genericInfo = FieldRepository.make(getGenericSignature(),
|
genericInfo = FieldRepository.make(getGenericSignature(),
|
||||||
getFactory());
|
getFactory());
|
||||||
|
this.genericInfo = genericInfo;
|
||||||
}
|
}
|
||||||
return genericInfo; //return cached repository
|
return genericInfo; //return cached repository
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -82,7 +82,7 @@ public final class Method extends Executable {
|
|||||||
// Generics and annotations support
|
// Generics and annotations support
|
||||||
private final transient String signature;
|
private final transient String signature;
|
||||||
// generic info repository; lazily initialized
|
// generic info repository; lazily initialized
|
||||||
private transient MethodRepository genericInfo;
|
private transient volatile MethodRepository genericInfo;
|
||||||
private final byte[] annotations;
|
private final byte[] annotations;
|
||||||
private final byte[] parameterAnnotations;
|
private final byte[] parameterAnnotations;
|
||||||
private final byte[] annotationDefault;
|
private final byte[] annotationDefault;
|
||||||
@ -108,11 +108,13 @@ public final class Method extends Executable {
|
|||||||
// Accessor for generic info repository
|
// Accessor for generic info repository
|
||||||
@Override
|
@Override
|
||||||
MethodRepository getGenericInfo() {
|
MethodRepository getGenericInfo() {
|
||||||
|
var genericInfo = this.genericInfo;
|
||||||
// lazily initialize repository if necessary
|
// lazily initialize repository if necessary
|
||||||
if (genericInfo == null) {
|
if (genericInfo == null) {
|
||||||
// create and cache generic info repository
|
// create and cache generic info repository
|
||||||
genericInfo = MethodRepository.make(getGenericSignature(),
|
genericInfo = MethodRepository.make(getGenericSignature(),
|
||||||
getFactory());
|
getFactory());
|
||||||
|
this.genericInfo = genericInfo;
|
||||||
}
|
}
|
||||||
return genericInfo; //return cached repository
|
return genericInfo; //return cached repository
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -54,7 +54,7 @@ public final class RecordComponent implements AnnotatedElement {
|
|||||||
private Method accessor;
|
private Method accessor;
|
||||||
private String signature;
|
private String signature;
|
||||||
// generic info repository; lazily initialized
|
// generic info repository; lazily initialized
|
||||||
private transient FieldRepository genericInfo;
|
private transient volatile FieldRepository genericInfo;
|
||||||
private byte[] annotations;
|
private byte[] annotations;
|
||||||
private byte[] typeAnnotations;
|
private byte[] typeAnnotations;
|
||||||
private RecordComponent root;
|
private RecordComponent root;
|
||||||
@ -127,10 +127,12 @@ public final class RecordComponent implements AnnotatedElement {
|
|||||||
|
|
||||||
// Accessor for generic info repository
|
// Accessor for generic info repository
|
||||||
private FieldRepository getGenericInfo() {
|
private FieldRepository getGenericInfo() {
|
||||||
|
var genericInfo = this.genericInfo;
|
||||||
// lazily initialize repository if necessary
|
// lazily initialize repository if necessary
|
||||||
if (genericInfo == null) {
|
if (genericInfo == null) {
|
||||||
// create and cache generic info repository
|
// create and cache generic info repository
|
||||||
genericInfo = FieldRepository.make(getGenericSignature(), getFactory());
|
genericInfo = FieldRepository.make(getGenericSignature(), getFactory());
|
||||||
|
this.genericInfo = genericInfo;
|
||||||
}
|
}
|
||||||
return genericInfo; //return cached repository
|
return genericInfo; //return cached repository
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user