question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

이하 다 틀린 내용입니다

https://github.com/JavaUnit/AutoParams/issues/239#issuecomment-850991306 를 참고해주세요.

문제 상황

Kotlin class 는 Java bytecode 로 변환될 때 arguments 를 받지 않는 constructor 를 기본으로 만드는 것 같습니다.

현재 AutoParams 의 ComplexObjectGenerator 에서 사용할 constructor 를 찾는 우선순위는

  • @ConstructorProperties 가 붙은 constructor
  • arguments 수가 적은 constructor

이기 때문에 @ConstructorProperties 가 붙은 constructor 가 없다면 arguments 를 받지 않는 constructor 가 항상 먼저 선택되게 됩니다.

해결 방법

Kotlin 에서 만드는 constructor 중 default 로 사용되는 constructor 는 kotlin.jvm.internal.DefaultConstructorMarker 라는 인자를 마지막에 받도록 되어있는 것 같습니다.

참조: https://stackoverflow.com/a/53912965/2259817

이를 이용해서 autoparams-kotlin 모듈을 만들 수 있지 않을까 싶은 생각이 듭니다.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
gyuwoncommented, Jul 18, 2021

@nallwhy 오랜시간 논의가 이어지지 않아 이 이슈는 일단 닫겠습니다. 필요하시면 다시 열어주세요. 😃

1reaction
nallwhycommented, May 30, 2021

@gyuwon 추정을 해보고 확인을 하면 재밌을 것 같아서 추정을 먼저 해보고 확인해보겠습니다.

https://kotlinlang.org/docs/data-classes.html 에 따르면

The compiler automatically derives the following members from all properties declared in the primary constructor:

equals()/ hashCode() pair

toString() of the form “User(name=John, age=42)”

componentN() functions corresponding to the properties in their order of declaration.

copy() function (see below).

정도의 차이가 있는 것 같기 때문에, constructor 부분이 다를 이유는 없지 않을까? 라고 생각해봅니다.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin Programming Language
Help is never far away — consult extensive community resources or ask the Kotlin team directly.
Read more >
Kotlin and Android | Android Developers
Android Studio provides first-class support for Kotlin. It even has built-in tools to help you convert Java-based code to Kotlin. The Show Kotlin...
Read more >
48. Kotlin support - Spring
Spring Boot provides Kotlin support by leveraging the support in other Spring projects such as Spring Framework, Spring Data, and Reactor.
Read more >
Kotlin (programming language) - Wikipedia
IntelliJ IDEA has plug-in support for Kotlin. · JetBrains also provides a plugin for Eclipse. · Integration with common Java build tools is...
Read more >
Using Kotlin - Quarkus
Kotlin is a very popular programming language that targets the JVM (amongst ... Quarkus provides first class support for using Kotlin as will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found