Home > Enterprise >  MissingMethodException when passing an implementing class instead of an interface
MissingMethodException when passing an implementing class instead of an interface

Time:11-30

I'm developing a script on Jira workflows (using Adaptavist Scriptrunner v.6.34) and I'm facing an issue in which groovy does not accept an interface implementation as a parameter to a function whose signature allows the implemented interface.

Code

import com.atlassian.jira.issue.link.DefaultRemoteIssueLinkManager;

(...)

def remoteLink = DefaultRemoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)

(issue is a build variable of type com.atlassian.jira.issue.IssueImpl)

What happens

groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.issue.link.DefaultRemoteIssueLinkManager.getRemoteIssueLinksForIssue() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl) values: [ADA-24684]
Possible solutions: getRemoteIssueLinksForIssue(com.atlassian.jira.issue.Issue)
    at Script6.run(Script6.groovy:32)
  • The method documentation is here
  • The method signature expects a parameter of type Issue (an Interface)
  • The parameter I am passing is of type IssueImpl

I don't understand how groovy does not accept an interface implementation.

What I tried so far

All those situations returned the original exception.

I've printed the methods and interfaces of the classes and everything matches the documentation, so no version mismatch here.

I don't know what else to do as it is going beyond my java/groovy knowledge. I've asked to colleagues which are java experts and they are not finding a reason for this behaviour. Any ideas?

CodePudding user response:

DefaultRemoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)

That is attempting to invoke a static method named getRemoteIssueLinksForIssue on the DefaultRemoteIssueLinkManager class. There does not appear to be any such method, and the error you are seeing is consistent with that.

The method you linked at docs.atlassian.com/software/jira/docs/api/8.19.0/com/atlassian/jira/issue/link/DefaultRemoteIssueLinkManager.html#getRemoteIssueLinksForIssue-com.atlassian.jira.issue.Issue- is an instance method, not a static method.

  • Related