title: IllegalAccessError when declaring a class for a library package
body: <p>I'm currently working on a maintenance for an undocumented code and have stumbled upon a weird error when running a class in Spring Boot. The code raises an IllegalAccessError on execution, but compiles properly.</p>
  
  <p>It seems that the way the original team tried to access the Kafka Streams' private methods was the "MacGyver way", but I'm unsure about its behaviour since IntelliJ imports the code properly and handles the inheritance as it should (if I declare the class as a local package it highlights saying that the AbstractStream and KTableImpl classes do not exist).</p>
  
  <p>The project is managed with Gradle and it is a micro-service. The execution is made through a Spring Boot and the error raises on startup.</p>
  
  <p>One possible solution was to use Java's Reflection library, but it does not seem the correct approach to solve this error. Maybe a boot setting is wrong?</p>
  
  <pre><code>package org.apache.kafka.streams.kstream.internals;
  
  import org.apache.kafka.streams.kstream.KTable;
  
  public class KTableSpy {
  
    public static &lt;K&gt; String getName(AbstractStream&lt;K&gt; stream) {
      return stream.name;
    }
  
    public static &lt;K, V&gt; void enableSendingOldValues(KTable&lt;K, V&gt; table) {
      ((KTableImpl&lt;K, ?, V&gt;) table).enableSendingOldValues();
    }
  }
  </code></pre>
  
  <p>This class should've worked properly and do not interfere on the service startup. Instead, we have the following error</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AVCompanyStateProjector': Invocation of init method failed; nested exception is java.lang.IllegalAccessError: tried to access method org.apache.kafka.streams.kstream.internals.KTableImpl.enableSendingOldValues()V from class org.apache.kafka.streams.kstream.internals.KTableSpy
  
  </code></pre>