Integrating Jacoco with Java 17

1,010 views
Skip to first unread message

Anuj Gupta

unread,
Oct 27, 2023, 2:04:28 AM10/27/23
to JaCoCo and EclEmma Users
HI Team

I have integrated Jacoco with Java 17 but it is giving Array index out of bound error. When I modified the Java version to 11, it is perfectly generating the reports.

Thanks
Anuj Gupta

Marc Hoffmann

unread,
Oct 27, 2023, 2:06:12 AM10/27/23
to JaCoCo and EclEmma Users
Hi Anij,

can you please provide a the full stack trace? JaCoCo supports all Java versions from 5 to 22.

Regards,
-marc



--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/baee81cf-a63c-49f5-834e-acfe564b1390n%40googlegroups.com.

Anuj Gupta

unread,
Oct 27, 2023, 3:08:43 AM10/27/23
to JaCoCo and EclEmma Users
Hi Marc,

I cannot share the whole trace for client confidentiality. But in general, below are the configurations:

Working configuration:

<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
<maven.compiler.version>3.8.1</maven.compiler.version>
<jacoco.version>0.8.3</jacoco.version>


After changing it to

<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.version>3.8.1</maven.compiler.version>
<jacoco.version>0.8.11</jacoco.version>

It is giving below error while creating 

new MockUp<Modelclass>() {
            @Mock
            HttpResponseMessage buildResponse(HttpStatus status, String message) {
                return responseMessage;
            }
 };

[ERROR]   RequestHandlerTest.testExecuteA » ArrayIndexOutOfBounds Index 3847 out of bounds for length 1874
[ERROR]   RequestHandlerTest.testExecuteAWithException » ArrayIndexOutOfBounds Index 3847 out of bounds for length 1874
[ERROR]   RequestHandlerTest.testExecuteB » ArrayIndexOutOfBounds Index 3847 out of bounds for length 1874
[ERROR]   RequestHandlerTest.testExecuteBWithException » ArrayIndexOutOfBounds Index 3847 out of bounds for length 1874
[ERROR]   testRunEmptyBody:52 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   testRunEmptyHeader:73 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   testRunEmptyHeader:73 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   testRunEmpty:125 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   testRunEmpty:125 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   testRunInvalid:156 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   testRunInvalidXml:94 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   testRunInvalidateXml:195 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 146
[ERROR]   mock_env_vars:41 » ArrayIndexOutOfBounds Index 51966 out of bounds for length 165

Marc Hoffmann

unread,
Oct 27, 2023, 3:10:47 AM10/27/23
to JaCoCo and EclEmma Users
Please understand that without a stack trace we cannot investigate this.

If you want us to have a look please create a reproducer you can share.

Regards,
-marc


Evgeny Mandrikov

unread,
Oct 27, 2023, 3:25:37 AM10/27/23
to JaCoCo and EclEmma Users
Hi,

Seems that you use JMockit.
And JMockit doesn't fully support all Java 11+ features for already 4 years - see https://github.com/jmockit/jmockit1/issues/615#issuecomment-501009439

Anuj Gupta

unread,
Oct 27, 2023, 3:47:05 AM10/27/23
to JaCoCo and EclEmma Users
Thanks Evgeny, Any idea what is the ideal alternative for jmockit, is it powe mockito
Reply all
Reply to author
Forward
0 new messages