8280132: Incorrect comparator com.sun.beans.introspect.MethodInfo.MethodOrder

Reviewed-by: prr
This commit is contained in:
Sergey Bylokhov 2022-02-09 01:26:42 +00:00
parent fb17a8ece0
commit 2f46af05ce
2 changed files with 1528 additions and 29 deletions
src/java.desktop/share/classes/com/sun/beans/introspect
test/jdk/java/beans/Introspector

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -98,10 +98,7 @@ final class MethodInfo {
/**
* A comparator that defines a total order so that methods have the same
* name and identical signatures appear next to each others. The methods are
* sorted in such a way that methods which override each other will sit next
* to each other, with the overridden method last - e.g. is Integer getFoo()
* placed before Object getFoo().
* name and identical signatures appear next to each others.
**/
private static final class MethodOrder implements Comparator<Method> {
@ -132,18 +129,7 @@ final class MethodInfo {
}
final Class<?> aret = a.getReturnType();
final Class<?> bret = b.getReturnType();
if (aret == bret) {
return 0;
}
// Super type comes last: Integer, Number, Object
if (aret.isAssignableFrom(bret)) {
return 1;
}
if (bret.isAssignableFrom(aret)) {
return -1;
}
return aret.getName().compareTo(bret.getName());
return aret == bret ? 0 : aret.getName().compareTo(bret.getName());
}
static final MethodOrder instance = new MethodOrder();

File diff suppressed because it is too large Load Diff