-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide Context Information when Exception happen in Analyzer or Instrumenter #104
Conversation
This typically happens for invalid class files. Do you apply any post processing to your class files? Are you using Java 8 (not yet supported by JaCoCo)? To track this down you can privately send me a class file which has this problem (source not required). |
Let's begin with the fact that JaCoCo doesn't report which class file it has the problem with. I am not using any post processing or Java 8. As far as I know, all class files are being produced by javac 7u21. How do I find out which class file is at fault? Can you add logging for this if it doesn't already exist? |
Unfortunately there is no way to log the class name. Internally JaCoCo works on InputStreams only. If the class file can't be parsed at all we even don't now it's name... The only way to find the problematic file is to narrow it down with the includes configuration. |
Marc, You could log the filename at org.jacoco.core.analysis.Analyzer line 183. Please produce a SNAPSHOT build with this extra log and I will test it for you. |
@cowwoc I'm wondering why you can't do build with such modification by yourself? And this might be a good opportunity to contribute to the project (pull-requests exactly for this) ;) |
We don't do any logging in the JaCoCo core yet and I don't want to introduce this. Also the proposal of @cowwoc only works for the specific case that a java.io.File instance which actually is a class file is passed to the API. InputStreams and JARs will not get proper logging. Instead of logging I would rather propose to wrap such exceptions in a exception which provides context information. |
Guys, You're making this a lot more complicated than it needs to be. The specific stack-trace I reported uses java.io.File so logging (or throwing an exception) will work just fine. Everyone has a different level of contribution they're able to provide and at this point this is as far as I can go. Please understand, I'm active in many open-source projects and I don't have the mental bandwidth to sink my teeth into another one at this time :) |
@cowwoc Sorry for appearing too complicated here. Please also understand that JaCoCo is basically a library used in quite a few integrations. That's why I'm a bit conservative about introducing code which helps in specific situation only and makes the APIs inconsistent. Any chance that you build a local version with additional logging? Alternatively I can do this for you, in this case you need to install the artifact in your local repo manually. In parallel I try to find a way to provide more meaningful exceptions. |
@cowwoc No need to sink teeth ;) The only purpose of my comment was to highlight the fact that you can quickly build JaCoCo locally ( git clone ... && mvn install ) with logging at org.jacoco.core.analysis.Analyzer line 183 (as proposed by you) to find the class, which causes exception, and which was requested by @marchof in first comment. Right now this is a best way to find root cause of exception, instead of waiting implementation of logging. And if this cause is on JaCoCo side, then maybe it will be fixed even before introduction of logging. And indeed - sorry, but we are very careful about API changes (what was treated as over-complication by you). |
The problem was caused by Findbugs referencing XOM 1.0 which references icu4j 2.6.1 which contains an invalid class format: http://icu-project.org/trac/ticket/6505 ... This was fixed in icu4j 2.8. I worked around the problem by forcing Findbugs to use a newer version of icu4j. Please convert this issue into a feature request for logging the source (JAR or class path) when an exception is thrown. |
@cowwoc why jacoco is analyzing icu4j 2.6.1 jar/package ? My question is: why your include rules does not limit which classes jacoco should analyze? |
@andrioli Honestly, I didn't think about it until you mentioned it. Most Jacoco documentation floating around the web didn't mention . I assumed that jacoco was smart enough to only pick up my main project's class files but obviously it can't perform miracles. Logging could have helped a little here too. Currently all I see is: [jacoco:report] and that's it. On a side-note, what's the difference between for prepare-agent and report? I tried only applying to "prepare-agent" but "report" ended up generating reports for other classes not included in "prepare-agent". I was expecting the report to only contain instrumented classes. |
@cowwoc The basic idea of JaCoCo is to simply collect execution information for all non-system classes loaded to the VM. At report generation time you decide what the scope of your report should be. In the HTML report there is a link in the top right corner "Sessions". It lists all classes which have been loaded. |
@marchof is there any value to reporting on non-instrumented classes? If not, shouldn't report's be a subset of prepare-agent's ? |
@cowwoc Instrumentation with the JaCoCo agents happens on-the-fly, i.e. only classes which are loaded during test execution get instrumented. In the report you typically want to see all classes under test to detect classes missed at all. Talking about configuration of Maven goals: Except for specific technical limitations there is no reason to configure any includes/excludes at all for prepare-agent. We could consider using a separate config for the agent. |
Analyzer and Instrumenter now expect a resource name parameter to provide better messages in case of internal errors.
Java Code Coverage Tools » jacoco #71 SUCCESS |
Provide context information when exceptions happen in Analyzer or Instrumenter
Hi,
I consistently get the following exception when running Jacoco against my (commercial) project. What can I do to help you correct this bug without sending you my source code? Can you add more logging and have me re-run the operation?