提交 b8af9095 编写于 作者: M malenkov

7087429: Constructor of java.beans.PropertyChangeEvent should declare thrown NPE for null source

Reviewed-by: rupashka
上级 0484b21d
/*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2011, 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
......@@ -25,6 +25,8 @@
package java.beans;
import java.util.EventObject;
/**
* A "PropertyChange" event gets delivered whenever a bean changes a "bound"
* or "constrained" property. A PropertyChangeEvent object is sent as an
......@@ -42,21 +44,21 @@ package java.beans;
* arbitrary set of if its properties have changed. In this case the
* old and new values should also be null.
*/
public class PropertyChangeEvent extends java.util.EventObject {
public class PropertyChangeEvent extends EventObject {
private static final long serialVersionUID = 7042693688939648123L;
/**
* Constructs a new <code>PropertyChangeEvent</code>.
* Constructs a new {@code PropertyChangeEvent}.
*
* @param source the bean that fired the event
* @param propertyName the programmatic name of the property that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
*
* @param source The bean that fired the event.
* @param propertyName The programmatic name of the property
* that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @throws IllegalArgumentException if {@code source} is {@code null}
*/
public PropertyChangeEvent(Object source, String propertyName,
Object oldValue, Object newValue) {
Object oldValue, Object newValue) {
super(source);
this.propertyName = propertyName;
this.newValue = newValue;
......
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7087429
* @summary Tests IllegalArgumentException from the PropertyChangeEvent constructor
* @author Sergey Malenkov
*/
import java.beans.PropertyChangeEvent;
public final class Test7087429 {
public static void main(String[] args) {
try {
new PropertyChangeEvent(null, null, null, null);
}
catch (IllegalArgumentException exception) {
if (exception.getMessage().equals("null source")) {
return;
}
}
throw new Error("IllegalArgumentException expected");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册