quick question, have you thought about ...

Gunther raj at gusw.net
Fri Mar 30 16:25:30 UTC 2018


Oh Wizards of Valhalla, I come before you to beseech your guidance.

In 1998 I have pushed to use Java generics when it wasn't yet part of 
standard Java.

Now I am considering the same with your great work.

But I wonder about 2 things, over the 20 years (man, time flies!) of 
working with Java generics, I always wanted two things.


    1. Generic interface extends parameter type:

Example:

public interface ConfidenceInterval<T extends Number> extends T {
    public float getConfidenceLevel();
    public T getLowerBoundary();
    public T getHigherBoundary();
}

And then I can use this, for example given a method

public void setNumber(Number number);

and a

ConfidenceInterval<Number> number;

I could call

setNumber(number);


    2. Run time type checking and reflection with generics?

Example

if(list instanceof List<Integer>)
    ...
else if(list instanceof List<Float>)
    ...

and reflections over the actual type parameters. In short, somehow 
undoing the type erasures.

You may find these naive questions.

Is this something one could ever hope for?

kind regards,
-Gunther




More information about the valhalla-dev mailing list