From philip.race at oracle.com Fri Nov 30 01:32:09 2018 From: philip.race at oracle.com (Philip Race) Date: Thu, 29 Nov 2018 17:32:09 -0800 Subject: [12] Review Request: 8211147 Incorrect comparator com.sun.beans.introspect.MethodInfo.MethodOrder In-Reply-To: <220dfd59-2b0a-04ca-480d-47b71ed8564d@oracle.com> References: <220dfd59-2b0a-04ca-480d-47b71ed8564d@oracle.com> Message-ID: <5C009319.1000301@oracle.com> +1 Can you add your notes below to the bug as an evaluation. -phil. On 10/5/18, 7:15 PM, Sergey Bylokhov wrote: > Hello. > Please review the fix for jdk12. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8211147 > Webrev: http://cr.openjdk.java.net/~serb/8211147/webrev.00 > > From the bug description: > The "MethodInfo.MethodOrder" comparator violates its contract > compare(x, y) == -(compare(y, x)) for all (x, y), so sort which use > this comparator can throw IllegalArgumentException. > > > The reason is how this comparator compare the return types of the > methods. The code assumes that if two methods have the same names then > one of the return type should be subtype of another, because of > covariant return types. An example in this bug shows that it is not > necessary correct, which means that this method may always returns > "-1" if two return types are unrelated. > > > Note that this class was particularly copied from > com.sun.jmx.mbeanserver.MethodOrder which looks like has the same bug, > I'll file a separate bug for it. >