-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Exclude from a report a part of bytecode that ECJ generates for a String in switch statement and that is hard to cover by tests #496
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
Conversation
b6b1767 to
e2d87f5
Compare
|
@marchof some thoughts about action plan to divide and conquer: Ability to ignore instructions is not that hard to implement as shown here. And this is already valuable enhancement, because opens door for introduction of unconditional (i.e. non-configurable since non-questionable) filters:
The last two can be implemented as a next baby step after this PR. Also opens door at least for experiments with filters that raise some questions:
Filtering of bytecode that ECJ generates for string in Then seems that filtering of Implementation of the last two - are the final step for non-configurable/non-questionable filters IMO. But already will be a very good improvement, especially Java 7 |
| public void visitJumpInsn(final int opcode, final Label label) { | ||
| visitInsn(); | ||
|
|
||
| if (remappedJumps.containsKey(currentNode)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for myself: should be covered by a synthetic unit test, because as of today CI build always uses javac, while this is used only for ECJ
|
After reading JLS and experimenting more with Java 7 |
|
@Godin First of all: Thank your for pushing this forward! It's great to see that the implementation actually nicely fits on top of our existing analyzer infrastructure. Also the filtering interface is really simple, so we can optimize/rework both sides later if we want to. Some remarks though:
Filter activation: I would like to add this very quickly to our master. But I'm not sure whether it should be activated by default. Therefore I propose to add a new method to the Analyzer: We have a registry of all implemented filters. Each filter has an id like the ones in our wiki. But only the activated filters will be considered while analysis. Maven and Ant reporting goals will get a new property for filter ids. So we can aggressively add new filters and ask people to test on real projects. Once we're confident with functionality and performance we can enable them as default. |
|
Another comment about filter implementation: Navigating the ASM tree leads to awkward code. When I did my first experiments I implemented a simple matcher to describe bytecode sequences: Something like this may improve readability of the filters, but we can add this later of course. |
|
@Godin Regarding |
Also I don't see strong connection with a wiki page here. After start of work on implementation test cases in implementation quite quickly uncover things that are not in wiki, making it outdated. So actually I expect that particular wiki pages will eventually be transformed into code/tests/javadocs/documentation, at least in respect to covered cases. Thus what about simple
That's true, however attempt to design declarative matchers before obtaining knowledge of what is really needed for an implementation of particular filter IMO actually increases complexity and error-prone. For example I rewrote completely #500 already 2 times and not excluded that will do one more time. Also there are some imperative logic that is quite hard to express in a declarative way. So let's postpone this till the actual concrete moment of the need to improve readability.
What are the reasons of uncertainty? I decided to implement filter for String in Do you have fears about filter for
I don't like addition of such configuration option. IMO more time will be wasted on explanations about how to use it and maintenance of it, rather than on valuable feedback. Also this will increase amount of information required to investigate/reproduce problems with analysis. In terms of feedback IMO there are far better and simpler options. For example we can ask people to test snapshot version with enabled by default filters. Or even release a version - anyway there is always a possibility to use previous version. And if there are concerns about performance, then I'd better test/work explicitly on this rather than on introduction and explanations of configuration options. |
|
@Godin Ok, I can agree on your points! ;-) What about the Regarding performance we can do a simple Benchmark by e.g. analyzing rt.jar and see the extra cost. Even if we don't make the filtering configurable we need a simple way to do comparisons in future. |
I updated #501 , so that it introduces
There won't be
Agree. So will work on this. |
|
@Godin Thx! Regarding performance tests I was thinking about a separate Maven project which analyzes some bigger artifacts from the Maven repo (e.g. Lucene, Tomcat). |
b60684f to
a7f443a
Compare
|
@marchof yes! 🎉 |
I propose to do one more baby step in story of filtering.
This change most likely requires additional polishing. But before doing so, I'd like to share this change as a proof of concept of a simple way to introduce filter without massive refactoring of analysis.