title: MockitoException on mocking a public class java 11
body: <p>I am trying to mock a public class with</p>
  <pre><code>    DevModeUtilityService devModeUtility = Mockito.mock(DevModeUtilityService.class);
  </code></pre>
  <p>I have dependencies as below</p>
  <pre><code>testCompile group: 'org.mockito',name:'mockito-core',version:'2.22.0'
  testCompile group: 'org.powermock', name:'powermock-module-testng', version:'2.0.7'
  testCompile group: 'org.powermock', name:'powermock-api-mockito2', version:'2.0.7'
  </code></pre>
  <pre><code>Source code:
  
  public class DevModeUtilityService {
  
  public String getAuthToken() {
      return null;
  }
  }
  </code></pre>
  <p>Exception that I get is posted below</p>
  <pre><code>org.mockito.exceptions.base.MockitoException: 
  Mockito cannot mock this class: class com.cisco.nls.root.info.local.DevModeUtility.
  </code></pre>
  <p>Mockito can only mock non-private &amp; non-final classes.
  If you're not sure why you're getting this error, please report to the mailing list.</p>
  <p>Java               : 11<br>
  JVM vendor name    : Oracle Corporation<br>
  JVM vendor version : 11.0.2+9<br>
  JVM name           : OpenJDK 64-Bit Server VM<br>
  JVM version        : 11.0.2+9<br>
  JVM info           : mixed mode<br>
  OS name            : Mac OS X<br>
  OS version         : 10.15.6<br></p>
  <pre><code>Underlying exception : java.lang.UnsupportedOperationException: Cannot define class using reflection
      at com.cisco.nls.root.info.local.DevModeUtilityTest.testLoadLocalHttpResponseGet(DevModeUtilityTest.java:74)
      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 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
      at org.testng.TestRunner.privateRun(TestRunner.java:782)
      at org.testng.TestRunner.run(TestRunner.java:632)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
      at org.testng.SuiteRunner.run(SuiteRunner.java:268)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
      at org.testng.TestNG.run(TestNG.java:1064)
      at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
      at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)
  
  Caused by: java.lang.UnsupportedOperationException: Cannot define class using reflection
      at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Unavailable.defineClass(ClassInjector.java:821)
      at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.inject(ClassInjector.java:185)
      at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:187)
      at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79)
      at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4376)
      at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:94)
      at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
      at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
      at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:138)
      at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:346)
      at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:161)
      at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:355)
      at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
      at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
      at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
      at org.powermock.api.mockito.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:50)
      at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
      at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63)
      at org.mockito.Mockito.mock(Mockito.java:1729)
      at org.mockito.Mockito.mock(Mockito.java:1642)
      ... 24 more
  
  Caused by: java.lang.IllegalArgumentException: Unknown Java version: 11
      at net.bytebuddy.ClassFileVersion.ofJavaVersion(ClassFileVersion.java:135)
      at net.bytebuddy.ClassFileVersion$VersionLocator$ForJava9CapableVm.locate(ClassFileVersion.java:337)
      at net.bytebuddy.ClassFileVersion.ofThisVm(ClassFileVersion.java:147)
      at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:301)
      at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:290)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.&lt;clinit&gt;(ClassInjector.java:70)
      at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:184)
      ... 41 more
  WARNING: An illegal reflective access operation has occurred
  WARNING: Illegal reflective access by org.powermock.reflect.internal.WhiteboxImpl (file:/Users/sarmuru2/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-reflect/1.7.4/a484263077a371165c2fa96aa52935cd580a3e3c/powermock-reflect-1.7.4.jar) to method java.lang.Object.finalize()
  WARNING: Please consider reporting this to the maintainers of org.powermock.reflect.internal.WhiteboxImpl
  WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
  WARNING: All illegal access operations will be denied in a future release
  </code></pre>