Skip to content

Improve Kotlin support #5537

@philwebb

Description

@philwebb

Placeholder issue for things we can do to improve Kotlin support

@value

Using @Value("${thing}") is a pain because you need to escape $ (e.g. @Value("\${thing}"). Perhaps a different key like @Value("#{thing}").

Open Classes

Open classes are a pain, can we use a classloader to remove final.
Also all @Bean methods

perhaps we can use a custom bean classloader

Default constructor arguments with @Autowired

Give a constructor with a default param:

open class Foo @Autowired constructor(val restTemplate: RestOperation = NoOpRestOperation());

Kotlin will create multiple constructors, this makes Spring fall over because there's multiple annotated constructors. A method to be smart about which to pick would be nice.

Main method

@JvmStatic is needed for main methods. Check if we can find them automatically. Also the name of the class is a bit mad ThePackageKt so perhaps we can replace it with something nice.

Add Kotlin Module

Look at Jackson for an example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions