Skip to content

Commit

Permalink
8304164: jdk/classfile/CorpusTest.java still fails after JDK-8303910
Browse files Browse the repository at this point in the history
Reviewed-by: jpai
  • Loading branch information
asotona committed Mar 17, 2023
1 parent 620564a commit b2639e1
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -110,6 +110,10 @@ public boolean isAssignableFrom(ClassDesc thisClass, ClassDesc fromClass) {

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 Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo> resolvedCache;

Expand All @@ -124,9 +128,11 @@ public CachedClassHierarchyResolver(Function<ClassDesc, InputStream> classStream
// empty ClInfo is stored in case of an exception to avoid repeated scanning failures
@Override
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc classDesc) {
var res = resolvedCache.get(classDesc);
//additional test for null value is important to avoid repeated resolution attempts
if (res == null && !resolvedCache.containsKey(classDesc)) {
//using NOPE to distinguish between null value and non-existent record in the cache
//this code is on JDK bootstrap critical path, so cannot use lambdas here
var res = resolvedCache.getOrDefault(classDesc, NOPE);
if (res == NOPE) {
res = null;
var ci = streamProvider.apply(classDesc);
if (ci != null) {
try (var in = new DataInputStream(new BufferedInputStream(ci))) {
Expand Down

1 comment on commit b2639e1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.