Skip to content

Failure after instrumentation of code which has stackmap frames and array of more than 7 dimensions #839

@quiquinSP

Description

@quiquinSP

I am in the process of migrating a SW from Java 8 to Java 11. We are using JaCoCo for code coverage and I have found a problem when running the unit tests with JaCoCo tool (using ant).

JaCoCo fails when it instantiates a class that contains a primitive array with more than 8 dimensions. Please do not ask about the motivation of having an 8 dimensional array .... legacy code I have to maintain.

I have reduced the code to the min that reproduces the problem.

  • The execution goes fine when I do not use JaCoCo/EclEmma or I use Java 8
  • I have tested with two different JaCoCo versions , 0.8.2 and 0.8.3

Steps to reproduce

JaCoCo version: tested with 0.8.2 and 0.8.3
Operating system: MacOS HighSierra 10.13.6 and CentOS Linux release 7.5.1804
Tool integration: Ant 1.10.5 and Eclipse EclEmma 3.1.1.201809121651
Java Versions: OpenJDK 11.0.1 and OpenJDK 11.0.2

Use the following piece of code

import org.junit.Test;
public class PrimitiveArrayJacocoTest {

	/**
	 * Test with a boolean array
	 */
	@Test
	public void testBooleanArray() {
		// Just instantiate the class
		new BooleanArrayJacoco();		
	}
	
	/**
	 * Test with an integer array
	 */
	@Test
	public void testIntegerArray() {	
		// Just instantiate the class
		new IntegerArrayJacoco();	
	}
	
	public class BooleanArrayJacoco {
		
		public BooleanArrayJacoco() {
		    
			// Declare a 8 dimension boolean array , if the amount of dimensions is reduced test does not fail. 
		    boolean[][][][][][][][] array = new boolean[12][][][][][][][];
		    int idxDepth0 = 0; 
		    if(array[idxDepth0] == null) {
		    	array[0] = new boolean[4][][][][][][]; // Create new node with 4 array pointers
		    }
		}
		
	}
	
	public class IntegerArrayJacoco {
		
		public IntegerArrayJacoco() {
		    
			// Declare a 8 dimension integer array , if the amount of dimensions is reduced test does not fail. 
		    int[][][][][][][][] array = new int[12][][][][][][][];
		    int idxDepth0 = 0; 
		    if(array[idxDepth0] == null) {
		    	array[0] = new int[4][][][][][][]; // Create new node with 4 array pointers
		    }
		}
		
	}

}

Expected behaviour

JaCoCo is able to run the tests with no failure.

Actual behaviour

Tests fail with the following stack trace

java.lang.NoClassDefFoundError: I
 at gaia.cu1.tools.util.lookuptree.PrimitiveArrayJacocoTest.testIntegerArray(PrimitiveArrayJacocoTest.java:44)
 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.ClassNotFoundException: I
 at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
 at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
 ... 24 more

and running the testBooleanArray .... the same but with different ClassNotFoundException:

java.lang.NoClassDefFoundError: Z
 at gaia.cu1.tools.util.lookuptree.PrimitiveArrayJacocoTest.testBooleanArray(PrimitiveArrayJacocoTest.java:33)
 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.ClassNotFoundException: Z
 at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
 at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
 ... 24 more

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions