Reputation: 21
I get a groovy.lang.MissingMethodException
in a class which is importing a static class.
Here's the implementation.
import Corpus
class InRe {
Corpus corpus
corpus.posts().each{
}
}
class L {
public static class Corpus{
public posts(){
}
}
}
And when I run my main class, it throws a
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method:
edu.msu.mi.forum.replies.InferReplies$_signatureExtractionByFrequentClosing_closure10.doCall() is applicable for argument types:
(edu.msu.mi.forum.webmd.WebMdConversation) values: [edu.msu.mi.forum.webmd.WebMdConversation@fb309] Possible solutions: doCall(edu.msu.mi.forum.model.Post), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
So my question is if I call a method from a static inner class, is that out of scope ?
Upvotes: 1
Views: 822
Reputation: 1379
You are trying to get to the Corpus class.
The Corpus class is a static class inside L class.
The following code:
class InRe {
Corpus corpus
corpus.posts().each{
}
}
should be changed to:
class InRe {
L.Corpus corpus = new L.Corpus()
corpus.posts().each{
}
}
The access to the Corpus is not direct so you can reach to it using the L.Corpus The import should be related to the class position, means that the import should be
import L
In general: Static nested classes are accessed using the enclosing class name.
Supporting the written above you can follow the java documentation.
Upvotes: 3