Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6435238

Use of an unchecked conversion generates redundant compiler warnings.

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        javac throws duplicate warning messages on compiling the below program:

        import java.util.Iterator;

        public class TestUncheckedWarning {
        public abstract class MyIterator<T> implements Iterator<T> {}

        public abstract class Base<T extends Iterator<?>> {
        protected abstract T foo();
        public abstract Iterable<T> getIterable();
        }

        public abstract class Derived extends Base<MyIterator<Number>> {
        public MyIterator foo() {
        return getIterable().iterator().next();
        }
        }
        }


        javac -Xlint TestUncheckedWarning.java
        TestUncheckedWarning.java:12: warning: foo() in TestUncheckedWarning.Derived overrides fo
        o() in TestUncheckedWarning.Base; return type requires unchecked conversion
        found : TestUncheckedWarning.MyIterator
        required: TestUncheckedWarning.MyIterator<java.lang.Number>
                        public MyIterator foo() {
                                          ^
        TestUncheckedWarning.java:12: warning: foo() in TestUncheckedWarning.Derived overrides fo
        o() in TestUncheckedWarning.Base; return type requires unchecked conversion
        found : TestUncheckedWarning.MyIterator
        required: TestUncheckedWarning.MyIterator<java.lang.Number>
                        public MyIterator foo() {
                                          ^
        2 warnings
        testcase: java_util/generics/phase2/UncheckedConversionTest01

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mcimadamore Maurizio Cimadamore
                  Reporter:
                  duke J. Duke (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: