title: Can't get JSON String by using gson.toJson(Element), {module java.base does not "opens java.util" to module com.google.gson]
body: <p>I am developing a minecraft-forge mod that collecst data from the game and converts the whole data as a JSON string. The mod was working fine while my class had just these fields:</p>
  <pre><code>public class MyInfo {
  
      public int ID;
      public float Health;
      public double X;
      public double Y;
      public double Z;
  
      public MyInfo(Player play) {
          ID = play.getId();
          Health = play.getHealth();
          X = play.getX();
          Y = play.getY();
          Z = play.getZ();
      }
  </code></pre>
  <p><code>Player</code> is an instance of <code>net.minecraft.world.entity.player.Player</code> where I can retrieve some data I want.</p>
  <p>It was working fine and the line where I make the JSON string was not facing any issue.</p>
  <pre><code>Gson _Json = new GsonBuilder().setPrettyPrinting().create();
  MyInfo pers = new MyInfo(player);
  String Data = _Json.toJson(pers);
  </code></pre>
  <p><em><strong>THE ISSUE:</strong></em></p>
  <p>As soon as I add an <code>ArrayList</code> field inside my <code>MyInfo</code> class, as I will show now:</p>
  <pre><code>public class MyInfo {
  
      public int ID;
      public float Health;
      public double X;
      public double Y;
      public double Z;
      public ArrayList&lt;MobEffectInstance&gt; ActivePotionEffects;
  
      public MyInfo(Player play) {
          ID = play.getId();
          Health = play.getHealth();
          X = play.getX();
          Y = play.getY();
          Z = play.getZ();
          ActivePotionEffects = new ArrayList&lt;&gt;(play.getActiveEffects()); //the method .getActiveEffects returns a Collection&lt;MobEffectIstance&gt;
      }
  </code></pre>
  <p>The thread encounters an exception as soon as it reaches the line where i use <code>_Json.toJson(pers)</code>, the exception says:</p>
  <pre><code>Exception in thread &quot;Thread-6&quot; java.lang.reflect.InaccessibleObjectException: 
  Unable to make field private final java.util.concurrent.atomic.AtomicLong java.util.Random.seed accessible: module java.base does not &quot;opens java.util&quot; to module com.google.gson
  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
  at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
  at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)        
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)        
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53) 
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)        
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)        
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)        
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53) 
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)        
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)        
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.getAdapter(Gson.java:489)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.toJson(Gson.java:727)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.toJsonTree(Gson.java:628)
  at MC-BOOTSTRAP/com.google.gson@2.8.9/com.google.gson.Gson.toJsonTree(Gson.java:607)
  </code></pre>
  <p>If I instantiate an <code>ArrayList&lt;Integer&gt;</code> in the same class where <code>_Json</code> is instantiated and filling it thanks to FOR loop, and then using <code>toJson()</code>, the problem about accessing to <code>java.lang</code> for <code>Gson</code> doesn't appear</p>
  <p>i.e:</p>
  <pre><code>ArrayList&lt;Integer&gt; numbers = new ArrayList&lt;&gt;();
  for (int i = 0; i &lt; 10; i++) {
         numbers.add(i);
  }
  Gson _Json = new GsonBuilder().setPrettyPrinting().create();
  MyInfo playr = new MyInfo(player); 
  String Data = _Json.toJson(numbers); //&lt;-- not passing *playr* anymore, but *numbers*  
  </code></pre>
  <p><em><strong>EDIT:</strong></em></p>
  <p>I found a workaround, it mainly works for my purpose, and is to have the type <code>MobEffectInstance</code> decomposed into primitive data types (i.e <code>String</code> or <code>Integer</code>) and put these values ​​inside a collection</p>
  <pre><code>public class MyInfo {
  
      public int ID;
      public float Health;
      public double X;
      public double Y;
      public double Z;
      public HashMap&lt;String,Integer&gt; ActivePotionEffects;
  
      public MyInfo(Player play) {
          ID = play.getId();
          Health = play.getHealth();
          X = play.getX();
          Y = play.getY();
          Z = play.getZ();
          ActivePotionEffects = new HashMap&lt;&gt;();
          ArrayList&lt;MobEffectInstance&gt; Temp = new ArrayList&lt;&gt;(play.getActiveEffects());
          for (MobEffectInstance mobEffectInstance : Temp) {
              ActivePotionEffects.put(mobEffectInstance.getDescriptionId(), mobEffectInstance.getDuration());
          }
      }
  </code></pre>