Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7098413

FindBugs: Result of integer multiplication cast to long

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • jt4.4.1
    • jt4.4.1
    • tools
    • b05
    • b05
    • generic
    • generic
    • Verified

    Description

      ICAST: Result of integer multiplication cast to long (ICAST_INTEGER_MULTIPLY_CAST_TO_LONG)

      This code performs integer multiply and then converts the result to a long, as in:

          long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; }
      If the multiplication is done using long arithmetic, you can avoid the possibility that the result will overflow. For example, you could fix the above code to:
          long convertDaysToMilliseconds(int days) { return 1000L*3600*24*days; }
      or
          static final long MILLISECONDS_PER_DAY = 24L*3600*1000;
          long convertDaysToMilliseconds(int days) { return days * MILLISECONDS_PER_DAY; }


         ICAST: In class com.sun.javatest.exec.BasicSessionControl
      In class com.sun.javatest.exec.BasicSessionControl
      In method com.sun.javatest.exec.BasicSessionControl.getNeedToAutoCheckExcludeList(Parameters)
      At BasicSessionControl.java:[line 460]
      Result of integer multiplication cast to long in com.sun.javatest.exec.BasicSessionControl.getNeedToAutoCheckExcludeList(Parameters)

      Attachments

        Activity

          People

            ersh Mikhail Ershov (Inactive)
            ersh Mikhail Ershov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: