-
Bug
-
Resolution: Duplicate
-
P3
-
7
-
x86
-
windows_7
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
The following program compiles without errors or warnings and does not contain explicit cast operators, but throws CastClassException at runtime, because it manages to pass a String array into a method accepting Integer array.
interface A<T>
{
void foo(T x);
}
interface B<T> extends A<T[]> { }
class C implements B<Integer>
{
static <T extends B<?>> void bar(T x)
{
x.foo(new String[]{"A"});
}
public void foo(Integer[] x)
{
int y = x[0];
}
public static void main(String[] args)
{
bar(new C());
}
}
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
interface A<T>
{
void foo(T x);
}
interface B<T> extends A<T[]> { }
class C implements B<Integer>
{
static <T extends B<?>> void bar(T x)
{
x.foo(new String[]{"A"});
}
public void foo(Integer[] x)
{
int y = x[0];
}
public static void main(String[] args)
{
bar(new C());
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
The following program compiles without errors or warnings and does not contain explicit cast operators, but throws CastClassException at runtime, because it manages to pass a String array into a method accepting Integer array.
interface A<T>
{
void foo(T x);
}
interface B<T> extends A<T[]> { }
class C implements B<Integer>
{
static <T extends B<?>> void bar(T x)
{
x.foo(new String[]{"A"});
}
public void foo(Integer[] x)
{
int y = x[0];
}
public static void main(String[] args)
{
bar(new C());
}
}
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
interface A<T>
{
void foo(T x);
}
interface B<T> extends A<T[]> { }
class C implements B<Integer>
{
static <T extends B<?>> void bar(T x)
{
x.foo(new String[]{"A"});
}
public void foo(Integer[] x)
{
int y = x[0];
}
public static void main(String[] args)
{
bar(new C());
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-7041019 Bogus type-variable substitution with array types with dependencies on accessibility check
- Closed
- relates to
-
JDK-4916567 integrate improved wildcard substitution from CPH
- Resolved
-
JDK-7040883 Compilation error: "length in Array is defined in an inaccessible class or interface"
- Closed
-
JDK-7041019 Bogus type-variable substitution with array types with dependencies on accessibility check
- Closed