Solved Accessing Fields

Discussion in 'Spigot Plugin Development' started by WAS, May 19, 2017.

  1. WAS


    I am working on a class in response to this post and I am wondering, when I am accessing a field, and doing work. Should I not set access to the field to false after I am done? In the example I saw it's left accessible, and when I search some examples of other people using Field#setAccessible() they, too, were leaving it accessible. Is that really a good idea? I mean surely it can't be all that bad. But just wondering.
  2. The getDeclaredField method has to return a new object each time, exactly because this object has the mutable accessible flag. So there is no need to reset the flag. You can find the full details in this blog post.

    So no, it does not have any impact.
    • Like Like x 1
  3. WAS


    Good read, and find. Thanks.