Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6804733
Votes 0
Synopsis javac generates spourious diagnostics for ill-formed type-variable bounds
Category java:compiler
Reported Against
Release Fixed 7(b51)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6677785 , 6192945
Submit Date 12-FEB-2009
Description
Consider the following source:

import java.util.Collection;
class Test<S extends Runnable> extends ArrayList<S> {
    <T extends S & S> void test() {}
}

when compiling it using JDK 7 compiler you get 3 error messages:

TestX.java:3: cyclic inheritance involving S
    <T extends S & S> void test() {}
     ^
TestX.java:3: a type variable may not be followed by other bounds
    <T extends S & S> void test() {}
                   ^
TestX.java:2: type parameter S is not within its bound
class Test<S extends Runnable> extends ArrayList<S> {
                                                 ^
3 errors

Both the first and the last error messages are wrong: there's no cyclic inheritance involving S - only, T's bound is ill-formed. Moreover it's not true that S is not within its bound (the bound of ArrayList's type parameter is Object!).

This affects netbeans IDE badly - as multiple spourious diagnostics are generated (and NB has to patch javac to obtain the correct behavior)
Posted Date : 2009-02-12 14:27:25.0
Work Around
N/A
Evaluation
The spourious diagnostics come from some work I and Peter have been doing for improving type variable attribution in jdk 7. In particular, Peter's fix (6192945) introduced the erroneous 'cyclic inheritance' error messages, while my fix (6677785) introduced the erroneous 'not within bound' message.

The former message is caused by a side-effect in the way in which Check.checkNonCyclic keeps track of already seen type-variables (basically a bound like S & S is seen as cyclic because S is seen twice, which is wrong).

The latter message is cause by the fact that cyclic type-variable bounds are attributed with Type.noType which then causes problems with bound checking (as noType is not a subtype of Object). Since S is erroneously seen as cyclic, its type is erroneosly set to Type.noType which then invalidates the bound checking routine.
Posted Date : 2009-02-12 14:40:00.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang