From d663b5da10be1f3f33a2729e4b3605fb5e13b4d6 Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Wed, 11 Jan 2023 17:18:39 +0000 Subject: [PATCH] 8299498: Usage of constructors of primitive wrapper classes should be avoided in java.lang API docs Reviewed-by: naoto, darcy, rriggs, mchung, lancea --- .../share/classes/java/lang/ArrayStoreException.java | 4 ++-- src/java.base/share/classes/java/lang/Byte.java | 6 +++--- src/java.base/share/classes/java/lang/Double.java | 4 ++-- src/java.base/share/classes/java/lang/Float.java | 4 ++-- src/java.base/share/classes/java/lang/Integer.java | 10 +++++----- src/java.base/share/classes/java/lang/Long.java | 10 +++++----- src/java.base/share/classes/java/lang/Short.java | 6 +++--- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/java.base/share/classes/java/lang/ArrayStoreException.java b/src/java.base/share/classes/java/lang/ArrayStoreException.java index 118c59706ab..c8388976038 100644 --- a/src/java.base/share/classes/java/lang/ArrayStoreException.java +++ b/src/java.base/share/classes/java/lang/ArrayStoreException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2023, 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 @@ -31,7 +31,7 @@ package java.lang; * following code generates an {@code ArrayStoreException}: *
  *     Object x[] = new String[3];
- *     x[0] = new Integer(0);
+ *     x[0] = Integer.valueOf(0);
  * 
* * @since 1.0 diff --git a/src/java.base/share/classes/java/lang/Byte.java b/src/java.base/share/classes/java/lang/Byte.java index cfd379bf64f..74a42d98a43 100644 --- a/src/java.base/share/classes/java/lang/Byte.java +++ b/src/java.base/share/classes/java/lang/Byte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, 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 @@ -233,7 +233,7 @@ public final class Byte extends Number implements Comparable, Constable { * equal to the value of: * *
- * {@code new Byte(Byte.parseByte(s, radix))} + * {@code Byte.valueOf(Byte.parseByte(s, radix))} *
* * @param s the string to be parsed @@ -262,7 +262,7 @@ public final class Byte extends Number implements Comparable, Constable { * equal to the value of: * *
- * {@code new Byte(Byte.parseByte(s))} + * {@code Byte.valueOf(Byte.parseByte(s))} *
* * @param s the string to be parsed diff --git a/src/java.base/share/classes/java/lang/Double.java b/src/java.base/share/classes/java/lang/Double.java index 7213eb55352..01a0fadaad1 100644 --- a/src/java.base/share/classes/java/lang/Double.java +++ b/src/java.base/share/classes/java/lang/Double.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2023, 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 @@ -1260,7 +1260,7 @@ public final class Double extends Number * of the integer value returned is the same as that of the * integer that would be returned by the call: *
-     *    new Double(d1).compareTo(new Double(d2))
+     *    Double.valueOf(d1).compareTo(Double.valueOf(d2))
      * 
* * @param d1 the first {@code double} to compare diff --git a/src/java.base/share/classes/java/lang/Float.java b/src/java.base/share/classes/java/lang/Float.java index 1bf8f176a88..b4e212434ae 100644 --- a/src/java.base/share/classes/java/lang/Float.java +++ b/src/java.base/share/classes/java/lang/Float.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2023, 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 @@ -1218,7 +1218,7 @@ public final class Float extends Number * of the integer value returned is the same as that of the * integer that would be returned by the call: *
-     *    new Float(f1).compareTo(new Float(f2))
+     *    Float.valueOf(f1).compareTo(Float.valueOf(f2))
      * 
* * @param f1 the first {@code float} to compare. diff --git a/src/java.base/share/classes/java/lang/Integer.java b/src/java.base/share/classes/java/lang/Integer.java index 183e3bb8804..c830ed91045 100644 --- a/src/java.base/share/classes/java/lang/Integer.java +++ b/src/java.base/share/classes/java/lang/Integer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2023, 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 @@ -951,7 +951,7 @@ public final class Integer extends Number * object equal to the value of: * *
- * {@code new Integer(Integer.parseInt(s, radix))} + * {@code Integer.valueOf(Integer.parseInt(s, radix))} *
* * @param s the string to be parsed. @@ -979,7 +979,7 @@ public final class Integer extends Number * object equal to the value of: * *
- * {@code new Integer(Integer.parseInt(s))} + * {@code Integer.valueOf(Integer.parseInt(s))} *
* * @param s the string to be parsed. @@ -1286,14 +1286,14 @@ public final class Integer extends Number * equal to the value of: * *
- * {@code getInteger(nm, new Integer(val))} + * {@code getInteger(nm, Integer.valueOf(val))} *
* * but in practice it may be implemented in a manner such as: * *
      * Integer result = getInteger(nm, null);
-     * return (result == null) ? new Integer(val) : result;
+     * return (result == null) ? Integer.valueOf(val) : result;
      * 
* * to avoid the unnecessary allocation of an {@code Integer} diff --git a/src/java.base/share/classes/java/lang/Long.java b/src/java.base/share/classes/java/lang/Long.java index 7c57f7435a1..6db8f8a96c1 100644 --- a/src/java.base/share/classes/java/lang/Long.java +++ b/src/java.base/share/classes/java/lang/Long.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2023, 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 @@ -1114,7 +1114,7 @@ public final class Long extends Number * to the value of: * *
- * {@code new Long(Long.parseLong(s, radix))} + * {@code Long.valueOf(Long.parseLong(s, radix))} *
* * @param s the string to be parsed @@ -1142,7 +1142,7 @@ public final class Long extends Number * equal to the value of: * *
- * {@code new Long(Long.parseLong(s))} + * {@code Long.valueOf(Long.parseLong(s))} *
* * @param s the string to be parsed. @@ -1509,14 +1509,14 @@ public final class Long extends Number * to the value of: * *
- * {@code getLong(nm, new Long(val))} + * {@code getLong(nm, Long.valueOf(val))} *
* * but in practice it may be implemented in a manner such as: * *
      * Long result = getLong(nm, null);
-     * return (result == null) ? new Long(val) : result;
+     * return (result == null) ? Long.valueOf(val) : result;
      * 
* * to avoid the unnecessary allocation of a {@code Long} object when diff --git a/src/java.base/share/classes/java/lang/Short.java b/src/java.base/share/classes/java/lang/Short.java index 89f55d44d86..fa93dcbccab 100644 --- a/src/java.base/share/classes/java/lang/Short.java +++ b/src/java.base/share/classes/java/lang/Short.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, 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 @@ -177,7 +177,7 @@ public final class Short extends Number implements Comparable, Constable * equal to the value of: * *
- * {@code new Short(Short.parseShort(s, radix))} + * {@code Short.valueOf(Short.parseShort(s, radix))} *
* * @param s the string to be parsed @@ -206,7 +206,7 @@ public final class Short extends Number implements Comparable, Constable * equal to the value of: * *
- * {@code new Short(Short.parseShort(s))} + * {@code Short.valueOf(Short.parseShort(s))} *
* * @param s the string to be parsed