I got Exception: Could not resolve class

Øystein Myhre Andersen o.myhre at gmail.com
Fri Oct 18 08:02:27 UTC 2024


Here is the link:
https://github.com/portablesimula/SimulaCompiler2/blob/main/Simula/src/simula/compiler/utilities/ClassHierarchy.java

I use:
openjdk version "24-ea" 2025-03-18
OpenJDK Runtime Environment (build 24-ea+16-1800)
OpenJDK 64-Bit Server VM (build 24-ea+16-1800, mixed mode, sharing)

- Øystein

On Fri, Oct 18, 2024 at 9:51 AM Chen Liang <liangchenblue at gmail.com> wrote:

> Hi Øystein, can you share a link to your ClassHierarchy code? ClassFile
> API has a layer of caching for the ClassHierarchyResolver it uses, which
> can lead to it not updating to the latest information in your
> ClassHierarchy.
>
> Chen
>
> On Fri, Oct 18, 2024 at 2:40 AM Øystein Myhre Andersen <o.myhre at gmail.com>
> wrote:
>
>> Below is a snippet of my code:
>>
>>
>> public byte[] buildClassFile() {
>>
>> ClassDesc CD_ThisClass = currentClassDesc();
>>
>> ClassDesc CD_SuperClass = superClassDesc();
>>
>> ClassHierarchy.addClassToSuperClass(CD_ThisClass, CD_SuperClass);
>>
>> try {
>>
>> byte[] bytes =
>> ClassFile.of(ClassFile.ClassHierarchyResolverOption.of(ClassHierarchy.getResolver())).build(CD_ThisClass,
>>
>>
>> ...
>>
>> return(bytes);
>>
>> } catch(Throwable e) {
>>
>> ClassHierarchyResolver resolver = ClassHierarchy.getResolver();
>>
>> ClassDesc desc = ClassDesc.of("simulaFEC.CLASS_CHECKER1_semchecker1_exp
>> ");
>>
>> System.out.println("classInfo("+desc+") = " + resolver.getClassInfo(desc
>> ));
>>
>>
>> e.printStackTrace();
>>
>> return null;
>>
>> }
>>
>> }
>>
>> When I run this code I get:
>>
>>
>> classInfo(ClassDesc[CLASS_CHECKER1_semchecker1_exp]) =
>> ClassHierarchyInfoImpl[superClass=ClassDesc[RTS_CLASS], isInterface=false]
>>
>> java.lang.IllegalArgumentException: Could not resolve class
>> CLASS_CHECKER1_semchecker1_exp
>>
>> at
>> java.base/jdk.internal.classfile.impl.ClassHierarchyImpl.resolve(ClassHierarchyImpl.java:76)
>>
>> at
>> java.base/jdk.internal.classfile.impl.ClassHierarchyImpl.isInterface(ClassHierarchyImpl.java:86)
>>
>> at
>> java.base/jdk.internal.classfile.impl.StackMapGenerator$Type.mergeReferenceFrom(StackMapGenerator.java:1334)
>>
>> .....
>>
>> I use my own 'resolver' which answers that 'CLASS_CHECKER1_semchecker1_
>> exp' is a subclass of 'RTS_CLASS'.
>>
>> I don't understand this.
>>
>>
>> - Øystein Myhre Andersen
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20241018/d1b0ff7e/attachment-0001.htm>


More information about the classfile-api-dev mailing list