google / gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Apache License 2.0
23.13k stars 4.27k forks source link

Remove `AccessController` usage for enum adapter #2704

Closed Marcono1234 closed 3 weeks ago

Marcono1234 commented 3 weeks ago

Purpose

Resolves #2686

Description

See #2686 and the discussion there

This pull request removes the AccessController usage, assuming most users don't depend on it and because it has been marked for removal in the JDK.

Also adds a new test for serialization of a JDK enum class to make sure the adapter works correctly despite strong encapsulation of JDK internals (JEP 403). Though the test is not directly related to the AccessController removal.