Jython -> ArrayIndexOutOfBoundsException

Anonymous
2012-06-14
2013-04-24

  • Anonymous
    2012-06-14

    Hello,
    I know I have an exotic setup, but you may be interested anyway…

    In our Eclipse Java project, we import Python classes via Jython (I can paste some source code here if necessary). Now, whenever we measure the code coverage of a JUnit test that uses the Python functions, we get the following output on syserr:

    java.lang.ArrayIndexOutOfBoundsException: 0
        at org.jacoco.agent.rt_9w37ty.core.internal.instr.ProbeVariableInserter.visitFrame(ProbeVariableInserter.java:121)
        at org.jacoco.agent.rt_9w37ty.asm.MethodAdapter.visitFrame(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.tree.FrameNode.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.tree.InsnList.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.tree.MethodNode.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.core.internal.flow.ClassProbesAdapter$1.visitEnd(ClassProbesAdapter.java:117)
        at org.jacoco.agent.rt_9w37ty.asm.ClassReader.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.ClassReader.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.core.instr.Instrumenter.instrument(Instrumenter.java:69)
        at org.jacoco.agent.rt_9w37ty.core.instr.Instrumenter.instrument(Instrumenter.java:82)
        at org.jacoco.agent.rt_9w37ty.CoverageTransformer.transform(CoverageTransformer.java:88)
        at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
        at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:385)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
        at org.python.core.BytecodeLoader$Loader.loadClassFromBytes(BytecodeLoader.java:119)
        at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:37)
        at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:67)
        at org.python.core.imp.createFromPyClass(imp.java:133)
        at org.python.core.imp.loadFromSource(imp.java:505)
        at org.python.core.imp.find_module(imp.java:411)
        at org.python.core.imp.import_next(imp.java:635)
        at org.python.core.imp.import_name(imp.java:746)
        at org.python.core.imp.importName(imp.java:806)
        at org.python.core.ImportFunction.__call__(__builtin__.java:1232)
        at org.python.core.PyObject.__call__(PyObject.java:367)
        at org.python.core.__builtin__.__import__(__builtin__.java:1202)
        at org.python.core.__builtin__.__import__(__builtin__.java:1185)
        at org.python.core.imp.importOne(imp.java:817)
        at org.python.pycode._pyx2.f$0(<string>:1)
        at org.python.pycode._pyx2.call_function(<string>)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1204)
        at org.python.core.Py.exec(Py.java:1248)
        at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:172)
        at my.JythonObjectFactory.createObject(JythonObjectFactory.java:37)
        at my.JythonWrapper.createJythonObject(JythonWrapper.java:9)
        at my.MyTest.processInputOutputTest(MyTest.java:10)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    java.lang.ArrayIndexOutOfBoundsException
    

    Despite this error message, the unit test succeeds, which is good. I just wanted to report the issue because it did not happen before we upgraded the EclEmma Eclipse plugin recently.

    Cheers,
    Hannes

     
  • Hi,

    many thanks for reporting this! I know anything is created dynamically, but is there any chance to get the class file in question as a file? Otherwise: Could you please provide a minimal example and describe steps to reproduce?

    You might open a tracker item.

    Thanks,
    -marc

     

  • Anonymous
    2012-06-15

    I got the same problem when using lombok…
    http://projectlombok.org/features/SneakyThrows.html

    java.lang.ArrayIndexOutOfBoundsException: 0
        at org.jacoco.agent.rt_9w37ty.core.internal.instr.ProbeVariableInserter.visitFrame(ProbeVariableInserter.java:121)
        at org.jacoco.agent.rt_9w37ty.asm.MethodAdapter.visitFrame(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.tree.FrameNode.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.tree.InsnList.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.tree.MethodNode.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.core.internal.flow.ClassProbesAdapter$1.visitEnd(ClassProbesAdapter.java:117)
        at org.jacoco.agent.rt_9w37ty.asm.ClassReader.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.asm.ClassReader.accept(Unknown Source)
        at org.jacoco.agent.rt_9w37ty.core.instr.Instrumenter.instrument(Instrumenter.java:69)
        at org.jacoco.agent.rt_9w37ty.core.instr.Instrumenter.instrument(Instrumenter.java:82)
        at org.jacoco.agent.rt_9w37ty.CoverageTransformer.transform(CoverageTransformer.java:88)
        at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
        at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        at com.consistem.cs4j.customization.bean.CustomizationInterceptor.createInvoker(CustomizationInterceptor.java:122)
        at com.consistem.cs4j.customization.bean.CustomizationInterceptor.intercept(CustomizationInterceptor.java:63)
        at com.consistem.cs4j.customization.bean.CustomizationInterceptorTest.afterInterceptor(CustomizationInterceptorTest.java:240)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:702)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
        at org.testng.TestRunner.privateRun(TestRunner.java:768)
        at org.testng.TestRunner.run(TestRunner.java:617)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
        at org.testng.SuiteRunner.run(SuiteRunner.java:240)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1188)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1113)
        at org.testng.TestNG.run(TestNG.java:1025)
        at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:76)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:161)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:101)
        at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:115)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
    
     
  • Hi,

    I recently did a major rework in the instrumentation strategy of JaCoCo and identified an issue that might be related. The latest JaCoCo trunk build might ix your problem. If you're using EclEmma you can try the latest trunk build from this update site:

      http://download.eclipselab.org/eclemma/trunk/update

    Please let me know whether your scenarios do now run properly with code coverage.

    Best regards,
    -marc