Date: Sat, 14 Jun 2003 19:26:57 -0400 (EDT)
From: C. Scott Ananian
To: jsr14-prototype-comments@sun.com
Subject: Map.Entry 'loses' parameterization.

Compiling this code:
  package harpoon.Util;
  import harpoon.Util.Collections.AbstractMapEntry;
  import java.util.*;
  public abstract class Default  {
    public static <K,V> Map.Entry<K,V> entry(final K key, final V value) {
        return new AbstractMapEntry<K,V>() {
                public K getKey() { return key; }
                public V getValue() { return value; }
            };
    }
  }
causes these compiler errors:
---
/home/cananian/jsr14_adding_generics-2_0-ea/scripts/javac -d . -g Default.java
Default.java:31: type java.util.Map.Entry does not take parameters
    public static <K,V> Map.Entry<K,V> entry(final K key, final V value) {
                                 ^
Default.java:34: <anonymous harpoon.Util.Default$1> is not abstract and does
 not override abstract method setValue(java.lang.Object) in java.util.Map.Entry
                public V getValue() { return value; }
                         ^
2 errors
---

This "forgetfulness" on the part of the compiler is a *very* common
problem when compiling projects using GJ using a dependency-tracking
system (such as 'make'): if certain 'magic' classes are not included on
the command line as source files (in this example, the AbstractMapEntry
class), then the parameterization of library classes will be 'lost' and a
slew of error messages will result.  The workaround is 'make clean &&
make', which can be very costly for large projects.

Full details are in the attached 'sunbug3.tgz'.  This bug has been present
in various forms since the 1.0 compiler and is my #1 usability problem
with the JSR-14 prototype compiler.  This is the single reason why the
rest of my research group hates me for switching FLEX over to GJ -- they'd
hate me for the other prototype compiler bugs if they did more GJ coding
themselves, but 'failure to build' is what they see most.
 --scott

Cocaine Mossad cryptographic AP Castro Dictionary Mk 48 Nazi World Trade Center 
Yakima Attache Peking genetic supercomputer fissionable for Dummies 
                         ( http://cscott.net/ )

    [ Part 2, "Bug example"  Application/OCTET-STREAM (Name: ]
    [ "sunbug3.tgz")  3.3KB. ]

Valid XHTML 1.0!