Describe the bug
Mappie is not able to generate mappers from Java classes if run on with JVM language version that doesn't include Records (introduced in Java 14).
> Task :commons:compileKotlin
e: java.lang.NullPointerException
at tech.mappie.ir.resolving.classes.sources.ImplicitClassMappingSourcesCollector.isJavaGetter(ImplicitClassMappingSourcesCollector.kt:43)
at tech.mappie.ir.resolving.classes.sources.ImplicitClassMappingSourcesCollector.visitFunction(ImplicitClassMappingSourcesCollector.kt:27)
at tech.mappie.ir.resolving.classes.sources.ImplicitClassMappingSourcesCollector.visitFunction(ImplicitClassMappingSourcesCollector.kt:17)
at org.jetbrains.kotlin.ir.visitors.IrVisitor.visitSimpleFunction(IrVisitor.kt:65)
at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:39)
at tech.mappie.ir.util.BaseVisitor.accept(BaseVisitor.kt:15)
at tech.mappie.ir.resolving.classes.sources.ImplicitClassMappingSourcesCollector.visitClass(ImplicitClassMappingSourcesCollector.kt:22)
at tech.mappie.ir.resolving.classes.sources.ImplicitClassMappingSourcesCollector.visitClass(ImplicitClassMappingSourcesCollector.kt:17)
Line that throw exception:
if (parentAsClass.isSubclassOf(context.pluginContext.referenceClass(CLASS_ID_RECORD)!!)) {
The problem is that if SDK of Java doesn't contain class java.lang.Record, the function referenceClass is null and non-null assertion operator throws the exception. Solution is refactoring of the code with removal of assumption of non-null.
if (context.pluginContext.referenceClass(CLASS_ID_RECORD)?.let { parentAsClass.isSubclassOf(it) } ?: false) {
Kotlin version
2.2.0
Mappie version
1.4.0
Mappie and Kotlin compatibility
yes
Invocation method
Gradle
Additional context
Tested on Java 11
Describe the bug
Mappie is not able to generate mappers from Java classes if run on with JVM language version that doesn't include Records (introduced in Java 14).
Line that throw exception:
The problem is that if SDK of Java doesn't contain class
java.lang.Record, the functionreferenceClassis null and non-null assertion operator throws the exception. Solution is refactoring of the code with removal of assumption of non-null.Kotlin version
2.2.0
Mappie version
1.4.0
Mappie and Kotlin compatibility
yes
Invocation method
Gradle
Additional context
Tested on Java 11