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

"double cannot be converted to CAP#1" error

XMLWordPrintable

    • b24
    • 9
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The attached code compiles fine on JDK 8 but fails with "double cannot be converted to CAP#1" error on JDK 10

      REGRESSION : Last worked in version 10.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached Java file


      ---------- BEGIN SOURCE ----------
      /*
       * To change this license header, choose License Headers in Project Properties.
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      package incompatibletypes;

      import javax.swing.JSpinner;
      import javax.swing.SpinnerNumberModel;

      /**
       *
       * @author david
       */
      public class IncompatibleTypes {

          JSpinner exposureShift = new JSpinner(new SpinnerNumberModel(0, -2, 2, 1.0 / 3) {

              @Override
              public Object getPreviousValue() {

                  double nv = ((Double) getValue()) - 1 / 3d;
                  nv = Math.round(nv * 3) / 3d;
                  if (getMinimum().compareTo(nv) <= 0) {
                      return nv;
                  }
                  return getValue();
              }

              @Override
              public Object getNextValue() {
                  double nv = ((Double) getValue()) + 1 / 3d;
                  nv = Math.round(nv * 3) / 3d;
                  if (getMaximum().compareTo(nv) >= 0) {
                      return nv;
                  }
                  return getValue();
              }

          });
          
          
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              System.out.println("Hello world");
          }
          
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found. No matter what argument I feed to compareTo, I get the same error.

      FREQUENCY : always


            vromero Vicente Arturo Romero Zaldivar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: