Revision: 6710 Author: [email protected] Date: Thu Nov 5 11:49:42 2009 Log: Merge tr...@6696-6702 into this branch Give transient generated units a real source location & precompute hash while source is available Slick trick with CompiledClass source location allows a much looser coupling of compilation unit validation code Looser coupling for ArtificialRescueChecker @Deprecate Resource.getURL() which isn't generally safe, and removes all overrides Removing lots of old, unneeded code from DevMode hierarchy TypeOracle.sort methods should be static ModuleContext should not create a zillion TypeOracles svn merge --ignore-ancestry -r6695:6702 https://google-web-toolkit.googlecode.com/svn/trunk .
http://code.google.com/p/google-web-toolkit/source/detail?r=6710 Modified: /releases/2.0/branch-info.txt /releases/2.0/dev/core/src/com/google/gwt/core/ext/typeinfo/TypeOracle.java /releases/2.0/dev/core/src/com/google/gwt/dev/DevMode.java /releases/2.0/dev/core/src/com/google/gwt/dev/DevModeBase.java /releases/2.0/dev/core/src/com/google/gwt/dev/GWTCompiler.java /releases/2.0/dev/core/src/com/google/gwt/dev/GWTShell.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/ArtificialRescueChecker.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/BinaryTypeReferenceRestrictionsChecker.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationState.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java /releases/2.0/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java /releases/2.0/dev/core/src/com/google/gwt/dev/resource/Resource.java /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/FileResource.java /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java /releases/2.0/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java /releases/2.0/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java /releases/2.0/dev/core/src/com/google/gwt/dev/shell/HostedModeServletContextProxy.java /releases/2.0/dev/core/src/com/google/gwt/dev/shell/tomcat/EmbeddedTomcatServer.java /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JDelegatingClassTypeTestBase.java /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JParameterizedTypeTest.java /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JRawTypeTest.java /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/ModuleContext.java /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/TypeOracleTest.gwt.xml /releases/2.0/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java /releases/2.0/dev/core/test/com/google/gwt/dev/javac/impl/MockResource.java /releases/2.0/dev/core/test/com/google/gwt/dev/resource/impl/MockAbstractResource.java /releases/2.0/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java /releases/2.0/user/src/com/google/gwt/junit/JUnitShell.java /releases/2.0/user/src/com/google/gwt/resources/ext/ResourceGeneratorUtil.java ======================================= --- /releases/2.0/branch-info.txt Thu Nov 5 11:47:39 2009 +++ /releases/2.0/branch-info.txt Thu Nov 5 11:49:42 2009 @@ -363,7 +363,18 @@ Clarify JsniCollector.SourceCache comment svn merge --ignore-ancestry -c 6616 https://google-web-toolkit.googlecode.com/svn/trunk . + tr...@6707 was merged into this branch Show which browser failed when a browser dies a mysterious death. svn merge --ignore-ancestry -c r6707 https://google-web-toolkit.googlecode.com/svn/trunk . +tr...@6696-6702 were merged into this branch + Give transient generated units a real source location & precompute hash while source is available + Slick trick with CompiledClass source location allows a much looser coupling of compilation unit validation code + Looser coupling for ArtificialRescueChecker + @Deprecate Resource.getURL() which isn't generally safe, and removes all overrides + Removing lots of old, unneeded code from DevMode hierarchy + TypeOracle.sort methods should be static + ModuleContext should not create a zillion TypeOracles + svn merge --ignore-ancestry -r6695:6702 https://google-web-toolkit.googlecode.com/svn/trunk . + ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/core/ext/typeinfo/TypeOracle.java Fri Jul 31 13:43:46 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/core/ext/typeinfo/TypeOracle.java Thu Nov 5 11:49:42 2009 @@ -146,6 +146,65 @@ static final String[] NO_STRINGS = new String[0]; private static final String JSO_CLASS = "com.google.gwt.core.client.JavaScriptObject"; + + /** + * Convenience method to sort class types in a consistent way. Note that the + * order is subject to change and is intended to generate an "aesthetically + * pleasing" order rather than a computationally reliable order. + */ + public static void sort(JClassType[] types) { + Arrays.sort(types, new Comparator<JClassType>() { + public int compare(JClassType type1, JClassType type2) { + String name1 = type1.getQualifiedSourceName(); + String name2 = type2.getQualifiedSourceName(); + return name1.compareTo(name2); + } + }); + } + + /** + * Convenience method to sort constructors in a consistent way. Note that the + * order is subject to change and is intended to generate an "aesthetically + * pleasing" order rather than a computationally reliable order. + */ + public static void sort(JConstructor[] ctors) { + Arrays.sort(ctors, new Comparator<JConstructor>() { + public int compare(JConstructor o1, JConstructor o2) { + // Nothing for now; could enhance to sort based on parameter list + return 0; + } + }); + } + + /** + * Convenience method to sort fields in a consistent way. Note that the order + * is subject to change and is intended to generate an "aesthetically + * pleasing" order rather than a computationally reliable order. + */ + public static void sort(JField[] fields) { + Arrays.sort(fields, new Comparator<JField>() { + public int compare(JField f1, JField f2) { + String name1 = f1.getName(); + String name2 = f2.getName(); + return name1.compareTo(name2); + } + }); + } + + /** + * Convenience method to sort methods in a consistent way. Note that the order + * is subject to change and is intended to generate an "aesthetically + * pleasing" order rather than a computationally reliable order. + */ + public static void sort(JMethod[] methods) { + Arrays.sort(methods, new Comparator<JMethod>() { + public int compare(JMethod m1, JMethod m2) { + String name1 = m1.getName(); + String name2 = m2.getName(); + return name1.compareTo(name2); + } + }); + } static String[] modifierBitsToNames(int bits) { List<String> strings = new ArrayList<String>(); @@ -572,65 +631,6 @@ recentTypes.clear(); ++reloadCount; } - - /** - * Convenience method to sort class types in a consistent way. Note that the - * order is subject to change and is intended to generate an "aesthetically - * pleasing" order rather than a computationally reliable order. - */ - public void sort(JClassType[] types) { - Arrays.sort(types, new Comparator<JClassType>() { - public int compare(JClassType type1, JClassType type2) { - String name1 = type1.getQualifiedSourceName(); - String name2 = type2.getQualifiedSourceName(); - return name1.compareTo(name2); - } - }); - } - - /** - * Convenience method to sort constructors in a consistent way. Note that the - * order is subject to change and is intended to generate an "aesthetically - * pleasing" order rather than a computationally reliable order. - */ - public void sort(JConstructor[] ctors) { - Arrays.sort(ctors, new Comparator<JConstructor>() { - public int compare(JConstructor o1, JConstructor o2) { - // Nothing for now; could enhance to sort based on parameter list - return 0; - } - }); - } - - /** - * Convenience method to sort fields in a consistent way. Note that the order - * is subject to change and is intended to generate an "aesthetically - * pleasing" order rather than a computationally reliable order. - */ - public void sort(JField[] fields) { - Arrays.sort(fields, new Comparator<JField>() { - public int compare(JField f1, JField f2) { - String name1 = f1.getName(); - String name2 = f2.getName(); - return name1.compareTo(name2); - } - }); - } - - /** - * Convenience method to sort methods in a consistent way. Note that the order - * is subject to change and is intended to generate an "aesthetically - * pleasing" order rather than a computationally reliable order. - */ - public void sort(JMethod[] methods) { - Arrays.sort(methods, new Comparator<JMethod>() { - public int compare(JMethod m1, JMethod m2) { - String name1 = m1.getName(); - String name2 = m2.getName(); - return name1.compareTo(name2); - } - }); - } void addNewType(JRealClassType newType) { String fqcn = newType.getQualifiedSourceName(); ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/DevMode.java Wed Nov 4 08:46:30 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/DevMode.java Thu Nov 5 11:49:42 2009 @@ -21,7 +21,6 @@ import com.google.gwt.core.ext.UnableToCompleteException; import com.google.gwt.core.ext.linker.ArtifactSet; import com.google.gwt.core.ext.linker.impl.StandardLinkerContext; -import com.google.gwt.dev.Compiler.CompilerOptionsImpl; import com.google.gwt.dev.cfg.ModuleDef; import com.google.gwt.dev.shell.ArtifactAcceptor; import com.google.gwt.dev.shell.jetty.JettyLauncher; @@ -293,20 +292,6 @@ // ignore, problem already logged } } - - @Override - protected void compile(TreeLogger logger) throws UnableToCompleteException { - CompilerOptions newOptions = new CompilerOptionsImpl(options); - newOptions.setCompilationStateRetained(true); - new Compiler(newOptions).run(logger); - } - - @Deprecated - @Override - protected void compile(TreeLogger logger, ModuleDef moduleDef) - throws UnableToCompleteException { - throw new UnsupportedOperationException(); - } @Override protected HostedModeBaseOptions createOptions() { @@ -415,33 +400,6 @@ protected String getWebServerName() { return options.getServletContainerLauncher().getName(); } - - @Override - protected boolean initModule(String moduleName) { - ModuleDef module = modulesByName.get(moduleName); - if (module == null) { - getTopLogger().log( - TreeLogger.WARN, - "Unknown module requested '" - + moduleName - + "'; all active GWT modules must be specified in the command line arguments"); - return false; - } - try { - TreeLogger logger = getTopLogger().branch(TreeLogger.DEBUG, - "Initializing module '" + module.getName() + "' for hosted mode"); - boolean shouldRefreshPage = false; - if (module.isGwtXmlFileStale()) { - shouldRefreshPage = true; - module = loadModule(logger, module.getCanonicalName(), false); - } - link(logger, module); - return shouldRefreshPage; - } catch (UnableToCompleteException e) { - // Already logged. - return false; - } - } /* * Overridden to keep our map up to date. ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/DevModeBase.java Thu Nov 5 08:47:31 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/DevModeBase.java Thu Nov 5 11:49:42 2009 @@ -73,25 +73,6 @@ */ public class UiBrowserWidgetHostImpl implements BrowserWidgetHost { - public void compile() throws UnableToCompleteException { - if (isLegacyMode()) { - throw new UnsupportedOperationException(); - } - DevModeBase.this.compile(getLogger()); - } - - @Deprecated - public void compile(String[] moduleNames) throws UnableToCompleteException { - if (!isLegacyMode()) { - throw new UnsupportedOperationException(); - } - for (int i = 0; i < moduleNames.length; i++) { - String moduleName = moduleNames[i]; - ModuleDef moduleDef = loadModule(getLogger(), moduleName, true); - DevModeBase.this.compile(getLogger(), moduleDef); - } - } - public ModuleSpaceHost createModuleSpaceHost(TreeLogger mainLogger, String moduleName, String userAgent, String url, String tabKey, String sessionKey, BrowserChannelServer serverChannel, @@ -132,19 +113,6 @@ public TreeLogger getLogger() { return getTopLogger(); } - - public boolean initModule(String moduleName) { - return DevModeBase.this.initModule(moduleName); - } - - @Deprecated - public boolean isLegacyMode() { - return DevModeBase.this instanceof GWTShell; - } - - public String normalizeURL(String whatTheUserTyped) { - return DevModeBase.this.normalizeURL(whatTheUserTyped); - } public void unloadModule(ModuleSpaceHost moduleSpaceHost) { ModuleHandle module = loadedModules.remove(moduleSpaceHost); @@ -733,7 +701,7 @@ String startupURL = ""; try { for (String prenormalized : options.getStartupURLs()) { - startupURL = normalizeURL(prenormalized); + startupURL = normalizeURL(prenormalized, getPort(), getHost()); logger.log(TreeLogger.INFO, "Starting URL: " + startupURL, null); launchURL(startupURL); } @@ -742,10 +710,6 @@ "Unable to open new window for startup URL: " + startupURL, null); } } - - public final String normalizeURL(String unknownUrlText) { - return normalizeURL(unknownUrlText, getPort(), getHost()); - } /** * Callback for the UI to indicate it is done. @@ -790,21 +754,6 @@ protected long checkForUpdatesInterval() { return CheckForUpdates.ONE_MINUTE; } - - /** - * Compiles all modules. - * - * @throws UnableToCompleteException - */ - protected abstract void compile(TreeLogger logger) - throws UnableToCompleteException; - - /** - * Compiles a module (legacy only). - */ - @Deprecated - protected abstract void compile(TreeLogger logger, ModuleDef moduleDef) - throws UnableToCompleteException; protected abstract HostedModeBaseOptions createOptions(); @@ -890,26 +839,6 @@ protected String getHost() { return "localhost"; } - - /** - * Called from a selection script as it begins to load in hosted mode. This - * triggers a hosted mode link, which might actually update the running - * selection script. - * - * @param moduleName the module to link - * @return <code>true</code> if the selection script was overwritten; this - * will trigger a full-page refresh by the calling (out of date) - * selection script - */ - protected boolean initModule(String moduleName) { - /* - * Not used in legacy mode due to GWTShellServlet playing this role. - * - * TODO: something smarter here and actually make GWTShellServlet less - * magic? - */ - return false; - } /** * By default we will open the application window. ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/GWTCompiler.java Thu Oct 29 07:49:45 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/GWTCompiler.java Thu Nov 5 11:49:42 2009 @@ -66,7 +66,10 @@ } } - static class GWTCompilerOptionsImpl extends PrecompileOptionsImpl implements + /** + * Simple implementation of {...@link LegacyCompilerOptions}. + */ + public static class GWTCompilerOptionsImpl extends PrecompileOptionsImpl implements LegacyCompilerOptions { private int localWorkers; ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/GWTShell.java Wed Nov 4 06:59:39 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/GWTShell.java Thu Nov 5 11:49:42 2009 @@ -19,7 +19,6 @@ import com.google.gwt.core.ext.UnableToCompleteException; import com.google.gwt.core.ext.linker.ArtifactSet; import com.google.gwt.core.ext.linker.EmittedArtifact; -import com.google.gwt.dev.GWTCompiler.GWTCompilerOptionsImpl; import com.google.gwt.dev.cfg.ModuleDef; import com.google.gwt.dev.shell.ArtifactAcceptor; import com.google.gwt.dev.shell.WorkDirs; @@ -185,26 +184,6 @@ public void restartServer(TreeLogger logger) throws UnableToCompleteException { // Unimplemented. } - - @Override - protected void compile(TreeLogger logger) throws UnableToCompleteException { - throw new UnsupportedOperationException(); - } - - /** - * Compiles a logical module def. The caller can modify the specified module - * def programmatically in some cases (this is needed for JUnit support, for - * example). - */ - @Override - protected void compile(TreeLogger logger, ModuleDef moduleDef) - throws UnableToCompleteException { - LegacyCompilerOptions newOptions = new GWTCompilerOptionsImpl(options); - newOptions.setCompilationStateRetained(true); - if (!new GWTCompiler(newOptions).run(logger, moduleDef)) { - // TODO(jat): error dialog? - } - } @Override protected HostedModeBaseOptions createOptions() { ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/ArtificialRescueChecker.java Mon Nov 2 12:44:54 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/ArtificialRescueChecker.java Thu Nov 5 11:49:42 2009 @@ -291,8 +291,9 @@ * Check the {...@link ArtificialRescue} annotations in a CompilationUnit. Errors * are reported through {...@link GWTProblem}. */ - public static void check(CompilationUnit cud) { - new ArtificialRescueChecker(cud).check(); + public static void check(CompilationUnitDeclaration cud, + boolean allowArtificialRescue) { + new ArtificialRescueChecker(cud, allowArtificialRescue).check(); } /** @@ -354,15 +355,16 @@ private List<String> referencedTypes; - private ArtificialRescueChecker(CompilationUnit unit) { - allowArtificialRescue = unit.isGenerated(); - cud = unit.getJdtCud(); - } - private ArtificialRescueChecker(CompilationUnitDeclaration cud) { allowArtificialRescue = true; this.cud = cud; } + + private ArtificialRescueChecker(CompilationUnitDeclaration cud, + boolean allowArtificialRescue) { + this.cud = cud; + this.allowArtificialRescue = allowArtificialRescue; + } private void check() { collectTypes = false; ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/BinaryTypeReferenceRestrictionsChecker.java Fri Aug 14 14:43:27 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/BinaryTypeReferenceRestrictionsChecker.java Thu Nov 5 11:49:42 2009 @@ -110,8 +110,7 @@ * is reported against the {...@link CompilationUnitDeclaration} for the first * instance of each unique {...@link BinaryTypeBinding}. */ - public static void check(CompilationUnitDeclaration cud, - Set<String> validBinaryTypeNames) { + public static void check(CompilationUnitDeclaration cud) { List<BinaryTypeReferenceSite> binaryTypeReferenceSites = findAllBinaryTypeReferenceSites(cud); Set<BinaryTypeBinding> alreadySeenTypeBindings = new HashSet<BinaryTypeBinding>(); @@ -122,8 +121,8 @@ } alreadySeenTypeBindings.add(binaryTypeBinding); - String binaryName = String.valueOf(binaryTypeBinding.constantPoolName()); - if (validBinaryTypeNames.contains(binaryName)) { + String fileName = String.valueOf(binaryTypeBinding.getFileName()); + if (fileName.endsWith(".java")) { // This binary name is valid; it is a reference to a unit that was // compiled in a previous JDT run. continue; ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationState.java Wed Nov 4 12:27:13 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationState.java Thu Nov 5 11:49:42 2009 @@ -345,7 +345,7 @@ // Check all units using our custom checks. CompilationUnitInvalidator.validateCompilationUnits(invalidatorState, - newUnits, jdtCompiler.getBinaryTypeNames()); + newUnits); // More units may have errors now. anyErrors |= CompilationUnitInvalidator.invalidateUnitsWithErrors(logger, ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java Wed Nov 4 12:27:13 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java Thu Nov 5 11:49:42 2009 @@ -285,16 +285,14 @@ return GENERATED_CLASSNAME_PATTERN.matcher(className).matches(); } - private static Set<String> computeFileNameRefs( - CompilationUnitDeclaration cud, - final Map<String, String> binaryTypeToSourceFileMap) { + private static Set<String> computeFileNameRefs(CompilationUnitDeclaration cud) { final Set<String> result = new HashSet<String>(); cud.traverse(new TypeRefVisitor(cud) { @Override protected void onBinaryTypeRef(BinaryTypeBinding referencedType, CompilationUnitDeclaration unitOfReferrer, Expression expression) { - String fileName = binaryTypeToSourceFileMap.get(String.valueOf(referencedType.getFileName())); - if (fileName != null) { + String fileName = String.valueOf(referencedType.getFileName()); + if (fileName.endsWith(".java")) { result.add(fileName); } } @@ -507,11 +505,10 @@ /** * Sets the compiled JDT AST for this unit. */ - void setCompiled(CompilationUnitDeclaration cud, - Map<String, String> binaryTypeToSourceFileMap) { + void setCompiled(CompilationUnitDeclaration cud) { assert (state == State.FRESH || state == State.ERROR); this.cud = cud; - fileNameRefs = computeFileNameRefs(cud, binaryTypeToSourceFileMap); + fileNameRefs = computeFileNameRefs(cud); state = State.COMPILED; } ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java Mon Jul 6 14:45:31 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java Thu Nov 5 11:49:42 2009 @@ -196,15 +196,14 @@ } public static void validateCompilationUnits(InvalidatorState state, - Collection<CompilationUnit> units, Set<String> validBinaryTypeNames) { + Collection<CompilationUnit> units) { for (CompilationUnit unit : units) { if (unit.getState() == State.COMPILED) { CompilationUnitDeclaration jdtCud = unit.getJdtCud(); JSORestrictionsChecker.check(state.jsoState, jdtCud); JsniChecker.check(jdtCud); - ArtificialRescueChecker.check(unit); - BinaryTypeReferenceRestrictionsChecker.check(jdtCud, - validBinaryTypeNames); + ArtificialRescueChecker.check(jdtCud, unit.isGenerated()); + BinaryTypeReferenceRestrictionsChecker.check(jdtCud); } } state.jsoState.finalCheck(); ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java Wed Nov 4 12:27:13 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java Thu Nov 5 11:49:42 2009 @@ -68,7 +68,6 @@ protected final CompiledClass enclosingClass; protected final String internalName; protected final boolean isLocal; - protected final String location; protected final CompilationUnit unit; /** @@ -92,7 +91,6 @@ ClassFile classFile = getClassFile(typeDeclaration, internalName); byte[] bytes = classFile.getBytes(); this.cacheToken = diskCache.writeByteArray(bytes); - this.location = String.valueOf(classFile.fileName()); this.isLocal = isLocalType(binding); } @@ -156,7 +154,7 @@ if (nameEnvironmentAnswer == null) { try { ClassFileReader cfr = new ClassFileReader(getBytes(), - location.toCharArray()); + unit.getDisplayLocation().toCharArray(), true); nameEnvironmentAnswer = new NameEnvironmentAnswer(cfr, null); } catch (ClassFormatException e) { throw new RuntimeException("Unexpectedly unable to parse class file", e); ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java Wed Nov 4 12:27:13 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java Thu Nov 5 11:49:42 2009 @@ -103,7 +103,7 @@ ICompilationUnit icu = cud.compilationResult().compilationUnit; CompilationUnitAdapter adapter = (CompilationUnitAdapter) icu; CompilationUnit unit = adapter.getUnit(); - unit.setCompiled(cud, binaryTypesRefs); + unit.setCompiled(cud); if (!cud.compilationResult().hasErrors()) { recordBinaryTypes(unit.getCompiledClasses()); } @@ -217,11 +217,6 @@ */ private final Map<String, CompiledClass> binaryTypes = new HashMap<String, CompiledClass>(); - /** - * Maps dotted binary names the containing unit location. - */ - private final Map<String, String> binaryTypesRefs = new HashMap<String, String>(); - private final Set<String> notPackages = new HashSet<String>(); private final Set<String> packages = new HashSet<String>(); @@ -254,10 +249,6 @@ PerfLogger.end(); return true; } - - public Set<String> getBinaryTypeNames() { - return binaryTypes.keySet(); - } private void addPackages(String slashedPackageName) { while (packages.add(slashedPackageName)) { @@ -274,8 +265,6 @@ private void recordBinaryTypes(Set<CompiledClass> compiledClasses) { for (CompiledClass compiledClass : compiledClasses) { binaryTypes.put(compiledClass.getInternalName(), compiledClass); - binaryTypesRefs.put(compiledClass.getInternalName(), - compiledClass.getUnit().getDisplayLocation()); } } ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java Tue Jul 28 21:11:02 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java Thu Nov 5 11:49:42 2009 @@ -28,6 +28,7 @@ import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.google.gwt.dev.cfg.ModuleDef; import com.google.gwt.dev.javac.impl.FileCompilationUnit; +import com.google.gwt.dev.javac.impl.Shared; import com.google.gwt.dev.resource.ResourceOracle; import com.google.gwt.dev.util.DiskCache; import com.google.gwt.dev.util.Util; @@ -105,14 +106,20 @@ * Finalizes the source and adds this compilation unit to the host. */ public void commit() { - cacheToken = diskCache.writeString(sw.toString()); + String source = sw.toString(); + strongHash = Util.computeStrongName(Util.getBytes(source)); + cacheToken = diskCache.writeString(source); sw = null; creationTime = System.currentTimeMillis(); } @Override public String getDisplayLocation() { - return "transient source for " + typeName; + if (strongHash != null) { + return "generated://" + strongHash + "/" + Shared.toPath(getTypeName()); + } else { + return "generated://uncommitted/" + Shared.toPath(getTypeName()); + } } @Override @@ -129,9 +136,6 @@ } public String getStrongHash() { - if (strongHash == null) { - strongHash = Util.computeStrongName(Util.getBytes(getSource())); - } return strongHash; } ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/resource/Resource.java Tue Nov 25 17:05:53 2008 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/resource/Resource.java Thu Nov 5 11:49:42 2009 @@ -16,6 +16,7 @@ package com.google.gwt.dev.resource; import java.io.InputStream; +import java.net.MalformedURLException; import java.net.URL; /** @@ -37,8 +38,9 @@ public abstract long getLastModified(); /** - * Returns the user-relevant location of the resource. No programmatic - * assumptions should be made about the return value. + * Returns the URL-like location of the resource. The returned value should + * generally reflect a unique resource in the system. The returned value will + * only be a valid URL if the underlying object is accessible via a URL. */ public abstract String getLocation(); @@ -48,13 +50,19 @@ public abstract String getPath(); /** - * Returns a URL for this resource; this URL will only be valid for resources - * based off the file system. + * Returns a URL for this resource if the resource happens to be based off the + * file system, otherwise returns <code>null</code>. * - * TODO: get rid of this method? + * @deprecated with no replacement */ - public abstract URL getURL(); - + @Deprecated + public final URL getURL() { + try { + return new URL(getLocation()); + } catch (MalformedURLException e) { + return null; + } + } /** * Overridden to finalize; always returns identity hash code. */ ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/FileResource.java Tue Nov 25 17:05:53 2008 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/FileResource.java Thu Nov 5 11:49:42 2009 @@ -19,8 +19,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; /** * Represents a resource contained in directory on a file system. @@ -60,15 +58,6 @@ public String getPath() { return abstractPathName; } - - @Override - public URL getURL() { - try { - return new URL(getLocation()); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } @Override public boolean isStale() { ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java Fri Jun 12 13:56:52 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java Thu Nov 5 11:49:42 2009 @@ -103,11 +103,6 @@ public String getPath() { return path; } - - @Override - public URL getURL() { - return resource.getURL(); - } @Override public boolean isStale() { ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java Wed Apr 1 12:12:47 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java Thu Nov 5 11:49:42 2009 @@ -17,8 +17,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; import java.util.jar.JarFile; import java.util.zip.ZipEntry; @@ -58,15 +56,6 @@ public String getPath() { return path; } - - @Override - public URL getURL() { - try { - return new URL(getLocation()); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } /** * Since we don't dynamically reload zips during a run, zip-based resources ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java Tue Oct 13 16:57:19 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java Thu Nov 5 11:49:42 2009 @@ -23,23 +23,6 @@ * <code>ModuleSpaceHost</code>, and the compiler. */ public interface BrowserWidgetHost { - /** - * Perform a web-mode compile on the user-specified set of modules. Used in - * non-legacy mode. - * - * @throws UnableToCompleteException - */ - void compile() throws UnableToCompleteException; - - /** - * Compile the specified set of modules, used in legacy mode. - * - * @param modules the names of the modules to compile - * @throws UnableToCompleteException - * @deprecated Will be removed when legacy shell mode is removed - */ - @Deprecated - void compile(String[] modules) throws UnableToCompleteException; /** * For OOPHM. @@ -62,29 +45,6 @@ TreeLogger getLogger(); - /** - * Called from a selection script as it begins to load in hosted mode. This - * triggers a hosted mode link, which might actually update the running - * selection script. - * - * @param moduleName the module to link - * @return <code>true</code> if the selection script was overwritten; this - * will trigger a full-page refresh by the calling (out of date) - * selection script - */ - boolean initModule(String moduleName); - - /** - * Returns <code>true</code> if running in legacy mode. - * - * @deprecated Will be removed when legacy shell mode is removed - */ - @Deprecated - boolean isLegacyMode(); - - String normalizeURL(String whatTheUserTyped); - - /** * For OOPHM. */ ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java Tue Oct 13 16:57:19 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java Thu Nov 5 11:49:42 2009 @@ -404,6 +404,7 @@ * @param moduleName the name of the module * @throws IOException */ + @SuppressWarnings("deprecation") private void doGetPublicFile(HttpServletRequest request, HttpServletResponse response, TreeLogger logger, String partialPath, String moduleName) throws IOException { ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/shell/HostedModeServletContextProxy.java Tue Nov 4 12:59:58 2008 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/shell/HostedModeServletContextProxy.java Thu Nov 5 11:49:42 2009 @@ -157,6 +157,7 @@ * @throws MalformedURLException * @see javax.servlet.ServletContext#getResource(java.lang.String) */ + @SuppressWarnings("deprecation") public URL getResource(String path) throws MalformedURLException { ModuleDef moduleDef = moduleDefRef.get(); assert (moduleDef != null) : "GWTShellServlet should have guaranteed that a" ======================================= --- /releases/2.0/dev/core/src/com/google/gwt/dev/shell/tomcat/EmbeddedTomcatServer.java Thu Aug 20 15:05:36 2009 +++ /releases/2.0/dev/core/src/com/google/gwt/dev/shell/tomcat/EmbeddedTomcatServer.java Thu Nov 5 11:49:42 2009 @@ -22,7 +22,7 @@ import com.google.gwt.dev.resource.impl.PathPrefixSet; import com.google.gwt.dev.resource.impl.ResourceOracleImpl; import com.google.gwt.dev.shell.WorkDirs; -import com.google.gwt.util.tools.Utility; +import com.google.gwt.dev.util.Util; import org.apache.catalina.Connector; import org.apache.catalina.ContainerEvent; @@ -39,7 +39,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; @@ -275,70 +274,44 @@ * Assumes that the leaf is a file (not a directory). */ private void copyFileNoOverwrite(TreeLogger logger, String srcResName, - Resource resource, File catBase) { + Resource srcRes, File catBase) { File dest = new File(catBase, srcResName); - InputStream is = null; - FileOutputStream os = null; try { - URL srcRes = resource.getURL(); - if (srcRes == null) { - logger.log(TreeLogger.TRACE, "Cannot find: " + srcResName, null); - return; - } - // Only copy if src is newer than desc. - // - long srcLastModified = srcRes.openConnection().getLastModified(); + long srcLastModified = srcRes.getLastModified(); long dstLastModified = dest.lastModified(); if (srcLastModified < dstLastModified) { // Don't copy over it. - // logger.log(TreeLogger.SPAM, "Source is older than existing: " + dest.getAbsolutePath(), null); return; } else if (srcLastModified == dstLastModified) { // Exact same time; quietly don't overwrite. - // return; } else if (dest.exists()) { // Warn about the overwrite logger.log(TreeLogger.WARN, "Overwriting existing file '" - + dest.getAbsolutePath() + "' with '" + resource.getLocation() + + dest.getAbsolutePath() + "' with '" + srcRes.getLocation() + "', which has a newer timestamp"); } // Make dest directories as required. - // File destParent = dest.getParentFile(); if (destParent != null) { // No need to check mkdirs result because IOException later anyway. destParent.mkdirs(); } - // Open in and out streams. - // - is = srcRes.openStream(); - os = new FileOutputStream(dest); - - // Copy the bytes over. - // - Utility.streamOut(is, os, 1024); - - // Try to close and change the last modified time. - // - Utility.close(os); + Util.copy(srcRes.openContents(), new FileOutputStream(dest)); dest.setLastModified(srcLastModified); logger.log(TreeLogger.TRACE, "Wrote: " + dest.getAbsolutePath(), null); } catch (IOException e) { logger.log(TreeLogger.WARN, "Failed to write: " + dest.getAbsolutePath(), e); - } finally { - Utility.close(is); - Utility.close(os); - } + } } /** ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JDelegatingClassTypeTestBase.java Wed Apr 1 13:03:34 2009 +++ /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JDelegatingClassTypeTestBase.java Thu Nov 5 11:49:42 2009 @@ -98,10 +98,10 @@ assertArraysEqual(expected, actual); } - protected static void validateEquals(TypeOracle oracle, - JClassType[] expectedTypes, JClassType actualTypes[]) { - oracle.sort(expectedTypes); - oracle.sort(actualTypes); + protected static void validateEquals(JClassType[] expectedTypes, + JClassType actualTypes[]) { + TypeOracle.sort(expectedTypes); + TypeOracle.sort(actualTypes); assertArraysEqual(expectedTypes, actualTypes); } ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JParameterizedTypeTest.java Mon Mar 17 12:11:10 2008 +++ /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JParameterizedTypeTest.java Thu Nov 5 11:49:42 2009 @@ -213,7 +213,7 @@ oracle.getType(MyIntegerList.class.getName()), parameterizedMyCustomList}; - validateEquals(oracle, expected, actualSubtypes); + validateEquals(expected, actualSubtypes); } /** ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JRawTypeTest.java Tue Nov 27 14:33:11 2007 +++ /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/JRawTypeTest.java Thu Nov 5 11:49:42 2009 @@ -75,7 +75,7 @@ oracle.getType(MyIntegerList.class.getName())}; JClassType[] actualSubtypes = rawTestType.getSubtypes(); - validateEquals(oracle, expectedTypes, actualSubtypes); + validateEquals(expectedTypes, actualSubtypes); } @Override ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/ModuleContext.java Fri May 9 14:33:56 2008 +++ /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/ModuleContext.java Thu Nov 5 11:49:42 2009 @@ -20,17 +20,35 @@ import com.google.gwt.dev.cfg.ModuleDef; import com.google.gwt.dev.cfg.ModuleDefLoader; +import java.util.HashMap; +import java.util.Map; + /** * Helper for loading modules from the classpath. */ class ModuleContext { + private static final Map<String, TypeOracle> typeOracleMap = new HashMap<String, TypeOracle>(); + + private static TypeOracle getTypeOracleFor(TreeLogger logger, + String moduleName) throws UnableToCompleteException { + TypeOracle oracle; + synchronized (typeOracleMap) { + oracle = typeOracleMap.get(moduleName); + if (oracle == null) { + ModuleDef moduleDef = ModuleDefLoader.loadFromClassPath(logger, + moduleName); + oracle = moduleDef.getCompilationState(logger).getTypeOracle(); + typeOracleMap.put(moduleName, oracle); + } + } + return oracle; + } + private final TypeOracle oracle; - private final ModuleDef moduleDef; ModuleContext(TreeLogger logger, String moduleName) throws UnableToCompleteException { - moduleDef = ModuleDefLoader.loadFromClassPath(logger, moduleName); - oracle = moduleDef.getTypeOracle(logger); + this.oracle = getTypeOracleFor(logger, moduleName); } public TypeOracle getOracle() { ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/TypeOracleTest.gwt.xml Thu Sep 6 13:07:54 2007 +++ /releases/2.0/dev/core/test/com/google/gwt/core/ext/typeinfo/TypeOracleTest.gwt.xml Thu Nov 5 11:49:42 2009 @@ -14,5 +14,6 @@ <module> <inherits name="com.google.gwt.core.Core"/> + <inherits name="com.google.gwt.junit.JUnit"/> <source path="test"/> </module> ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java Wed Nov 4 12:27:13 2009 +++ /releases/2.0/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java Thu Nov 5 11:49:42 2009 @@ -61,8 +61,7 @@ } JdtCompiler.compile(units); CompilationUnitInvalidator.InvalidatorState state = new CompilationUnitInvalidator.InvalidatorState(); - CompilationUnitInvalidator.validateCompilationUnits(state, units, - validBinaryTypeNames); + CompilationUnitInvalidator.validateCompilationUnits(state, units); if (CompilationUnitInvalidator.invalidateUnitsWithErrors(logger, units)) { CompilationUnitInvalidator.invalidateUnitsWithInvalidRefs(logger, units); } ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/dev/javac/impl/MockResource.java Tue Nov 25 17:05:53 2008 +++ /releases/2.0/dev/core/test/com/google/gwt/dev/javac/impl/MockResource.java Thu Nov 5 11:49:42 2009 @@ -46,11 +46,6 @@ public String getPath() { return path; } - - @Override - public URL getURL() { - return null; - } @Override public InputStream openContents() { ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/dev/resource/impl/MockAbstractResource.java Tue Nov 25 17:05:53 2008 +++ /releases/2.0/dev/core/test/com/google/gwt/dev/resource/impl/MockAbstractResource.java Thu Nov 5 11:49:42 2009 @@ -18,7 +18,6 @@ import junit.framework.Assert; import java.io.InputStream; -import java.net.URL; public final class MockAbstractResource extends AbstractResource { private boolean isStale; @@ -49,11 +48,6 @@ public String getPath() { return path; } - - @Override - public URL getURL() { - return null; - } @Override public boolean isStale() { ======================================= --- /releases/2.0/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java Tue Jul 28 21:11:02 2009 +++ /releases/2.0/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java Thu Nov 5 11:49:42 2009 @@ -91,11 +91,6 @@ public String getPath() { return "onPublicPath.txt"; } - - @Override - public URL getURL() { - return null; - } @Override public InputStream openContents() { ======================================= --- /releases/2.0/user/src/com/google/gwt/junit/JUnitShell.java Thu Nov 5 11:47:39 2009 +++ /releases/2.0/user/src/com/google/gwt/junit/JUnitShell.java Thu Nov 5 11:49:42 2009 @@ -20,7 +20,10 @@ import com.google.gwt.core.ext.TreeLogger.Type; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.TypeOracle; +import com.google.gwt.dev.GWTCompiler; import com.google.gwt.dev.GWTShell; +import com.google.gwt.dev.LegacyCompilerOptions; +import com.google.gwt.dev.GWTCompiler.GWTCompilerOptionsImpl; import com.google.gwt.dev.cfg.BindingProperty; import com.google.gwt.dev.cfg.ModuleDef; import com.google.gwt.dev.cfg.ModuleDefLoader; @@ -864,7 +867,11 @@ userAgents); } } - super.compile(getTopLogger(), module); + LegacyCompilerOptions newOptions = new GWTCompilerOptionsImpl(options); + newOptions.setCompilationStateRetained(true); + if (!new GWTCompiler(newOptions).run(getTopLogger(), module)) { + throw new UnableToCompleteException(); + } } void maybeCompileForWebMode(String moduleName, String... userAgents) ======================================= --- /releases/2.0/user/src/com/google/gwt/resources/ext/ResourceGeneratorUtil.java Tue Oct 27 00:00:07 2009 +++ /releases/2.0/user/src/com/google/gwt/resources/ext/ResourceGeneratorUtil.java Thu Nov 5 11:49:42 2009 @@ -92,9 +92,10 @@ resourceMap = oracle.getResourceMap(); } + @SuppressWarnings("deprecation") public URL locate(String resourceName) { Resource r = resourceMap.get(resourceName); - return r == null ? null : r.getURL(); + return (r == null) ? null : r.getURL(); } } --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
