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

Solution/Workaround for JDK-8172555

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7u80
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.7.0_80"
      Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Not applicable (OS independent)

      A DESCRIPTION OF THE PROBLEM :
      Apologies for reporting it this way.

      I found a solution/workaround to JDK-8172555 - it'd be great if you could add this as a comment, so future devs won't need to search for this. Unfortunately I don't have an account on the JDK Bug System and can't create one.

      This will save many developers many hours from finding the problem.

      ----

      The given example will work if you wrap it around sun.org.mozilla.javascript.internal.Context-calls as follows:

      Context.enter();
      try {
       eval(...)
       eval(...)
      } finally {
       Context.exit();
      }

      Explanation:
      eval()-Calls internally enter and leave context - and as they are always the only one inside that context, it gets destroyed after the first eval() and the context isn't available anymore to the date-object in the second eval, leading to the NullPointerException described in the bug report. With the explicit Context.enter() beforehand, the Context won't get destroyed after the first call and everything will work.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use code from JDK-8172555 with JDK 1.7 or even JDK 1.8 (when using Rhino)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      See description:

      Apologies for reporting it this way.

      I found a solution/workaround to JDK-8172555 - it'd be great if you could add this as a comment, so future devs won't need to search for this. Unfortunately I don't have an account on the JDK Bug System and can't create one.

      This will save many developers many hours from finding the problem.

      ----

      The given example will work if you wrap it around sun.org.mozilla.javascript.internal.Context-calls as follows:

      Context.enter();
      try {
       eval(...)
       eval(...)
      } finally {
       Context.exit();
      }

      Explanation:
      eval()-Calls internally enter and leave context - and as they are always the only on inside that context, it gets destroyed after the first eval() and the context isn't available anymore to the date-object in the second eval, leading to the NullPointerException described in the bug report. With the explicit Context.enter() beforehand, the Context won't get destroyed after the first call and everything will work.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: