Remove CompilationUnit's dependency on hosted mode code. Review by: bobv git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5827 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java index cd296df..86f42a6 100644 --- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java +++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
@@ -20,7 +20,6 @@ import com.google.gwt.dev.asm.Opcodes; import com.google.gwt.dev.asm.commons.EmptyVisitor; import com.google.gwt.dev.jdt.TypeRefVisitor; -import com.google.gwt.dev.shell.CompilingClassLoader; import com.google.gwt.dev.util.DiskCache; import com.google.gwt.dev.util.Util; import com.google.gwt.dev.util.collect.HashMap; @@ -48,6 +47,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; /** * Encapsulates the state of a single active compilation unit in a particular @@ -117,7 +117,7 @@ * javac weirdness issue where javac refers a class but does not * generate it. */ - if (CompilingClassLoader.isClassnameGenerated(lookupName) + if (isClassnameGenerated(lookupName) && !allGeneratedClasses.contains(lookupName)) { allGeneratedClasses.add(lookupName); } @@ -264,6 +264,27 @@ } } + private static final Pattern GENERATED_CLASSNAME_PATTERN = Pattern.compile(".+\\$\\d.*"); + + /** + * Checks if the class names is generated. Accepts any classes whose names + * match .+$\d.* (handling named classes within anonymous classes and multiple + * named classes of the same name in a class, but in different methods). + * Checks if the class or any of its enclosing classes are anonymous or + * synthetic. + * <p> + * If new compilers have different conventions for anonymous and synthetic + * classes, this code needs to be updated. + * </p> + * + * @param className name of the class to be checked. + * @return true iff class or any of its enclosing classes are anonymous or + * synthetic. + */ + public static boolean isClassnameGenerated(String className) { + return GENERATED_CLASSNAME_PATTERN.matcher(className).matches(); + } + private static Set<String> computeFileNameRefs( CompilationUnitDeclaration cud, final Map<String, String> binaryTypeToSourceFileMap) { @@ -561,6 +582,6 @@ if (!cc.getRealClassType().isLocalType()) { return false; } - return CompilingClassLoader.isClassnameGenerated(cc.getBinaryName()); + return isClassnameGenerated(cc.getBinaryName()); } }
diff --git a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java index 39124ac..900f3c3 100644 --- a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java +++ b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
@@ -62,7 +62,6 @@ import java.util.SortedMap; import java.util.Stack; import java.util.TreeMap; -import java.util.regex.Pattern; /** * An isolated {@link ClassLoader} for running all user code. All user files are @@ -451,8 +450,6 @@ private static EmmaStrategy emmaStrategy; - private static final Pattern GENERATED_CLASSNAME_PATTERN = Pattern.compile(".+\\$\\d.*"); - /** * Caches the byte code for {@link JavaScriptHost}. */ @@ -479,25 +476,6 @@ emmaStrategy = EmmaStrategy.get(emmaAvailable); } - /** - * Checks if the class names is generated. Accepts any classes whose names - * match .+$\d.* (handling named classes within anonymous classes and multiple - * named classes of the same name in a class, but in different methods). - * Checks if the class or any of its enclosing classes are anonymous or - * synthetic. - * <p> - * If new compilers have different conventions for anonymous and synthetic - * classes, this code needs to be updated. - * </p> - * - * @param className name of the class to be checked. - * @return true iff class or any of its enclosing classes are anonymous or - * synthetic. - */ - public static boolean isClassnameGenerated(String className) { - return GENERATED_CLASSNAME_PATTERN.matcher(className).matches(); - } - private static void classDump(String name, byte[] bytes) { String packageName, className; int pos = name.lastIndexOf('.'); @@ -1024,7 +1002,7 @@ * compiler. */ if (typeHasCompilationUnit(lookupClassName) - && isClassnameGenerated(className)) { + && CompilationUnit.isClassnameGenerated(className)) { /* * modification time = 0 ensures that whatever is on the disk is always * loaded.
diff --git a/dev/core/test/com/google/gwt/dev/shell/GeneratedClassnameTest.java b/dev/core/test/com/google/gwt/dev/javac/GeneratedClassnameTest.java similarity index 82% rename from dev/core/test/com/google/gwt/dev/shell/GeneratedClassnameTest.java rename to dev/core/test/com/google/gwt/dev/javac/GeneratedClassnameTest.java index ecf7087..3a70b0a 100644 --- a/dev/core/test/com/google/gwt/dev/shell/GeneratedClassnameTest.java +++ b/dev/core/test/com/google/gwt/dev/javac/GeneratedClassnameTest.java
@@ -1,4 +1,4 @@ -package com.google.gwt.dev.shell; +package com.google.gwt.dev.javac; import junit.framework.TestCase; @@ -16,12 +16,12 @@ for (String name : namesToAccept) { assertTrue("className = " + name + " should have been accepted", - CompilingClassLoader.isClassnameGenerated(name)); + CompilationUnit.isClassnameGenerated(name)); } for (String name : namesToReject) { assertFalse("className = " + name + " should not have been accepted", - CompilingClassLoader.isClassnameGenerated(name)); + CompilationUnit.isClassnameGenerated(name)); } } }