RFR: 8280035: Use Class.isInstance instead of Class.isAssignableFrom where applicable
Peter Levart
plevart at openjdk.java.net
Mon Feb 21 20:29:54 UTC 2022
On Mon, 17 Jan 2022 08:28:35 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:
>> src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java line 405:
>>
>>> 403: Object res = m.invoke(a, new Object[0]);
>>> 404: if (res instanceof Annotation[]) {
>>> 405: for (Annotation rep : (Annotation[]) m.invoke(a, new Object[0])) {
>>
>> BTW it looks suspicious to have `m.invoke(a, new Object[0])` called again here. Shouldn't it just reuse `res` variable instead?
>
> It looks unnecessary. Please feel free to fix.
Or even use the new pattern matching syntax and remove unnecessary explicit empty array construction:
if (m.invoke(a) instanceof Annotation[] anns) {
for (Annotation rep : anns) {
-------------
PR: https://git.openjdk.java.net/jdk/pull/7061
More information about the serviceability-dev
mailing list