Weird getMethod error

Blake McBride <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CABwHSOs+5_OAhMXx5SwDw6TURq28fOEbRHwJNY5otwwaiS3swQ@mail.gmail.com>
Greetings,

I have a really strange error as follows.  I have two files:

*Test3.java:*

import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyCodeSource;
import org.codehaus.groovy.tools.GroovyClass;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;

public class Test3 {

public static void main(String[] args) throws IOException,
NoSuchMethodException
{
GroovyClassLoader groovyLoader = new GroovyClassLoader(GroovyClass.class
.getClassLoader());
Class<?> groovyClass = groovyLoader.parseClass(new GroovyCodeSource(new
File("src/Test4.groovy")), false);
Class<?> [] argTypes = new Class[1];
argTypes[0] = Object.class;
Method f1 = groovyClass.getMethod("fun1", argTypes);
Method f2 = groovyClass.getMethod("main", argTypes);
int x = 1;
}

}

*Test4.groovy:*

class Test4 {

static void fun1(Object x) {
println "Hello from fun1"
}


static void main(Object x) {
println "Hello from main"
}

}

Getting "f1" always works. However, getting "f2" throws an exception!
Interestingly, if I rename "main" or pass a different argument type, it
works.
The only time it doesn't work is if the method name is "main" and it has a
single Object argument.

Does anyone know why this is?

Thanks!

Blake McBride
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.