I identified this problem while diagnosing a bug reported against Spring Boot.
It's probably best described with an example:
GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
CompilationUnit compilationUnit = new CompilationUnit(groovyClassLoader);
CompileUnit ast = compilationUnit.getAST();
Compiling the above, and running it with a file named foo.groovy in the current working directory with the contents:
will produce the output:
I would expect the class to be named foo, not file:foo. This is the result if foo.groovy is moved into a directory named foo and the URL used to reference it becomes file:foo/foo.groovy.
I believe the problem lies in org.codehaus.groovy.ast.ModuleNode.extractClassFromFileDescription() as it does not consider a URL that contains no slashes. As a result it never strips off the file: prefix.