Skip to content

Commit

Permalink
Missed field
Browse files Browse the repository at this point in the history
  • Loading branch information
liach committed Oct 30, 2024
1 parent 8147d66 commit 5ff5797
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions src/java.base/share/classes/java/lang/reflect/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,18 @@ class Field extends AccessibleObject implements Member {
private final boolean trustedFinal;
// Generics and annotations support
private final transient String signature;
// generic info repository; lazily initialized
private transient volatile FieldRepository genericInfo;
private final byte[] annotations;
// Cached field accessor created without override
@Stable
private FieldAccessor fieldAccessor;
// Cached field accessor created with override
@Stable
private FieldAccessor overrideFieldAccessor;
// For sharing of FieldAccessors. This branching structure is
// currently only two levels deep (i.e., one root Field and
// potentially many Field objects pointing to it.)
//
// If this branching structure would ever contain cycles, deadlocks can
// occur in annotation code.
private Field root;

/**
* Fields are mutable due to {@link AccessibleObject#setAccessible(boolean)}.
* Thus, we return a new copy of a root each time a field is returned.
* Some lazily initialized immutable states can be stored on root and shared to the copies.
*/
private Field root;
private transient volatile FieldRepository genericInfo;
private @Stable FieldAccessor fieldAccessor; // access control enabled
private @Stable FieldAccessor overrideFieldAccessor; // access control suppressed
// End shared states

// Generics infrastructure

Expand All @@ -107,22 +103,18 @@ private GenericsFactory getFactory() {
// Accessor for generic info repository
private FieldRepository getGenericInfo() {
var genericInfo = this.genericInfo;
// lazily initialize repository if necessary
if (genericInfo == null) {
var root = this.root;
if (root != null) {
genericInfo = root.getGenericInfo();
} else {
// 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;
}


/**
* Package-private constructor
*/
Expand Down

0 comments on commit 5ff5797

Please sign in to comment.