< prev index next > src/java.base/share/classes/java/lang/reflect/Method.java
Print this page
import sun.reflect.annotation.AnnotationType;
import sun.reflect.annotation.AnnotationParser;
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationFormatError;
import java.nio.ByteBuffer;
+ import java.util.Optional;
import java.util.StringJoiner;
+ import java.util.function.Function;
/**
* A {@code Method} provides information about, and access to, a single method
* on a class or interface. The reflected method may be a class method
* or an instance method (including an abstract method).
// If this branching structure would ever contain cycles, deadlocks can
// occur in annotation code.
private Method root;
// Hash code of this object
private int hash;
+ private volatile Optional<?> codeModel;
// Generics infrastructure
private String getGenericSignature() {return signature;}
// Accessor for factory
@Override
public int getModifiers() {
return modifiers;
}
+ /* package */
+ Optional<?> setCodeModelIfNeeded(Function<Method, Optional<?>> modelFactory) {
+ Optional<?> localRef = codeModel;
+ if (localRef == null) {
+ synchronized (this) {
+ localRef = codeModel;
+ if (localRef == null) {
+ Optional<?> op = modelFactory.apply(this);
+ codeModel = localRef = op;
+ }
+ }
+ }
+ return localRef;
+ }
+
/**
* {@inheritDoc}
* @throws GenericSignatureFormatError {@inheritDoc}
* @since 1.5
* @jls 8.4.4 Generic Methods
< prev index next >