title: Access `sun.security.x509` in JDK 11 without modules?
body: <p>(tl,dr at the end)
  We have a small method that generates self-signed SSL certificate and it obviously depends on <code>sun.security.x509</code>. Currently we are still building it using JDK8 because of that, even though the rest of the codebase (it's only small, single library) is build using JDK11 and run with JVM11.</p>
  
  <p>Unfortunately there aren't replacement in the main JDK, as per (and <code>CertificateFactory</code> has little to nothing with generating certificates, contrary to what it's javadoc states…):</p>
  
  <ul>
  <li><a href="https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8165481" rel="noreferrer">https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8165481</a></li>
  <li><a href="https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8058778" rel="noreferrer">https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8058778</a></li>
  </ul>
  
  <p>One option would be to use BouncyCastle, but that's additional 4MB that we really don't need, especially for such small task so I was pondering ways to access it while </p>
  
  <p>From what I saw, the package and required classes are still package and relevant classes are still there (see <a href="https://github.com/AdoptOpenJDK/openjdk-jdk/tree/master/src/java.base/share/classes/sun/security/x509" rel="noreferrer"><code>sun.security.x509</code> on github</a> but when building it (using maven) I get error:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project: Compilation failure: Compilation failure:
  [ERROR] OldSelfSignedCertificateGenerator.java:[20,25] package sun.security.x509 does not exist
  [ERROR] OldSelfSignedCertificateGenerator.java:[71,45] cannot find symbol
  [ERROR]   symbol:   class X509CertInfo
  [ERROR]   location: class OldSelfSignedCertificateGenerator
  </code></pre>
  
  <p>I was searching a bit and adding:</p>
  
  <pre><code>&lt;arg&gt;--add-exports&lt;/arg&gt;&lt;arg&gt;java.base/sun.security.x509=ALL-UNNAMED&lt;/arg&gt;
  </code></pre>
  
  <p>to <code>maven-compiler-plugin</code> and it somewhat worked - I only get <code>WARNING</code> not regarding <code>sun.security.x509</code> package:</p>
  
  <pre><code>[WARNING] OldSelfSignedCertificateGenerator.java:[20,25] sun.security.x509.AlgorithmId is internal proprietary API and may be removed in a future release
  </code></pre>
  
  <p>BUT! Now it seems I entered (unwillingly!) module system and it complains about access to other, basic Java classes (and one more our dependency):</p>
  
  <pre><code>[ERROR] CertificateUtil.java:[35,17] package java.util.logging is not visible
    (package java.util.logging is declared in module java.logging, but module java.base does not read it)
  </code></pre>
  
  <p>I tried adding <code>java.logging</code> module in the same manner to exports but without much success. It also seems that I would have to convert both this library and it's dependency to module system, which is not really desired.</p>
  
  <p>The question is somewhat related to <a href="https://stackoverflow.com/questions/39143858/how-to-generate-a-self-signed-certificate-using-only-jdk-supported-classes">How to generate a self-signed certificate using only JDK supported classes?</a></p>
  
  <hr>
  
  <p>tl,dr;
  is there a way to compile library using <code>sun.security.x509</code> package under JDK 11 without module system? Some simple switch?</p>