8304164: jdk/classfile/CorpusTest.java still fails after JDK-8303910
Reviewed-by: jpai
This commit is contained in:
parent
620564ac61
commit
b2639e1d62
@ -110,6 +110,10 @@ public final class ClassHierarchyImpl {
|
|||||||
|
|
||||||
public static final class CachedClassHierarchyResolver implements ClassHierarchyResolver {
|
public static final class CachedClassHierarchyResolver implements ClassHierarchyResolver {
|
||||||
|
|
||||||
|
//this instance should never appear in the cache nor leak out
|
||||||
|
private static final ClassHierarchyResolver.ClassHierarchyInfo NOPE =
|
||||||
|
new ClassHierarchyResolver.ClassHierarchyInfo(null, false, null);
|
||||||
|
|
||||||
private final Function<ClassDesc, InputStream> streamProvider;
|
private final Function<ClassDesc, InputStream> streamProvider;
|
||||||
private final Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo> resolvedCache;
|
private final Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo> resolvedCache;
|
||||||
|
|
||||||
@ -124,9 +128,11 @@ public final class ClassHierarchyImpl {
|
|||||||
// empty ClInfo is stored in case of an exception to avoid repeated scanning failures
|
// empty ClInfo is stored in case of an exception to avoid repeated scanning failures
|
||||||
@Override
|
@Override
|
||||||
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc classDesc) {
|
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc classDesc) {
|
||||||
var res = resolvedCache.get(classDesc);
|
//using NOPE to distinguish between null value and non-existent record in the cache
|
||||||
//additional test for null value is important to avoid repeated resolution attempts
|
//this code is on JDK bootstrap critical path, so cannot use lambdas here
|
||||||
if (res == null && !resolvedCache.containsKey(classDesc)) {
|
var res = resolvedCache.getOrDefault(classDesc, NOPE);
|
||||||
|
if (res == NOPE) {
|
||||||
|
res = null;
|
||||||
var ci = streamProvider.apply(classDesc);
|
var ci = streamProvider.apply(classDesc);
|
||||||
if (ci != null) {
|
if (ci != null) {
|
||||||
try (var in = new DataInputStream(new BufferedInputStream(ci))) {
|
try (var in = new DataInputStream(new BufferedInputStream(ci))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user