I was doing a bit of code cleanup and removing "duplicate" implement calls and noticed that ZC stopped recognizing that one of my native classes implements a different native interface due to not doing any flattening of implemented interfaces. A basic setup class structure wise that fails to find that A implements C is as follows:
publicclassAimplementsB {
}
publicinterfaceBextendsC {
}
publicinterfaceC {
}I am fairly certain this is due to how implemented interfaces are collected here, as Class#getAnnotatedInterfaces only gets directly declared interfaces. I did some basic testing (outside of ZC/CrT so I haven't yet validated this actually fixes the issue I ran into but I am fairly certain it does) and I believe adjusting fillImplementedInterfaces to behave like:
privatevoidfillImplementedInterfaces(Class<?> cls, HighLevelDefinitiondefinition, JavaClassjavaClass) {
Set<AnnotatedType> interfaces = newLinkedHashSet<>();
addAllAnnotatedInterfaces(interfaces, cls);
for (AnnotatedTypeiface : interfaces) {
if (shouldLoadType(iface.getType())) {
TypeIDtype = typeConverter.loadType(typeConversionContext.context, iface);
ImplementationMembermember = newImplementationMember(CodePosition.NATIVE, definition, Modifiers.PUBLIC, type);
definition.members.add(member);
typeConversionContext.compiled.setImplementationInfo(member, newJavaImplementation(true, javaClass));
}
}
}
privatevoidaddAllAnnotatedInterfaces(Set<AnnotatedType> interfaces, Class<?> cls) {
for (AnnotatedTypeiface : cls.getAnnotatedInterfaces()) {
interfaces.add(iface);
Typetype = iface.getType();
while (typeinstanceofParameterizedType) {
type = ((ParameterizedType) type).getRawType();
}
if (typeinstanceofClass) {
addAllAnnotatedInterfaces(interfaces, (Class<?>) type);
}
}
}Will properly get all parent interfaces, except I am unsure how shouldLoadType behaves and whether this will cause issues in cases where B is registered to ZC so it knows about A, B, and C and not just A and C, as I feel like this may cause it to have C effectively be registered as both B and C, though that might happen already if the implementations are manually declared?
I was doing a bit of code cleanup and removing "duplicate" implement calls and noticed that ZC stopped recognizing that one of my native classes implements a different native interface due to not doing any flattening of implemented interfaces. A basic setup class structure wise that fails to find that
A implements Cis as follows:I am fairly certain this is due to how implemented interfaces are collected here, as
Class#getAnnotatedInterfacesonly gets directly declared interfaces. I did some basic testing (outside of ZC/CrT so I haven't yet validated this actually fixes the issue I ran into but I am fairly certain it does) and I believe adjustingfillImplementedInterfacesto behave like:Will properly get all parent interfaces, except I am unsure how
shouldLoadTypebehaves and whether this will cause issues in cases whereBis registered to ZC so it knows aboutA,B, andCand not justAandC, as I feel like this may cause it to haveCeffectively be registered as bothBandC, though that might happen already if the implementations are manually declared?