Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 97259

Summary: [infer type arguments] produces name clashes
Product: [Eclipse Project] JDT Reporter: Dirk Baeumer <dirk_baeumer>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Dirk Baeumer CLA 2005-05-30 10:21:40 EDT
RC1

- check out org.eclipse.core.expressions
- run infer

observe: you have a compile error in PropertyCache:

Severity	Description	Resource	In Folder	Location	Creation Time
2	Name clash: The method removeEldestEntry(Map.Entry<?,?>) of type new
LinkedHashMap<Property,Property>(){} has the same erasure as
removeEldestEntry(Map.Entry<K,V>) of type LinkedHashMap<K,V> but does not
override it	PropertyCache.java
org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions	line 25
May 30, 2005 4:15:29 PM
Comment 1 Dirk Baeumer CLA 2005-06-01 06:45:10 EDT
Markus, we should understand this and try to fix if critical.

Marking as RC2, but depends on your investigation.
Comment 2 Markus Keller CLA 2005-06-09 11:27:54 EDT
This one is hard, i.e. not for 3.1.

Here's the standalone example. The problem is the linking between the type
arguments of new LinkedHashMap(..) and the type arguments for Entry in
removeEldestEntry(..). Would have to store type arguments of the extended class
and connect them to the Entry. The problem is that the link has to go over the
superclass LinkedHashMap<K,V> and its overridden method
#removeEldestEntry(Map.Entry<K,V>), which links the K and V from the extended
LinkedHashMap with the different K and V from the method's parameter Map.Entry.


import java.util.LinkedHashMap;
import java.util.Map.Entry;

class Cache {

    private LinkedHashMap/*<String, Integer>*/fCache;

    public Cache(final int cacheSize) {
        fCache= new LinkedHashMap/*<String, Integer>*/(100, 0.75f, true) {

            private static final long serialVersionUID= 1L;

            protected boolean removeEldestEntry(Entry/*<String, Integer>*/eldest) {
                return size() > cacheSize;
            }
        };
    }

    public void put(String key, Integer value) {
        fCache.put(key, value);
    }

    public Integer get(String key) {
        return (Integer) fCache.get(key);
    }

    public static void main(String... args) {
        Cache cache= new Cache(12);
        cache.put("a", new Integer(13));
        cache.put("a", 14);
        System.out.println();
    }
}
Comment 3 Eclipse Genie CLA 2019-04-03 14:23:16 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.