Netflix / Netflix/dgs-codegen

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

Open
#431 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
217
Forks
116
PR merge metrics
No merged PRs in 30d

Description

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"
		)
	}
...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the AccountInput serialization with Float mapped to java.math.BigDecimal, then start at InputValueSerializer.kt line 78 and follow the call from GraphQLQueryRequest.kt line 47. Compare this path with the generated client setup in build.gradle.kts; done means the request serializes without KotlinReflectionInternalError while retaining the configured type mapping.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, java, kotlin, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.