-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b134
-
generic, x86
-
generic, windows_7
-
Verified
The following example was submitted by Neal Gafter as a program that causes javac to get stuck in an infinite loop.
interface I<T> {}
interface A<T> extends I<A<A<T>>>{}
abstract class X {
abstract <T> T foo(T x, T y);
void bar(A<Integer> x, A<String> y){
foo(x, y);
}
}
I verified that the following variations still cause javac to get stuck:
- Replacing the invocation "foo(x,y)" with "Object o = true ? x : y"
- Redefining I and A as classes rather than interfaces
- Replacing "A<Integer>" and "A<String>" with "A<C>" and "A<D>", where C and D are unrelated classes (except by Object)
- Replacing "I<A<A<T>>>" with "I<A<A<A<T>>>>" or "I<A<I<A<T>>>>"
This change prevents the bug:
- Replacing "I<A<A<T>>>" with "I<A<T>>", or eliminating the extends clause entirely
This seems to be a problem with the lub implementation. It's not clear to me why the supertype of A has any impact on the implementation, since the lub of "A<Foo>" and "A<Bar>" is always just "A<? extends lub(Foo,Bar)>". But I know the specification gets there in a convoluted way...
interface I<T> {}
interface A<T> extends I<A<A<T>>>{}
abstract class X {
abstract <T> T foo(T x, T y);
void bar(A<Integer> x, A<String> y){
foo(x, y);
}
}
I verified that the following variations still cause javac to get stuck:
- Replacing the invocation "foo(x,y)" with "Object o = true ? x : y"
- Redefining I and A as classes rather than interfaces
- Replacing "A<Integer>" and "A<String>" with "A<C>" and "A<D>", where C and D are unrelated classes (except by Object)
- Replacing "I<A<A<T>>>" with "I<A<A<A<T>>>>" or "I<A<I<A<T>>>>"
This change prevents the bug:
- Replacing "I<A<A<T>>>" with "I<A<T>>", or eliminating the extends clause entirely
This seems to be a problem with the lub implementation. It's not clear to me why the supertype of A has any impact on the implementation, since the lub of "A<Foo>" and "A<Bar>" is always just "A<? extends lub(Foo,Bar)>". But I know the specification gets there in a convoluted way...
- duplicates
-
JDK-7017834 javac crashes on a small program
- Closed