How to invoke instance methods from within a closure?

I’ve a method as shown below that calls another instance method from the same class. However, the build fails with MissingMethodException unless I make the later method static. Is there a way not to have to do that?

private List<String> myMethod() {
    wsdlFiles.each { wsdlURL ->
        wsdlUrls.add(MyClass.getURLAsString(new File(wsdlDir, wsdlURL)))
    }
    wsdlUrls
}
private static String getURLAsString(File f) {
    f.toURI().toURL().toString()
}

Is this a build script or a class? Does it work when you make the called method non-private?

It’s a class. And it works when the method is made non-private. However, I’d rather make it static than non-private due to encapsulation concerns. Thank you.

It’s a class. And it works when the method is made non-private. However, I’d rather make it static than non-private due to encapsulation concerns. Thank you.

‘protected’ or ‘@PackageScope’ will probably work as well.