From b908388e817e9bf30c8558b53efc9b2ddf2bad75 Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Thu, 5 Jan 2023 16:49:23 +0000 Subject: [PATCH] 8298449: Unnecessary Vector usage in MetaData.ProxyPersistenceDelegate Reviewed-by: serb --- .../share/classes/java/beans/MetaData.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/java.desktop/share/classes/java/beans/MetaData.java b/src/java.desktop/share/classes/java/beans/MetaData.java index bdae85f9e7c..ec177f2479e 100644 --- a/src/java.desktop/share/classes/java/beans/MetaData.java +++ b/src/java.desktop/share/classes/java/beans/MetaData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -155,9 +155,8 @@ static final class ProxyPersistenceDelegate extends PersistenceDelegate { // This unappealing hack is not required but makes the // representation of EventHandlers much more concise. java.lang.reflect.InvocationHandler ih = java.lang.reflect.Proxy.getInvocationHandler(p); - if (ih instanceof EventHandler) { - EventHandler eh = (EventHandler)ih; - Vector args = new Vector<>(); + if (ih instanceof EventHandler eh) { + ArrayList args = new ArrayList<>(); args.add(type.getInterfaces()[0]); args.add(eh.getTarget()); args.add(eh.getAction()); @@ -165,7 +164,9 @@ static final class ProxyPersistenceDelegate extends PersistenceDelegate { args.add(eh.getEventPropertyName()); } if (eh.getListenerMethodName() != null) { - args.setSize(4); + if (args.size() == 3) { + args.add(null); + } args.add(eh.getListenerMethodName()); } return new Expression(oldInstance,