ClassReferenceFixer's KotlinReferenceFixer assumes every Kotlin metadata reference resolved, and NPEs when one didn't. Several spots dereference the referenced* field without a null check:
// ClassReferenceFixer.java:773 visitAnyType
kotlinTypeMetadata.className = kotlinTypeMetadata.referencedClass.getName();
// :746 visitAnyFunction
kotlinFunctionMetadata.referencedMethod.getName(kotlinFunctionMetadata.referencedMethodClass)
// :905 visitAnyArgument
argument.referencedAnnotationMethod.getName(annotation.referencedAnnotationClass);
// :917 / :929 visitClassArgument / visitEnumArgument
value.className = value.referencedClass.getName();
If the class pool is incomplete — e.g. a class referenced only from @Metadata that isn't on the classpath — ClassReferenceInitializer leaves the matching referenced* null, and these lines throw instead of leaving the reference as-is. (visitAnyType does have a guard, but it's on className != null, not the referencedClass it actually dereferences.)
The annotation path right above already does the right thing:
// :888 visitAnyAnnotation
if (annotation.referencedAnnotationClass != null) {
annotation.className = annotation.referencedAnnotationClass.getName();
}
Could the type / function / argument paths get the same null guard? Today an incomplete classpath crashes the fixer rather than degrading gracefully.
ClassReferenceFixer'sKotlinReferenceFixerassumes every Kotlin metadata reference resolved, and NPEs when one didn't. Several spots dereference thereferenced*field without a null check:If the class pool is incomplete — e.g. a class referenced only from
@Metadatathat isn't on the classpath —ClassReferenceInitializerleaves the matchingreferenced*null, and these lines throw instead of leaving the reference as-is. (visitAnyTypedoes have a guard, but it's onclassName != null, not thereferencedClassit actually dereferences.)The annotation path right above already does the right thing:
Could the type / function / argument paths get the same null guard? Today an incomplete classpath crashes the fixer rather than degrading gracefully.