Skip to content

Commit

Permalink
8280132: Incorrect comparator com.sun.beans.introspect.MethodInfo.Met…
Browse files Browse the repository at this point in the history
…hodOrder

Reviewed-by: prr
  • Loading branch information
mrserb committed Feb 9, 2022
1 parent fb17a8e commit 2f46af0
Show file tree
Hide file tree
Showing 2 changed files with 1,528 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -98,10 +98,7 @@ static List<Method> get(Class<?> type) {

/**
* 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> {

Expand Down Expand Up @@ -132,18 +129,7 @@ public int compare(final Method a, final Method b) {
}
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();
Expand Down
Loading

3 comments on commit 2f46af0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb
Copy link
Member Author

@mrserb mrserb commented on 2f46af0 Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 2f46af0 Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb the backport was successfully created on the branch mrserb-backport-2f46af05 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 2f46af05 from the openjdk/jdk repository.

The commit being backported was authored by Sergey Bylokhov on 9 Feb 2022 and was reviewed by Phil Race.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev mrserb-backport-2f46af05:mrserb-backport-2f46af05
$ git checkout mrserb-backport-2f46af05
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev mrserb-backport-2f46af05

Please sign in to comment.