Re: Updated State of the Specialization

Timo Kinnunen timo.kinnunen at
Fri Dec 19 22:45:33 UTC 2014


I’m not sure Peeling is necessary. The reason is that the problem it’s trying to solve already exists in the current Java and it has workarounds too. Here’s a demonstration with three ListLike<T> adaptations and the workarounds:

interface SmallList<T> {

public void remove(short position);

public void remove(T element);


interface MediumList<T> {

public void remove(int position);

public void remove(T element);


interface BigList<T> {

public void remove(BigInteger position);

public void remove(T element);


public class Workaround {

@SuppressWarnings({ "rawtypes", "unchecked" })

static void method(SmallList<Short> smallList, MediumList<Integer> mediumList, BigList<BigInteger> bigList) {

smallList.remove((short) 3);

smallList.remove((Short) (short) 3);


mediumList.remove((Integer) 3);

((BigList<?>) bigList).remove(BigInteger.valueOf(3));

((BigList) bigList).remove((Object) BigInteger.valueOf(3));



For the record, none of the workarounds feel “correct” to me, although the int/Integer pair gets close. 

Rather than Peeling, what I think is needed is to streamline overload selection so that the specialized methods are selected whenever possible and the non-specialized methods can be manually selected with extra casts, like this:

smallList.remove((short) 3);


mediumList.remove((int) 3);


bigList.remove((BigInteger) BigInteger.valueOf(3));


Have a nice day,

Sent from Windows Mail

From: Brian Goetz
Sent: ‎Friday‎, ‎December‎ ‎19‎, ‎2014 ‎22‎:‎31
To: valhalla-dev at

I've updated the State of the Specialization here:

The old version is here:

More information about the valhalla-dev mailing list