| [GRADLE-2163] AsmBackedClassGenerator.addGetter is not adding convention backed method for get<Property>() for boolean properties Created: 12/Mar/12 Updated: 04/Jan/13 Resolved: 14/Mar/12 | |
| Status: | Resolved | 
| Project: | Gradle | 
| Affects Version/s: | 1.0-milestone-8a | 
| Fix Version/s: | 1.0-rc-1 | 
| Type: | Bug | ||
| Reporter: | Justin Ryan | Assignee: | Luke Daley | 
| Resolution: | Fixed | Votes: | 0 | 
| Description | 
| I was having a problem with Checkstyle.groovy, where the run() method calls getIgnoreFailures(), but it wouldn't pick up the convention value. Which, by the way, points to a flaw in the unit tests, since the test is checking the property while the code is calling the accessor, e.g. assert getIgnoreFailures() == true should be used instead of assert ignoreFailures == true. A little tracking down, showed that while AbstractClassGenerator.generate is looping the metaClass.properties, it gets to a boolean property who's MetaBeanProperty.getter is named "is<Property>" which consequently gets generated with convention support in AsmBackedClassGenerator.addGetter. But Groovyc also generates "get<Property>" for boolean properties (GROOVY-2696), and this method is NOT being created in AsmBackedClassGenerator. Which means the compile is happy since the method signatures match up, yet it's just a plain accessor. And without a good unit test it goes unnoticed. From what I can tell, Groovy generates the "get<Property>" method but doesn't expose it was a getter method via MetaBeanProperty. To work around it, AsmBackedClassGenerator.addGetter should look for this corner case and generate two identical methods. | 
| Comments | 
| Comment by Justin Ryan [ 12/Mar/12 ] | 
| If someone can confirm my logic, I can submit a pull request tomorrow. I should mention that this effects all boolean conventions where the "get<Property>" method call is used. I can vouch that this includes Checkstyle, CodeNarc and PMD. | 
| Comment by Justin Ryan [ 14/Mar/12 ] | 
| Working pull request made: https://github.com/gradle/gradle/pull/72 It includes test and code. |