1 Reply Latest reply: Jun 30, 2011 7:47 PM by EJP RSS

    Can weak global references become invalid during code execution?

    user12866708
      Hi,

      Currently I have the following code, imgBuffer is a weak global refernce:

      if(!(*env)->IsSameObject(env, imgBuffer, NULL)) {
      ... use imgBuffer reference
      }

      Is the following code invalid, because the reference could become invalid after the null-check?
      If this is the case, do I need to create a new local reference first, and use that one instead?

      Or are there some guarantees that weak global references aren't collected as long as native code is executed?

      Thanks, Clemens