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

sigtest does not check constants in source mode.

XMLWordPrintable

    • 1.3
    • x86
    • windows_nt
    • Verified

      The SigTest should check compile-time constants in source mode.

      Compile-Time constants affects source compatibility.
      If a field, which is a compile-time constant, is changed to become
      a non-compile-time constant, them some sources will not compile against
      the new version, because compile-time constants can be used in
      "case <compile-time constant>:" expressions but regular fields can not.

      For example the following class can be compiled:

      class Other {
          public static final int test = 1;
          public static int getInt() {
              return 1;
          }
      }
      class Test {
          public static final int test = 1;
          public static void main(String[] argv) {
             switch(Other.getInt()) {
             case Other.test: System.out.println("OK"); break;
             }
          }
      }

      But changing of the line
          public static final int test = 1;
      by
          public static final int test = getInt();

      produces the following compile-time error.

        Test.java:11: constant expression required
               case Other.test: System.out.println("OK"); break;
                       ^
        1 error

      The changing of the values does not break source compatibility if the
      fields is still compile-time constant. But we have to check values because
      they are part of the specification.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: