0

I can run all test and they passed but when i run with coverage i got error

FATAL ERROR in native method: processing of -javaagent 
failedjava.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at 
com.intellij.rt.coverage.main.CoveragePremain.
premain(CoveragePremain.java:66)
... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
at 

com.intellij.rt.coverage.instrumentation.Instrumentator.premain(Instrumentator.j ava:65) ... 11 more

Process finished with exit code 1
Exception in thread "main" 

Why without coverage option they passed but with coverage not? And how can i fix this ?

2 Answers2

0

The java.lang.reflect.InvocationTargetException is occur when underlying method throws the exception. if method which has been invoked/call with reflection API, throwing an exception. and reflection API will wrap exception in to InvocationTargetException which throw by underlying method. for more understanding you can refer below link of stackover flow Question Asked by : user550413 and Answer by many java experts. i think you can get suitable answer on this link.

What could cause java.lang.reflect.InvocationTargetException?

Anshul Sharma
  • 3,432
  • 1
  • 12
  • 17
  • Thank, i came across what happend to me and it was non-ASCII characters in path. –  Aug 16 '17 at 17:13
0

In my case it was casued by non-ASCII characters in Intellij path. The solution is to change directory in Intellij properties:

Workaround:
Add this line -Djava.io.tmpdir=C:\Temp to the idea.exe.vmoptions file (in C:\Program Files\ideaIU-11.1.4\bin)
And make sure the C:\Temp exists.

Source : https://youtrack.jetbrains.com/issue/IDEABKL-5941#u=1401303711495