Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3876

S3986 produces an IndexOutOfBoundsException on calls to super

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.1
    • Component/s: None
    • Labels:

      Description

      In a class inheriting from SimpleDateFormat, if the parent constructor is called via super, one might choose to invoke the parameterless constructor.
      In this case, S3986 produces an IndexOutOfBoundsException as it tries to access a method call that has no parameters.

      public class ChildSimpleDateFormat extends SimpleDateFormat {
      
        private static final long serialVersionUID = 1L;
      
        ThreadLocal<SimpleDateFormat> localSimpleDateFormat;
      
        public ChildSimpleDateFormat() {
          super(); // <-- This line will trigger an IndexOutOfBoundsException
        }
      }
      

        Attachments

          Activity

            People

            Assignee:
            dorian.burihabwa Dorian Burihabwa
            Reporter:
            dorian.burihabwa Dorian Burihabwa
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: