Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support instantiating Kotlin classes with optional parameters #1482

Closed
wants to merge 1 commit into from

Conversation

sdeleuze
Copy link
Contributor

This commit updates BeanUtils class in order to add Kotlin optional
parameters with default values support to the immutable data classes
support introduced by SPR-15199.

@jhoeller Could you please review and hopefully merge it with your changes if any?

Issue: SPR-15673

@sdeleuze sdeleuze requested a review from jhoeller July 19, 2017 15:25
}
catch (NoSuchMethodException ex) {
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
Constructor<T> ctor = findPrimaryConstructor(clazz);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we'll have to differentiate here: For instantiateClass(Class), we can only deal with the no-arg default constructor (public or non-public) in the regular Java case... not with a non-default unique public constructor that findPrimaryConstructor might return to us.

So maybe we'll do some straight KotlinDelegate.findPrimaryConstructor vs clazz.getDeclaredConstructor() right here in instantiateClass(Class), and only use the public findPrimaryConstructor variant for data binding purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I am going to change that accordingly to your proposal.

@sdeleuze sdeleuze force-pushed the SPR-15673 branch 2 times, most recently from 86431a5 to 2e2c2ec Compare July 20, 2017 08:28
This commit updates BeanUtils class in order to add Kotlin optional
parameters with default values support to the immutable data classes
support introduced by SPR-15199.

Issue: SPR-15673
@sdeleuze
Copy link
Contributor Author

Merged via fa4d139.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants