Author: sco...@google.com Date: Tue Mar 31 09:48:28 2009 New Revision: 5130
Added: changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/StaticData.java Modified: changes/scottb/memory/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocaleUtils.java changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java changes/scottb/memory/user/src/com/google/gwt/i18n/server/GwtLocaleFactoryImpl.java Log: HACK: clear out pinned i18n static data. Modified: changes/scottb/memory/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java ============================================================================== --- changes/scottb/memory/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java (original) +++ changes/scottb/memory/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java Tue Mar 31 09:48:28 2009 @@ -371,6 +371,13 @@ // Free up memory. module.clear(); + try { + Class<?> clazz = Class.forName("com.google.gwt.i18n.rebind.StaticData", + false, Thread.currentThread().getContextClassLoader()); + clazz.getDeclaredMethod("clear").invoke(null); + } catch (Throwable e) { + e.printStackTrace(); + } // Check for compilation problems. We don't log here because any problems // found here will have already been logged by AbstractCompiler. Modified: changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocaleUtils.java ============================================================================== --- changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocaleUtils.java (original) +++ changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocaleUtils.java Tue Mar 31 09:48:28 2009 @@ -32,7 +32,13 @@ public class LocaleUtils { // TODO(jat): rewrite to avoid statics - private static GwtLocaleFactory factory = new GwtLocaleFactoryImpl(); + private static final Set<GwtLocale> allCompileLocales = new HashSet<GwtLocale>(); + + private static final Set<GwtLocale> allLocales = new HashSet<GwtLocale>(); + + private static GwtLocale compileLocale; + + private static final GwtLocaleFactoryImpl factory = new GwtLocaleFactoryImpl(); /** * The token representing the locale property controlling Localization. @@ -44,13 +50,15 @@ */ private static final String PROP_RUNTIME_LOCALES = "runtime.locales"; - private static GwtLocale compileLocale; - - private static Set<GwtLocale> allLocales = new HashSet<GwtLocale>(); + private static final Set<GwtLocale> runtimeLocales = new HashSet<GwtLocale>(); - private static Set<GwtLocale> allCompileLocales = new HashSet<GwtLocale>(); - - private static Set<GwtLocale> runtimeLocales = new HashSet<GwtLocale>(); + public static void clear() { + allCompileLocales.clear(); + allLocales.clear(); + compileLocale = null; + factory.clear(); + runtimeLocales.clear(); + } /** * Returns the set of all compile-time locales. @@ -112,9 +120,9 @@ return; } compileLocale = newCompileLocale; - allLocales = new HashSet<GwtLocale>(); - allCompileLocales = new HashSet<GwtLocale>(); - runtimeLocales = new HashSet<GwtLocale>(); + allLocales.clear(); + allCompileLocales.clear(); + runtimeLocales.clear(); String[] localeValues = propertyOracle.getPropertyValueSet(logger, PROP_LOCALE); String rtLocaleNames = propertyOracle.getPropertyValue(logger, Modified: changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java ============================================================================== --- changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java (original) +++ changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java Tue Mar 31 09:48:28 2009 @@ -94,13 +94,13 @@ } return generate(logger, context, typeName, locale); } - + public final String generate(TreeLogger logger, GeneratorContext context, String typeName, String localeName) throws UnableToCompleteException { // Clear cache if reset was done. TypeOracle typeOracle = context.getTypeOracle(); if (lastReloadCount != typeOracle.getReloadCount()) { - ResourceFactory.clearCache(); + StaticData.clear(); lastReloadCount = typeOracle.getReloadCount(); } Added: changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/StaticData.java ============================================================================== --- (empty file) +++ changes/scottb/memory/user/src/com/google/gwt/i18n/rebind/StaticData.java Tue Mar 31 09:48:28 2009 @@ -0,0 +1,26 @@ +/* + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.i18n.rebind; + +/** + * Allows clearing accumulated static state. + */ +public class StaticData { + public static void clear() { + ResourceFactory.clearCache(); + LocaleUtils.clear(); + } +} Modified: changes/scottb/memory/user/src/com/google/gwt/i18n/server/GwtLocaleFactoryImpl.java ============================================================================== --- changes/scottb/memory/user/src/com/google/gwt/i18n/server/GwtLocaleFactoryImpl.java (original) +++ changes/scottb/memory/user/src/com/google/gwt/i18n/server/GwtLocaleFactoryImpl.java Tue Mar 31 09:48:28 2009 @@ -68,6 +68,10 @@ // one is used instead to preserved cached data structures. private Map<GwtLocaleImpl, GwtLocaleImpl> instanceCache = new HashMap<GwtLocaleImpl, GwtLocaleImpl>(); + public void clear() { + instanceCache.clear(); + } + public GwtLocale fromComponents(String language, String script, String region, String variant) { if (language != null && language.length() == 0) { --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---