[^jeka] fix groovy compiler tests

(cherry-picked from 929fdfa)
This commit is contained in:
peter
2012-11-23 21:51:41 +01:00
parent a345240b37
commit fa91e1ccb0
@@ -328,14 +328,6 @@ public class GroovycRunner {
final CompilerConfiguration config,
final String finalOutput, final GroovyClassLoader classLoader) {
try {
if (forStubs) {
return createStubGenerator(config, classLoader);
}
}
catch (NoClassDefFoundError ignore) { // older groovy distributions just don't have stub generation capability
}
final GroovyClassLoader transformLoader = new GroovyClassLoader(classLoader) {
public Enumeration<URL> getResources(String name) throws IOException {
if (name.endsWith("org.codehaus.groovy.transform.ASTTransformation")) {
@@ -358,6 +350,15 @@ public class GroovycRunner {
return super.getResources(name);
}
};
try {
if (forStubs) {
return createStubGenerator(config, classLoader, transformLoader);
}
}
catch (NoClassDefFoundError ignore) { // older groovy distributions just don't have stub generation capability
}
CompilationUnit unit;
try {
unit = new CompilationUnit(config, null, classLoader, transformLoader) {
@@ -385,10 +386,14 @@ public class GroovycRunner {
return unit;
}
private static CompilationUnit createStubGenerator(final CompilerConfiguration config, final GroovyClassLoader classLoader) {
private static CompilationUnit createStubGenerator(final CompilerConfiguration config, final GroovyClassLoader classLoader, final GroovyClassLoader transformLoader) {
JavaAwareCompilationUnit unit = new JavaAwareCompilationUnit(config, classLoader) {
private boolean annoRemovedAdded;
public GroovyClassLoader getTransformLoader() {
return transformLoader;
}
@Override
public void addPhaseOperation(PrimaryClassNodeOperation op, int phase) {
if (!annoRemovedAdded && phase == Phases.CONVERSION && op.getClass().getName().startsWith("org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit$")) {