import java.lang.reflect.*;

class Test {
    static class Capturing<T> {
        protected Capturing() {
            ParameterizedType paramT = (ParameterizedType) getClass().getGenericSuperclass();
            Type t = paramT.getActualTypeArguments()[0];

            if (t instanceof TypeVariable) {
                System.out.println("Found expected type");
            } else {
                throw new AssertionError("Unexpected type: " + t);
            }
        }
    }

    static void run(Runnable r) {
        r.run();
    }

    public static <T> void main(String... args) {
        class Local {
            <M> void runTest() {
                run(() -> new Capturing<M>() {});
            }
        }

        new Local().runTest();
    }
} 