src/java.base/share/classes/sun/reflect/generics/repository/ClassRepository.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -41,11 +41,11 @@
public class ClassRepository extends GenericDeclRepository<ClassSignature> {
public static final ClassRepository NONE = ClassRepository.make("Ljava/lang/Object;", null);
private Type superclass; // caches the generic superclass info
- private Type[] superInterfaces; // caches the generic superinterface info
+ private volatile Type[] superInterfaces; // caches the generic superinterface info
// private, to enforce use of static factory
private ClassRepository(String rawSig, GenericsFactory f) {
super(rawSig, f);
}
@@ -89,22 +89,23 @@
}
return superclass; // return cached result
}
public Type[] getSuperInterfaces(){
- if (superInterfaces == null) { // lazily initialize super interfaces
+ Type[] sis = superInterfaces;
+ if (sis == null) { // lazily initialize super interfaces
// first, extract super interface subtree(s) from AST
TypeTree[] ts = getTree().getSuperInterfaces();
// create array to store reified subtree(s)
- Type[] sis = new Type[ts.length];
+ sis = new Type[ts.length];
// reify all subtrees
for (int i = 0; i < ts.length; i++) {
Reifier r = getReifier(); // obtain visitor
ts[i].accept(r);// reify subtree
// extract result from visitor and store it
sis[i] = r.getResult();
}
superInterfaces = sis; // cache overall result
}
- return superInterfaces.clone(); // return cached result
+ return sis.clone(); // return cached result
}
}