I think WeakHashMap is what we want since you are looking up validators
based on IFiles.  Just make sure via the WeakHashMap API says that both the
keys and the entries can be garbage collected since we want both to be able
to be garbage collected.

OK I just checked.

In a WeakHashMap on  the key's are garbage collected.  So the entries (the
validators) would still have hard references so them.  SO how about this.
 THe WeakHashMap can use the IFile as the key and for the entry or object
for that key can be a WeakReference<Validator>  So that way both key and
entries can be GC'ed.  THis means that you code needs to make sure that it
fails when either the key or the entry(object) is null.


On Mon, Dec 16, 2013 at 3:22 PM, Kuo Zhang <notifications@github.com> wrote:

> In
> common/plugins/com.liferay.ide.core/src/com/liferay/ide/core/LiferayLanguagePropertiesValidator.java:
>
> > +import org.eclipse.core.resources.IFile;
> > +import org.eclipse.core.resources.IMarker;
> > +import org.eclipse.core.resources.IResource;
> > +import org.eclipse.core.runtime.CoreException;
> > +import org.eclipse.osgi.util.NLS;
> > +
> > +/**
> > + * @author Kuo Zhang
> > + */
> > +public class LiferayLanguagePropertiesValidator
> > +{
> > +    public final static String ID_LANGUAGE_PROPERTIES_ENCODING_NOT_DEFAULT = "language-properties-encoding-not-defalut";
> > +
> > +    public final static String LIFERAY_LANGUAGE_PROPERTIES_MARKER_TYPE = "com.liferay.ide.core.LiferayLanguagePropertiesMarker";
> > +
> > +    private static Map<IFile, LiferayLanguagePropertiesValidator> fileAndValidators = new HashMap<IFile, LiferayLanguagePropertiesValidator>();
>
> Greg, I've investigated the weak reference, but not sure here should I
> just use WeakReference or WeakHashMap?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/gamerson/liferay-ide/pull/372/files#r8360031>
> .
>



-- 
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com