Details
-
Suggestion
-
Resolution: Unresolved
-
None
-
None
-
None
-
1
-
Description
Problem Definition
When using Kotlin to create a Jira plugin, one runs into this problem very quickly:
https://youtrack.jetbrains.com/issue/KT-19515
The problem is, that Kotlin inheritance respects generics. There are many classes in the Jira source code and/or it's libraries that do not use generics and instead use the raw type.
For example:
- com.atlassian.jira.util.ErrorColleciton - uses Generics
- webwork.action.ActionSupport - does not use Generics
- This leads to a clash of signatures in com.atlassian.jira.web.action.JiraWebActionSupport:
- setErrorMessages(Collection)
- setErrorMessages(Collection<String>)
- This is fine for the Java compiler. However, the Kotlin compiler is more strict here.
- Thus, in Kotlin, just subclassing JiraWebActionSupport will lead to a compile error
Suggested Solution
- The problem cannot be fixed at client/call side (the plugin).
- Adaption of the Jira source code and it's dependencies is necessary.
- Specifically, scan all Java files and add missing generics.
- Specifically, webwork-1.4-atlassian-30.jar should have generics added (or rather, it should be replaced with a 1.5 version of the library), as this contains the often needed Action base classes.
- There should not be anything blocking adding generics going forward, as Jira already requires Java 1.8 as stated on "Supported platforms" page
Why this is important
Kotlin is picking up momentum and it can be expected that more and more plugins will be created with Kotlin
Kotlin was on the "Adopt" stage of the Atlassian Tech Radar this year. So if we shall adopt, let's make it as smooth as possible
Workaround
Whenever you need to extend a Jira base class that will lead to such a compile error in Kotlin, create the subclass as a Java class instead.