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

Cast with unbounded wildcards with fbounds causes infinite loop in javac

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      javac 1.6.0_26

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      The program copied below should compile, but causes an infinite recursion instead.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the source code given below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should compile withouth problem.
      ACTUAL -
      It produces a stack overflow shown below

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      The system is out of resources.
      Consult the following stack trace for details.
      java.lang.StackOverflowError
              at com.sun.tools.javac.code.Types$1.visitWildcardType(Types.java:98)
              at com.sun.tools.javac.code.Type$WildcardType.accept(Type.java:416)
              at com.sun.tools.javac.code.Types$MapVisitor.visit(Types.java:3270)
              at com.sun.tools.javac.code.Types.upperBound(Types.java:95)
              at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2990)
              at com.sun.tools.javac.code.Types.adapt(Types.java:3020)
              at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2981)
              at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2990)
              at com.sun.tools.javac.code.Types.adapt(Types.java:3020)
      [...]


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class StackOverflow implements AInterface<AClass<?>> {
      @Override
      public void doA(final AInterface<AClass<?>> vm) {
      final StackOverflow cast = (StackOverflow) vm;
      }
      }

      class AClass<T extends Comparable<T>> {}

      interface AInterface<V> {
      void doA(AInterface<V> vm);
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      It is working in Java7.

      If possible, you can change the code to use a specific generic type, that way it will also compile with Java6:

      class StackOverflow<S extends Comparable<S>> implements AInterface<AClass<S>> {
      @Override
      public void doA(final AInterface<AClass<S>> vm) {
      final StackOverflow cast = (StackOverflow) vm;
      }
      }

      class AClass<T extends Comparable<T>> {}

      interface AInterface<V> {
      void doA(AInterface<V> vm);
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kizune Alexander Zuev
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: