Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-11904

Sling Scripting Core build fails on Java 17 due to Mockito error:module java.base does not "opens java.lang" to unnamed module @2613a93a

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • Scripting Core 2.4.10
    • Scripting
    • None

    Description

      [ERROR] org.apache.sling.scripting.core.impl.bundled.LogWriterTest.testLogWriterCRLFFlush  Time elapsed: 0.077 s  <<< ERROR!
      java.lang.ExceptionInInitializerError
      	at org.mockito.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:167)
      	at org.mockito.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
      	at org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:217)
      	at org.mockito.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
      	at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:117)
      	at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:109)
      	at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:105)
      	at org.mockito.cglib.proxy.Enhancer.<clinit>(Enhancer.java:70)
      	at org.mockito.internal.creation.jmock.ClassImposterizer.createProxyClass(ClassImposterizer.java:85)
      	at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:62)
      	at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:56)
      	at org.mockito.internal.creation.CglibMockMaker.createMock(CglibMockMaker.java:23)
      	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
      	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
      	at org.mockito.Mockito.mock(Mockito.java:1243)
      	at org.mockito.Mockito.mock(Mockito.java:1120)
      	at org.apache.sling.scripting.core.impl.bundled.LogWriterTest.testLogWriterCRLFFlush(LogWriterTest.java:32)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
      	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
      	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
      	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
      	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:364)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:237)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:158)
      	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
      	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
      	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
      Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2613a93a
      	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
      	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
      	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
      	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
      	at org.mockito.cglib.core.ReflectUtils$2.run(ReflectUtils.java:57)
      	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
      	at org.mockito.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:47)
      	... 45 more
      

      Reproduce with mvn clean test -Dtest=LogWriterTest#testLogWriterCRLFFlush. This is similar (but not the same) with SLING-11903, as this module does not use JMock.

      Attachments

        Issue Links

          Activity

            People

              rombert Robert Munteanu
              rombert Robert Munteanu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: