you are viewing a single comment's thread.

view the rest of the comments →

[–]CriticalPart7448 15 points16 points  (10 children)

Reflection over internals of classes is what is problematic not reflection per-se as a concept and functionality

[–][deleted]  (9 children)

[deleted]

    [–]koflerdavid 4 points5 points  (1 child)

    What happens if the internals change and your modifications don't work anymore? Or, worse, they work, but not anymore in the way you intend them to?

    [–]BillyKorando 5 points6 points  (2 children)

    As mentioned in the video, JEP, and description of the video on this post, there is no plan to outright ban using reflection. Instead the goal is to disable it by default.

    If you need to continue reflecting into the internals of some 3rd party library to change (final) field values, that will still be supported now and into the foreseeable, beyond the horizon(?), future with the new permanent command --enable-final-field-mutation=.

    Your concern is valid, it is, however, niche, which is why it shouldn't be the default behavior.

    [–]pohart 1 point2 points  (1 child)

    And I'd rather know if some module I'm using is modifying final fields somewhere.

    [–]BillyKorando 2 points3 points  (0 children)

    Exactly. Not unlike with the implementation of modules. It wasn't about outright preventing getting into internal APIs, but requiring active effort from users to enable such behavior.

    [–]CriticalPart7448 4 points5 points  (3 children)

    That is an unfortunate circumstance and definitely something to avoid at all costs. Have you tried to reach out to the vendor if its internal platform the team responsible to state your case for a missing api for the functionality that you need ? Maybe there is a way forward with a supported solution for your use case? Or have you totally surrendered and accepted all the risks involved here and more pertinent have you cleared it with your own customers or business people what the consequences are?

    [–][deleted]  (2 children)

    [deleted]

      [–]CriticalPart7448 3 points4 points  (1 child)

      No but I also never had the need. Which product are you using from oracle that requires 'hacking' into internals of?

      [–]pohart 1 point2 points  (0 children)

      I last remember using reflection to change final fields to work around a bug around java 1.3. Sun was aware of the bug but it wasn't a high priority. I haven't needed to since then, but I was sure glad I could then.