4922835: DOC: Statement javadoc should indicate that target and methodName cannot be null
authormalenkov
Thu, 21 Jan 2010 21:45:00 +0300
changeset 4845 64433d7632f2
parent 4844 68e39b0ed557
child 4846 48f8e6d40dde
4922835: DOC: Statement javadoc should indicate that target and methodName cannot be null Reviewed-by: peterz
jdk/src/share/classes/java/beans/Expression.java
jdk/src/share/classes/java/beans/Statement.java
--- a/jdk/src/share/classes/java/beans/Expression.java	Wed Jan 13 15:40:47 2010 +0900
+++ b/jdk/src/share/classes/java/beans/Expression.java	Thu Jan 21 21:45:00 2010 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc.  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
@@ -51,12 +51,19 @@
     private Object value = unbound;
 
     /**
-     * Creates a new <code>Statement</code> object with a <code>target</code>,
-     * <code>methodName</code> and <code>arguments</code> as per the parameters.
+     * Creates a new {@link Expression} object
+     * for the specified target object to invoke the method
+     * specified by the name and by the array of arguments.
+     * <p>
+     * The {@code target} and the {@code methodName} values should not be {@code null}.
+     * Otherwise an attempt to execute this {@code Expression}
+     * will result in a {@code NullPointerException}.
+     * If the {@code arguments} value is {@code null},
+     * an empty array is used as the value of the {@code arguments} property.
      *
-     * @param target The target of this expression.
-     * @param methodName The methodName of this expression.
-     * @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
+     * @param target  the target object of this expression
+     * @param methodName  the name of the method to invoke on the specified target
+     * @param arguments  the array of arguments to invoke the specified method
      *
      * @see #getValue
      */
@@ -66,16 +73,23 @@
     }
 
     /**
-     * Creates a new <code>Expression</code> object for a method
-     * that returns a result. The result will never be calculated
-     * however, since this constructor uses the <code>value</code>
-     * parameter to set the value property by calling the
-     * <code>setValue</code> method.
+     * Creates a new {@link Expression} object with the specified value
+     * for the specified target object to invoke the  method
+     * specified by the name and by the array of arguments.
+     * The {@code value} value is used as the value of the {@code value} property,
+     * so the {@link #getValue} method will return it
+     * without executing this {@code Expression}.
+     * <p>
+     * The {@code target} and the {@code methodName} values should not be {@code null}.
+     * Otherwise an attempt to execute this {@code Expression}
+     * will result in a {@code NullPointerException}.
+     * If the {@code arguments} value is {@code null},
+     * an empty array is used as the value of the {@code arguments} property.
      *
-     * @param value The value of this expression.
-     * @param target The target of this expression.
-     * @param methodName The methodName of this expression.
-     * @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
+     * @param value  the value of this expression
+     * @param target  the target object of this expression
+     * @param methodName  the name of the method to invoke on the specified target
+     * @param arguments  the array of arguments to invoke the specified method
      *
      * @see #setValue
      */
--- a/jdk/src/share/classes/java/beans/Statement.java	Wed Jan 13 15:40:47 2010 +0900
+++ b/jdk/src/share/classes/java/beans/Statement.java	Thu Jan 21 21:45:00 2010 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc.  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
@@ -69,13 +69,19 @@
     ClassLoader loader;
 
     /**
-     * Creates a new <code>Statement</code> object with a <code>target</code>,
-     * <code>methodName</code> and <code>arguments</code> as per the parameters.
+     * Creates a new {@link Statement} object
+     * for the specified target object to invoke the method
+     * specified by the name and by the array of arguments.
+     * <p>
+     * The {@code target} and the {@code methodName} values should not be {@code null}.
+     * Otherwise an attempt to execute this {@code Expression}
+     * will result in a {@code NullPointerException}.
+     * If the {@code arguments} value is {@code null},
+     * an empty array is used as the value of the {@code arguments} property.
      *
-     * @param target The target of this statement.
-     * @param methodName The methodName of this statement.
-     * @param arguments The arguments of this statement. If <code>null</code> then an empty array will be used.
-     *
+     * @param target  the target object of this statement
+     * @param methodName  the name of the method to invoke on the specified target
+     * @param arguments  the array of arguments to invoke the specified method
      */
     @ConstructorProperties({"target", "methodName", "arguments"})
     public Statement(Object target, String methodName, Object[] arguments) {
@@ -85,27 +91,36 @@
     }
 
     /**
-     * Returns the target of this statement.
+     * Returns the target object of this statement.
+     * If this method returns {@code null},
+     * the {@link #execute} method
+     * throws a {@code NullPointerException}.
      *
-     * @return The target of this statement.
+     * @return the target object of this statement
      */
     public Object getTarget() {
         return target;
     }
 
     /**
-     * Returns the name of the method.
+     * Returns the name of the method to invoke.
+     * If this method returns {@code null},
+     * the {@link #execute} method
+     * throws a {@code NullPointerException}.
      *
-     * @return The name of the method.
+     * @return the name of the method
      */
     public String getMethodName() {
         return methodName;
     }
 
     /**
-     * Returns the arguments of this statement.
+     * Returns the arguments for the method to invoke.
+     * The number of arguments and their types
+     * must match the method being  called.
+     * {@code null} can be used as a synonym of an empty array.
      *
-     * @return the arguments of this statement.
+     * @return the array of arguments
      */
     public Object[] getArguments() {
         return arguments;
@@ -154,6 +169,9 @@
         }
 
         Object[] arguments = getArguments();
+        if (arguments == null) {
+            arguments = emptyArray;
+        }
         // Class.forName() won't load classes outside
         // of core from a class inside core. Special
         // case this method.
@@ -285,7 +303,9 @@
         Object target = getTarget();
         String methodName = getMethodName();
         Object[] arguments = getArguments();
-
+        if (arguments == null) {
+            arguments = emptyArray;
+        }
         StringBuffer result = new StringBuffer(instanceName(target) + "." + methodName + "(");
         int n = arguments.length;
         for(int i = 0; i < n; i++) {