diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java
index <HASH>..<HASH> 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java
@@ -417,12 +417,15 @@ public class List<A> extends AbstractCollection<A> implements java.util.List<A> 
         return last;
     }
 
+    @SuppressWarnings("unchecked")
     public <Z> List<Z> map(Function<A, Z> mapper) {
-        ListBuffer<Z> buf = new ListBuffer<>();
-        for (A a : this) {
-            buf.add(mapper.apply(a));
+        if (nonEmpty()) {
+            List<Z> tail1 = tail.map(mapper);
+            Z head1 = mapper.apply(head);
+            if (tail1 != tail || head1 != head)
+                return tail1.prepend(head1);
         }
-        return buf.toList();
+        return (List<Z>)this;
     }
 
     @SuppressWarnings("unchecked")
<I>: List.map should return itself if list is unchanged
Summary: Fix List.map to match semantics of old Type.map
Reviewed-by: jlahoda