/* * @test /nodynamiccopyright/ * @bug 4897892 * @summary cast to parameterized type is accepted although it should be rejected * @author gafter * * @compile/ref=AmbiguousCast.out -XDrawDiagnostics -Xlint:unchecked AmbiguousCast.java */ class Test { private static class GenericWrapper { private Elem theObject; public GenericWrapper(Elem arg) { theObject = arg; } public GenericWrapper (GenericWrapper other) { this.theObject = other.theObject; } public String toString() { return theObject.toString(); } } private static GenericWrapper method (Object wrappedString) { return (GenericWrapper) wrappedString; } public static void main(String[] args) { System.out.println(method(new GenericWrapper("abc"))); System.out.println(method(new GenericWrapper(new Exception()))); } }