title: Migrating from Java 8 to java 11- not able to load jdk.internal.util class (java.lang.NoClassDefFoundError)
body: <p>Migrating from Java 8 to Java 11 open JDK. Getting weird error where one class (java.util.Arrays) from java.base module is not able to access another class called (<code>jdk.internal.util.ArraysSupport</code>) from <code>java.base</code> module. </p>
  
  <p>If I look at module-info of <code>java.base</code> module <code>jdk.internal.util</code> package is not exported. I tried <code>--add-export java.base/jdk.internal.util=ALL-UNNAMED</code> but getting the same error. As <code>--add-export</code> helps in exporting package to another module. Here the problem is one class from the same module is not able to access another one from the same module. Not sure what is wrong here and looking for suggestions.</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class jdk.internal.util.ArraysSupport
          at java.base/java.util.Arrays.equals(Arrays.java:2873)
          at java.base/sun.security.util.ObjectIdentifier.equals(ObjectIdentifier.java:345)
          at java.base/sun.security.pkcs.PKCS7.parse(PKCS7.java:185)
          at java.base/sun.security.pkcs.PKCS7.parse(PKCS7.java:154)
          at java.base/sun.security.pkcs.PKCS7.&lt;init&gt;(PKCS7.java:136)
          at java.base/sun.security.util.SignatureFileVerifier.&lt;init&gt;(SignatureFileVerifier.java:127)
          at java.base/java.util.jar.JarVerifier.processEntry(JarVerifier.java:297)
          at java.base/java.util.jar.JarVerifier.update(JarVerifier.java:230)
          at java.base/java.util.jar.JarFile.initializeVerifier(JarFile.java:757)
          at java.base/java.util.jar.JarFile.ensureInitialization(JarFile.java:1034)
          at java.base/java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69)
          at java.base/jdk.internal.loader.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:870)
          at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:788)
          at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
          at java.base/java.lang.Class.forName0(Native Method)
          at java.base/java.lang.Class.forName(Class.java:315)
          at org.apache.commons.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2124)
          at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2033)
          at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1533)
          at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
          at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
          at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
          at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:371)
          at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:590)
          at com.rbccm.sales.hub.employee.tasklet.SalesHubSQLExecutionTasklet.execute(SalesHubSQLExecutionTasklet.java:45)
          at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
          at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
          at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
          at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:272)
          at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
          at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375)
          at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
          at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145)
          at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
          at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
          at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
          at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:66)
  </code></pre>
  
  <p>Code of <code>SalesHubSQLExecutionTasklet</code> class  is as following</p>
  
  <pre><code>@Override
  public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
      JdbcTemplate jdbcTemplate = new JdbcTemplate(this.getDataSource());
  
      long start = System.currentTimeMillis();
      try {
          if (!StringUtils.isBlank(this.getSql())) {
              if (this.getSql().toUpperCase().startsWith("UPDATE")) {
                  int result = jdbcTemplate.update(this.getSql());
                  LOGGER.info("{} records updated executing SQL [{}]", result, this.getSql());
              }
              else {
                  jdbcTemplate.execute(this.getSql());
              }   
          }
          else if (this.sqls != null &amp;&amp; this.sqls.length &gt; 0) {
              int[] result = jdbcTemplate.batchUpdate(sqls);
              for (int i=0; i&lt;sqls.length; i++) {
                  LOGGER.info("SQL [{}] result [{}].", sqls[i], result[i]);
              }
          }
      }
      catch (Exception ex) {
          LOGGER.error("Error executing SQL [{}]", this.getSql(), ex);
      }
      LOGGER.info("Step {} execute SQL [{}] finished in {} ms.", chunkContext.getStepContext().getStepName(), this.getSql(), (System.currentTimeMillis()-start));
  
      return RepeatStatus.FINISHED;
  }
  </code></pre>
  
  <p>The line no 45 is </p>
  
  <pre><code>int[] result = jdbcTemplate.batchUpdate(sqls);
  </code></pre>
  
  <p>I tried to load with a separate plain class on the Unix box. And it worked fine </p>
  
  <pre><code>Class&lt;?&gt; classToLoad = Class.forName("jdk.internal.util.ArraysSupport");
  </code></pre>
  
  <p>and it loaded the class successfully, so not sure what's wrong here!  </p>