title: Error executing tests in Travis CI with JaCoCo
body: <p>I'm working on a Java proyect and I'm trying to generate some code coverage with JaCoCo. If I run my tests with Maven everything works fine, but my Travis build crashes with this error while trying to run my tests:</p>
  
  <pre><code>-------------------------------------------------------
   T E S T S
  -------------------------------------------------------
  Exception in thread "main" java.lang.reflect.InvocationTargetException
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
      at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
  Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
      at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
      at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
      at org.jacoco.agent.rt.internal_c13123e.PreMain.createRuntime(PreMain.java:55)
      at org.jacoco.agent.rt.internal_c13123e.PreMain.premain(PreMain.java:47)
      ... 6 more
  Caused by: java.lang.NoSuchFieldException: $jacocoAccess
      at java.base/java.lang.Class.getField(Class.java:2000)
      at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
      ... 9 more
  FATAL ERROR in native method: processing of -javaagent failed
  Aborted (core dumped)
  
  Results :
  
  Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
  </code></pre>
  
  <p>My .travis.yml file is (logic is the package in which my tests are stored):</p>
  
  <pre><code>language: java
  after_success:
   - bash &lt;(curl -s https://codecov.io/bash)
  script: 
  - "mvn -Dtest=logic/** test"
  </code></pre>
  
  <p>And my pom.xml file is:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;TFG&lt;/groupId&gt;
      &lt;artifactId&gt;TFG&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;8&lt;/java.version&gt;
          &lt;maven.compiler.source&gt;${java.version}&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;${java.version}&lt;/maven.compiler.target&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;sourceDirectory&gt;src/main/java&lt;/sourceDirectory&gt;
          &lt;testSourceDirectory&gt;src/test/java&lt;/testSourceDirectory&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.8.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.8&lt;/source&gt;
                      &lt;target&gt;1.8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-project-info-reports-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.7&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;dependencyLocationsEnabled&gt;false&lt;/dependencyLocationsEnabled&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.19&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;argLine&gt;${surefireArgLine}&lt;/argLine&gt;
                  &lt;skipTests&gt;${skip.unit.tests}&lt;/skipTests&gt;
              &lt;/configuration&gt;
              &lt;dependencies&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.junit.platform&lt;/groupId&gt;
                      &lt;artifactId&gt;junit-platform-surefire-provider&lt;/artifactId&gt;
                      &lt;version&gt;1.0.0&lt;/version&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
              &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;0.8.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;pre-unit-test&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;prepare-agent&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;destFile&gt;${project.build.directory}/coverage-reports/jacoco-ut.exec&lt;/destFile&gt;
                          &lt;propertyName&gt;surefireArgLine&lt;/propertyName&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;post-unit-test&lt;/id&gt;
                      &lt;phase&gt;test&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;report&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;dataFile&gt;${project.build.directory}/coverage-reports/jacoco-ut.exec&lt;/dataFile&gt;
                          &lt;outputDirectory&gt;${project.reporting.outputDirectory}/jacoco-ut&lt;/outputDirectory&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jfree&lt;/groupId&gt;
              &lt;artifactId&gt;jfreechart&lt;/artifactId&gt;
              &lt;version&gt;1.0.19&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
              &lt;artifactId&gt;itextpdf&lt;/artifactId&gt;
              &lt;version&gt;5.0.6&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;com.gestor&lt;/groupId&gt;
              &lt;artifactId&gt;GestorProblema1maquina&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
              &lt;scope&gt;system&lt;/scope&gt;
              &lt;systemPath&gt;${project.basedir}/lib/GestorProblema1maquina.jar&lt;/systemPath&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
              &lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt;
              &lt;version&gt;5.4.2&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
              &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
              &lt;version&gt;5.4.2&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
              &lt;artifactId&gt;poi&lt;/artifactId&gt;
              &lt;version&gt;4.1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.12&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.woodstock.dependlibs&lt;/groupId&gt;
              &lt;artifactId&gt;jhall&lt;/artifactId&gt;
              &lt;version&gt;2.0&lt;/version&gt;
              &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>