mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8304502: Classfile API class hierarchy makes assumptions when class is not resolved
Reviewed-by: jpai
This commit is contained in:
parent
0deb648985
commit
0156909ab3
4 changed files with 13 additions and 13 deletions
|
@ -45,9 +45,6 @@ public final class ClassHierarchyImpl {
|
|||
|
||||
private final ClassHierarchyResolver resolver;
|
||||
|
||||
//defer initialization of logging until needed
|
||||
private static System.Logger logger;
|
||||
|
||||
/**
|
||||
* Public constructor of <code>ClassHierarchyImpl</code> accepting instances of <code>ClassHierarchyInfoResolver</code> to resolve individual class streams.
|
||||
* @param classHierarchyResolver <code>ClassHierarchyInfoResolver</code> instance
|
||||
|
@ -59,12 +56,7 @@ public final class ClassHierarchyImpl {
|
|||
private ClassHierarchyResolver.ClassHierarchyInfo resolve(ClassDesc classDesc) {
|
||||
var res = resolver.getClassInfo(classDesc);
|
||||
if (res != null) return res;
|
||||
//maybe throw an exception here to avoid construction of potentially invalid stack maps
|
||||
if (logger == null)
|
||||
logger = System.getLogger("jdk.internal.classfile");
|
||||
if (logger.isLoggable(System.Logger.Level.DEBUG))
|
||||
logger.log(System.Logger.Level.DEBUG, "Could not resolve class " + classDesc.displayName());
|
||||
return new ClassHierarchyResolver.ClassHierarchyInfo(classDesc, false, null);
|
||||
throw new IllegalArgumentException("Could not resolve class " + classDesc.displayName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,10 +165,15 @@ public final class ClassHierarchyImpl {
|
|||
}
|
||||
|
||||
public static final class StaticClassHierarchyResolver implements ClassHierarchyResolver {
|
||||
|
||||
private static final ClassHierarchyInfo CHI_Object =
|
||||
new ClassHierarchyInfo(ConstantDescs.CD_Object, false, null);
|
||||
|
||||
private final Map<ClassDesc, ClassHierarchyInfo> map;
|
||||
|
||||
public StaticClassHierarchyResolver(Collection<ClassDesc> interfaceNames, Map<ClassDesc, ClassDesc> classToSuperClass) {
|
||||
map = new HashMap<>(interfaceNames.size() + classToSuperClass.size());
|
||||
map = HashMap.newHashMap(interfaceNames.size() + classToSuperClass.size() + 1);
|
||||
map.put(ConstantDescs.CD_Object, CHI_Object);
|
||||
for (var e : classToSuperClass.entrySet())
|
||||
map.put(e.getKey(), new ClassHierarchyInfo(e.getKey(), false, e.getValue()));
|
||||
for (var i : interfaceNames)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue