< prev index next >

src/java.base/share/classes/java/lang/reflect/Parameter.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 157      * @return The modifier flags for this parameter.
 158      */
 159     public int getModifiers() {
 160         return modifiers;
 161     }
 162 
 163     /**
 164      * Returns the name of the parameter.  If the parameter's name is
 165      * {@linkplain #isNamePresent() present}, then this method returns
 166      * the name provided by the class file. Otherwise, this method
 167      * synthesizes a name of the form argN, where N is the index of
 168      * the parameter in the descriptor of the method which declares
 169      * the parameter.
 170      *
 171      * @return The name of the parameter, either provided by the class
 172      *         file or synthesized if the class file does not provide
 173      *         a name.
 174      */
 175     public String getName() {
 176         // Note: empty strings as parameter names are now outlawed.
 177         // The .equals("") is for compatibility with current JVM
 178         // behavior.  It may be removed at some point.
 179         if(name == null || name.equals(""))
 180             return "arg" + index;
 181         else
 182             return name;
 183     }
 184 
 185     // Package-private accessor to the real name field.
 186     String getRealName() {
 187         return name;
 188     }
 189 
 190     /**
 191      * Returns a {@code Type} object that identifies the parameterized
 192      * type for the parameter represented by this {@code Parameter}
 193      * object.
 194      *
 195      * @return a {@code Type} object identifying the parameterized
 196      * type of the parameter represented by this object
 197      */
 198     public Type getParameterizedType() {
 199         Type tmp = parameterTypeCache;




 157      * @return The modifier flags for this parameter.
 158      */
 159     public int getModifiers() {
 160         return modifiers;
 161     }
 162 
 163     /**
 164      * Returns the name of the parameter.  If the parameter's name is
 165      * {@linkplain #isNamePresent() present}, then this method returns
 166      * the name provided by the class file. Otherwise, this method
 167      * synthesizes a name of the form argN, where N is the index of
 168      * the parameter in the descriptor of the method which declares
 169      * the parameter.
 170      *
 171      * @return The name of the parameter, either provided by the class
 172      *         file or synthesized if the class file does not provide
 173      *         a name.
 174      */
 175     public String getName() {
 176         // Note: empty strings as parameter names are now outlawed.
 177         // The .isEmpty() is for compatibility with current JVM
 178         // behavior.  It may be removed at some point.
 179         if(name == null || name.isEmpty())
 180             return "arg" + index;
 181         else
 182             return name;
 183     }
 184 
 185     // Package-private accessor to the real name field.
 186     String getRealName() {
 187         return name;
 188     }
 189 
 190     /**
 191      * Returns a {@code Type} object that identifies the parameterized
 192      * type for the parameter represented by this {@code Parameter}
 193      * object.
 194      *
 195      * @return a {@code Type} object identifying the parameterized
 196      * type of the parameter represented by this object
 197      */
 198     public Type getParameterizedType() {
 199         Type tmp = parameterTypeCache;


< prev index next >