Skip to content

KotlinReflectionInternalError: Unresolved class: class java.math.BigDecimal$1 #431

@jayZipCo

Description

@jayZipCo

I got this error when I add the mapping "Float" to "java.math.BigDecimal" and has an input type with variable of this Float(will be converted to BigDecimal later).

Input type

input AccountInput {
	customerId: ID
	amount: Float
}

Error log:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/Users/tester/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.3.18/7ff3000f3342989cb011b6095a0e86f2e5176cef/spring-core-5.3.18.jar) to field java.math.BigDecimal.intVal
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2022-07-19 14:01:29.099 ERROR 39933 --- [nio-8089-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Unresolved class: class java.math.BigDecimal$1] with root cause

kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Unresolved class: class java.math.BigDecimal$1
	at kotlin.reflect.jvm.internal.KClassImpl.reportUnresolvedClass(KClassImpl.kt:329)
	at kotlin.reflect.jvm.internal.KClassImpl.access$reportUnresolvedClass(KClassImpl.kt:44)
	at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.invoke(KClassImpl.kt:56)
	at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.invoke(KClassImpl.kt:47)
	at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(ReflectProperties.java:92)
	at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
	at kotlin.reflect.jvm.internal.KClassImpl$Data.getDescriptor(KClassImpl.kt)
	at kotlin.reflect.jvm.internal.KClassImpl.getDescriptor(KClassImpl.kt:182)
	at kotlin.reflect.jvm.internal.KClassImpl.isCompanion(KClassImpl.kt:283)
	at com.netflix.graphql.dgs.client.codegen.InputValueSerializer.serialize(InputValueSerializer.kt:78)
	at com.netflix.graphql.dgs.client.codegen.InputValueSerializer.serialize(InputValueSerializer.kt:79)
	at com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest.serialize(GraphQLQueryRequest.kt:47)

The error happens when it calls nestedValue::class.isCompanion as seen below
image

And the error will be gone if I remove the amount field from input type.

Would appreciate any help on this.

My build.gradle.kts

plugins {
	jacoco
	id("org.springframework.boot") version "2.5.12"
	id("org.owasp.dependencycheck") version "6.0.2"
	id("io.spring.dependency-management") version "1.0.11.RELEASE"
	kotlin("jvm") version "1.5.10"
	kotlin("plugin.spring") version "1.5.10"
	id("com.netflix.dgs.codegen") version "4.6.6"
}
dependencies {
	implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
	implementation("org.jetbrains.kotlin:kotlin-reflect")
	implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

	implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:3.10.2"))
	implementation("com.netflix.graphql.dgs:graphql-dgs-client")
}

tasks {
	generateJava {
		schemaPaths = mutableListOf("${projectDir}/src/main/resources/schema")
		generateClient = true
		language = "java"
		typeMapping = mutableMapOf(
			"JSON" to "org.json.simple.JSONObject",
			"Float" to "java.math.BigDecimal",
			"DateTimeOffset" to "java.time.LocalDateTime",
			"Decimal" to "java.math.BigDecimal"
		)
	}
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions