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

DEBUG CODE GETS COMPILED EVEN THOUGH THE DEBUG FLAG SET TO FALSE.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.3.0
    • 1.1.1
    • tools
    • beta
    • generic
    • generic



      Name: clC74495 Date: 11/17/98


      This enhancement is filed by Java licensee Oracle (#765649).

      The debug code happens in many places in the sun/applet package.
      For example:
      In AppletPanel.java:
      ...
      static boolean debug = false;
      ...
      debug("AppletPanel:CTOR: get list of Jarfiles");
      ...

      static void debug(String s) {
          if (debug)
              System.err.println("AppletPanel:::" + s);
      }

      static void debug(String s, Throwable t) {
          if (debug) {
              debug(s);
          }
      }
      The JVM will call the String functions to assemble the strings and call
      the appropriate debug function, REGARDLESS whether the boolean debug
      flag is set or not.

      The changes would be to test the debug flag first before calling the
      debug method.
      private static boolean final debug = false;
      ...
      if (debug)
      {
          debug("AppletPanel:CTOR: get list of Jarfiles");
      }
      When the debug flag is set to false, since the boolean is defined as
      static final, the javac compiler is smart enough not to compile the
      debug code block, therefore the String method calls are avoided.
      (Review ID: 42910)
      ======================================================================

            iris Iris Clark
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: