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

Field.set() does not set field when target field is final: OK, but no exception

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      class Example {
      private final double x = 1;
      ...
      final Field field = object.getClass().getDeclaredField(identifier);
      field.setAccessible(true);
      field.set(object, value);

      Field is not set but no exception is thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See description

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Some kind of exceptoin
      ACTUAL -
      None.

      ---------- BEGIN SOURCE ----------
      See description
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Make sure the target field is not final

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: