Skip to content

Ensure kotlin compiler includes method param names #12641

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

Closed
wants to merge 4 commits into from
Closed

Ensure kotlin compiler includes method param names #12641

wants to merge 4 commits into from

Conversation

ruifigueira
Copy link
Contributor

Configures kotlin-maven-plugin to include the -java-parameters
argument, so that method parameter names are included in bytecode.

See gh-9323
Fixes gh-12640

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 26, 2018
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 27, 2018
@philwebb philwebb added this to the 2.0.x milestone Mar 27, 2018
@wilkinsona
Copy link
Member

Thanks for the PR, @ruifigueira. I suspect we need to do the same in Gradle too. Would you like to confirm that and make the necessary changes as part of this pull request?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Mar 27, 2018
@ruifigueira
Copy link
Contributor Author

Sure, @wilkinsona. I found a similar PR (#9839) which is a great help, so I'll change KotlinPluginAction accordingly.

@snicoll snicoll added status: on-hold We can't start working on this issue yet and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 27, 2018
@ruifigueira
Copy link
Contributor Author

Gradle plugin now enables -java-parameters by default.
I also included some documentation.

Configures kotlin-maven-plugin to include the `-java-parameters`
argument, so that method parameter names are included in bytecode.

See gh-9323
Fixes gh-12640
This way, java parameters names are included in bytecode and can be
retrieved using reflection.

Fixes gh-12640
This commit documents the need of `-java-parameters` flag when compiling
kotlin to ensure `Endpoint` method parameters names are available, as
well as informing that `spring-boot-gradle-plugin` / maven with
`spring-boot-starter-parent` do exactly that by default when
activated.

Fixes gh-12640
Using `javaParameters` configuration parameter in `kotlin-maven-plugin`
instead of args: it is cleaner and users can add `args` to the plugin
configuration without having to worry about adding `-java-parameters`

Fixes gl-12640
@snicoll snicoll removed the status: on-hold We can't start working on this issue yet label Mar 28, 2018
@wilkinsona wilkinsona modified the milestones: 2.0.x, 2.0.1 Mar 28, 2018
@wilkinsona wilkinsona self-assigned this Mar 28, 2018
@ruifigueira
Copy link
Contributor Author

Concourse CI doesn't seem to like me :) I was looking into those build errors and they are from Spring Boot Server Tests:

[ERROR] nestedMetaInfResourceIsAvailableViaServletContext[Undertow: exploded jar](org.springframework.boot.context.embedded.EmbeddedServletContainerJarPackagingIntegrationTests)  Time elapsed: 4.007 s  <<< ERROR!
java.lang.NoClassDefFoundError: org/springframework/web/client/RestTemplate$AcceptHeaderRequestCallback

and in another job, it is failing due to a Github Pull Request under build-deployment-tests > git-pull-request:

/usr/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/session.rb:625:in `rescue in create_socket': getaddrinfo: Try again (api.github.com:443) (Faraday::ConnectionFailed)

I noticed that the first one is also occuring in the official Spring Boot master branch, so I'm assuming it has nothing to do with my changes.

wilkinsona added a commit that referenced this pull request Mar 28, 2018
* gh-12641:
  Polish “Configure Kotlin compiler to use -java-parameters by default”
  Configure Kotlin compiler to use -java-parameters by default
@wilkinsona
Copy link
Member

Thanks very much for making your first contribution to Spring Boot, @ruifigueira. Especially one that was so complete. Sorry about the CI failures. I believe they were caused by a corrupted jar file from one of our snapshot dependencies.

I've merged your changes into master along with a little bit of polish. Thanks again.

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

Successfully merging this pull request may close these issues.

Kotlin method parameter names are not included in bytecode
5 participants