0

I have the following class:

@groovy.transform.InheritConstructors
class PythonBuild {
    def basePath
    def branchName

    PythonBuild(String basePath, String branchName) {
        // stuff
    }
}

when I instantiate it:

master = PythonBuild('Python-Backend/+MASTER/', 'master')

I get this error:

groovy.lang.MissingMethodException: No signature of method:
Script1.PythonBuild() is applicable for argument types:
(java.lang.String, java.lang.String) values: [Python-Backend/+MASTER/, master]

This error makes no sense to me since, as far as I can tell, the constructor is defined as taking two strings and I am passing two strings.

I am new to Groovy and have got this far by copying examples. What am I doing wrong?

7
  • It seems that Newify is not inherited. Could you please check it? Annotate PythonBuild with Newify? Commented Nov 2, 2015 at 11:37
  • 1
    Should not it be with keyword new while initiating new class master = new PythonBuild('Python-Backend/+MASTER/', 'master') Commented Nov 2, 2015 at 11:40
  • @mst is right, you're just missing the new infront of PythonBuild when trying to call the constructor... Voting to close this as a simple typographic error Commented Nov 2, 2015 at 11:43
  • @tim_yates, is that really a typo or a case with Newify? Commented Nov 2, 2015 at 11:46
  • 1
    @tim_yates it's not a typographic error, I didn't realise the keyword was required. And to be honest the error message from Groovy is not very helpful... though I think I understand now that is was looking for a static method to call rather than the constructor (?) Commented Nov 2, 2015 at 13:02

1 Answer 1

2

new keyword missed, while invoking constructor.

@groovy.transform.InheritConstructors
class PythonBuild {    
    def basePath     
    def branchName     
    def PythonBuild(String basePath, String branchName) { } 
}


def master = new PythonBuild('Python-Backend/+MASTER/', 'master')


println(master)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.