JDK-6558545 : Undecidable type system leads to stack overflow
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0,6u27,7,8,9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2007-05-17
  • Updated: 2024-04-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
This crashes the compiler:

class T { }
class N<Z> { }
class C<X> extends N<N<? super C<C<X>>>> {
  N<? super C<T>> cast(C<T> c) { return c; }
}

from http://research.microsoft.com/~akenn/generics/FOOL2007.pdf

Comments
There are several papers which propose "reasonable" restrictions to the type system, at least one of which does seem to be truly reasonable, that restore the decidability of the type system. However, adopting these would require a widespread study of the effects on existing Java code. The alternative is to implement a type checker that is guaranteed to be complete for all well-typed programs, but may diverge on ill-typed ones, which would involve significant changes to the type checker. Both of these are at least JEP-level efforts, and it's questionable whether they could even be done for 9. They obviously cannot be done for 8. A final note: this issue needs to be addressed as part of any effort to reify generics.
23-08-2013