kotlin๊ณผ kotlinFixture | troubleshooting | KotlinReflectionInternalError ๐Ÿค”

๋ณด๋žŒยท2024๋…„ 9์›” 28์ผ
0

troubleshooting

๋ชฉ๋ก ๋ณด๊ธฐ
5/5

kotlinFixture๋ฅผ ์ ์šฉํ•ด๋ณด๋˜ ์ค‘ ์—๋Ÿฌ๋ฅผ ๋งˆ์ฃผํ–ˆ๋‹ค.

KotlinReflectionInternalError

val domain: Domain =
          fixture<Domain> {
              property(Domain::doubleField) { 100.0 }
              property(Domain::mutableMapField) {
                  mutableMapOf(
                      "key" to "value",
                  )
              }
          }

์œ„์™€ ๊ฐ™์ด Domain ๋ฅผ fixture๋กœ ์ƒ์„ฑํ–ˆ๋Š”๋ฐ ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Could not compute caller for function: public constructor Array(size: kotlin.Int, init: (kotlin.Int) -> T) defined in kotlin.Array[DeserializedClassConstructorDescriptor@143d9427] (member = null)

๊ฒ€์ƒ‰ํ•ด๋ณด๋‹ˆ kotlineFixture์—์„œ ํŠน์ • ํƒ€์ž…์„ ๋งŒ๋“ค์–ด์ฃผ์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•œ ์˜ค๋ฅ˜์˜€๋‹ค.

fixture ์„ ์–ธ์‹œ์— ์•„๋ž˜์™€ ๊ฐ™์ด ํŠน์ • ํƒ€์ž…์— ๋Œ€ํ•ด์„œ ์ง€์ •ํ•  ์ˆ˜๊ฐ€ ์žˆ๋‹ค.
๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.
์ง€๋ฆฌ์ •๋ณด๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ org.locationtech.jts.geom๋ฅผ import ํ•˜์—ฌ ์‚ฌ์šฉ์ค‘์ธ๋ฐ ํ•ด๋‹น๊ฐ’์€ ์ง€์›์„ ํ•ด์ฃผ์ง€ ์•Š์•„ ๋ฐœ์ƒ๋œ ๋ฌธ์ œ์˜€๋‹ค.

  • geotype์„ ์ง€์›ํ•˜๋Š” import org.locationtech.jts.geom.Point geom์€ kotlinFixture์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์ง€ ๋ชปํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.

ํ•ด๊ฒฐ๋ฐฉ์•ˆ

ํ•ด๊ฒฐ๋ฐฉ์•ˆ์€ kotlinFixture์—์„œ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ํƒ€์ž…(ex:Point ํƒ€์ž…)์ธ ๊ฒฝ์šฐ ํ•ด๋‹น ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™”๋ฅผ ์ง€์ •ํ•˜๋ฉด ๋œ๋‹ค.

val fixture =
            kotlinFixture {
                factory<Point> { getPoint(0.0, 0.0) }
            }

ํ•ด๊ฒฐ ์ฝ”๋“œ ์ „๋ฌธ

val fixture =
            kotlinFixture {
                factory<Point> { getPoint(0.0, 0.0) }
            }
  
 
///์ค‘๋žต

val domain: Domain =
          fixture<Domain> {
              property(Domain::doubleField) { 100.0 }
              property(Domain::mutableMapField) {
                  mutableMapOf(
                      "key" to "value",
                  )
              }
          }

๋งŒ์ผ Pointํƒ€์ž…์— ๋Œ€ํ•ด์„œ ๋‹ค๋ฅธ ๊ฐ’์œผ๋กœ ์ง€์ •์„ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด propery๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์›ํ•˜๋Š” ๊ฐ’์œผ๋กœ ์ง€์ •ํ•˜๋ฉด factory๋กœ ์ง€์ •ํ•œ ๊ฐ’์ด ๋ฎ์–ด ์“ฐ์—ฌ์ง„๋‹ค.

profile
๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ์ž

0๊ฐœ์˜ ๋Œ“๊ธ€