{"action":"created","issue":{"url":"https://api.github.com/repos/siom79/japicmp/issues/31","labels_url":"https://api.github.com/repos/siom79/japicmp/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/siom79/japicmp/issues/31/comments","events_url":"https://api.github.com/repos/siom79/japicmp/issues/31/events","html_url":"https://github.com/siom79/japicmp/issues/31","id":54727850,"number":31,"title":"Incorrectly reports method changes","user":{"login":"oliverburn","id":6856692,"avatar_url":"https://avatars.githubusercontent.com/u/6856692?v=3","gravatar_id":"","url":"https://api.github.com/users/oliverburn","html_url":"https://github.com/oliverburn","followers_url":"https://api.github.com/users/oliverburn/followers","following_url":"https://api.github.com/users/oliverburn/following{/other_user}","gists_url":"https://api.github.com/users/oliverburn/gists{/gist_id}","starred_url":"https://api.github.com/users/oliverburn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliverburn/subscriptions","organizations_url":"https://api.github.com/users/oliverburn/orgs","repos_url":"https://api.github.com/users/oliverburn/repos","events_url":"https://api.github.com/users/oliverburn/events{/privacy}","received_events_url":"https://api.github.com/users/oliverburn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-19T05:35:42Z","updated_at":"2015-01-20T19:39:12Z","closed_at":null,"body":"I have been testing the `0.2.3` version and have noticed that it does not correctly report changes to methods. I have created a [repository](https://bitbucket.org/ojburn/japicmp-bugs/overview) for demonstrating the problems I am seeing. To reproduce:\r\n\r\n    git clone https://ojburn@bitbucket.org/ojburn/japicmp-bugs.git\r\n    cd japicmp-bugs/method-changes\r\n    ./gradlew jar cmp\r\n\r\nThe first problem is changing the method `compareTo` from:\r\n\r\n    public class MethodAnnotations implements Comparable<String>\r\n    {\r\n        @Override\r\n        public int compareTo(String o)\r\n        {\r\n            return 0;\r\n        }\r\n    }\r\n\r\nto:\r\n\r\n    public class MethodAnnotations\r\n    {\r\n        public int compareTo(String o)\r\n        {\r\n            return 0;\r\n        }\r\n    }\r\n\r\njapicmp reports that the method is both `UNCHANGED` and `REMOVED`\r\n\r\n    Processing samples.MethodAnnotations, change status MODIFIED\r\n        Number methods: 2\r\n            method compareTo, change status UNCHANGED, compat true\r\n            method compareTo, change status REMOVED, compat false\r\n\r\nThe second problem is that when a method return type is changed, `japicmp` is reporting that a method had been `REMOVED` as well as a `NEW` one added. I would suggest that japicmp should report that the method has been `CHANGED`. \r\n\r\nAn example would be the changes in the return types from:\r\n\r\n    public interface InterfaceMethodChanges\r\n    {\r\n        void returnChangedVoidToInt();\r\n        int returnChangedIntToVoid();\r\n        String returnChangedStringToObject();\r\n    }\r\n\r\nto:\r\n\r\n    public interface InterfaceMethodChanges\r\n    {\r\n        int returnChangedVoidToInt();\r\n        void returnChangedIntToVoid();\r\n        Object returnChangedStringToObject();\r\n    }\r\n"},"comment":{"url":"https://api.github.com/repos/siom79/japicmp/issues/comments/70718071","html_url":"https://github.com/siom79/japicmp/issues/31#issuecomment-70718071","issue_url":"https://api.github.com/repos/siom79/japicmp/issues/31","id":70718071,"user":{"login":"siom79","id":3755956,"avatar_url":"https://avatars.githubusercontent.com/u/3755956?v=3","gravatar_id":"","url":"https://api.github.com/users/siom79","html_url":"https://github.com/siom79","followers_url":"https://api.github.com/users/siom79/followers","following_url":"https://api.github.com/users/siom79/following{/other_user}","gists_url":"https://api.github.com/users/siom79/gists{/gist_id}","starred_url":"https://api.github.com/users/siom79/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siom79/subscriptions","organizations_url":"https://api.github.com/users/siom79/orgs","repos_url":"https://api.github.com/users/siom79/repos","events_url":"https://api.github.com/users/siom79/events{/privacy}","received_events_url":"https://api.github.com/users/siom79/received_events","type":"User","site_admin":false},"created_at":"2015-01-20T19:39:12Z","updated_at":"2015-01-20T19:39:12Z","body":"Thank you for reporting these two issues.\r\n\r\nYou may be astonished, but if you take a closer look at the two class files, you will see that there are really two methods for the first class and that there is only one method for the second version of the class ([javap](http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javap.html) is a disassembler that comes with the JDK):\r\n\r\n```\r\n>javap Interfaces$InterfaceComparableRemoved.class\r\nCompiled from \"Interfaces.java\"\r\npublic class japicmp.test.Interfaces$InterfaceComparableRemoved implements java.lang.Comparable<java.lang.String> {\r\n  final japicmp.test.Interfaces this$0;\r\n  public japicmp.test.Interfaces$InterfaceComparableRemoved(japicmp.test.Interfaces);\r\n  public int compareTo(java.lang.String);\r\n  public int compareTo(java.lang.Object);\r\n}\r\n\r\n>javap ..\\..\\japicmp-test-v2\\target\\Interfaces$InterfaceComparableR\r\nemoved.class\r\nCompiled from \"Interfaces.java\"\r\npublic class japicmp.test.Interfaces$InterfaceComparableRemoved {\r\n  final japicmp.test.Interfaces this$0;\r\n  public japicmp.test.Interfaces$InterfaceComparableRemoved(japicmp.test.Interfaces);\r\n  public int compareTo(java.lang.String);\r\n}\r\n\r\n```\r\nThis has something to do with the fact that in Java Generics are not part of the class file ([Type Erasure](http://docs.oracle.com/javase/tutorial/java/generics/erasure.html)). Or to be more precise this is the case of a [bridge method](http://docs.oracle.com/javase/tutorial/java/generics/bridgeMethods.html).\r\n\r\nCurrently I am using [Method Descriptors](http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3) to distinguish different methods within a class. The fact that you can overload a method makes it in theory in some situations impossible to detect whether two methods with the same name and different parameters have changed or have been added/removed. Hence I follow the default diff principle, that I show the changed method as removed and added. But I think it should be possible to leave the return value out of the computation and report such cases as a change.\r\nI will see what I can do...:smirk:"}}