Skip to content

Commit

Permalink
8269665: Clean-up toString() methods of some primitive wrappers
Browse files Browse the repository at this point in the history
Reviewed-by: redestad
  • Loading branch information
stsypanov authored and cl4es committed Aug 2, 2021
1 parent 7cc1eb3 commit 72145f3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/java.base/share/classes/java/lang/Boolean.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2021, 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
Expand Down Expand Up @@ -205,7 +205,7 @@ public static Boolean valueOf(String s) {
* @since 1.4
*/
public static String toString(boolean b) {
return b ? "true" : "false";
return String.valueOf(b);
}

/**
Expand All @@ -216,8 +216,9 @@ public static String toString(boolean b) {
*
* @return a string representation of this object.
*/
@Override
public String toString() {
return value ? "true" : "false";
return String.valueOf(value);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/java.base/share/classes/java/lang/Byte.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, 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
Expand Down Expand Up @@ -90,7 +90,7 @@ public final class Byte extends Number implements Comparable<Byte>, Constable {
* @see java.lang.Integer#toString(int)
*/
public static String toString(byte b) {
return Integer.toString((int)b, 10);
return Integer.toString(b);
}

/**
Expand Down Expand Up @@ -436,8 +436,9 @@ public double doubleValue() {
* @return a string representation of the value of this object in
* base&nbsp;10.
*/
@Override
public String toString() {
return Integer.toString((int)value);
return Integer.toString(value);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/lang/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -8657,6 +8657,7 @@ public boolean equals(Object obj) {
*
* @return a string representation of this object.
*/
@Override
public String toString() {
return String.valueOf(value);
}
Expand Down
7 changes: 4 additions & 3 deletions src/java.base/share/classes/java/lang/Short.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, 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
Expand Down Expand Up @@ -89,7 +89,7 @@ public final class Short extends Number implements Comparable<Short>, Constable
* @see java.lang.Integer#toString(int)
*/
public static String toString(short s) {
return Integer.toString((int)s, 10);
return Integer.toString(s);
}

/**
Expand Down Expand Up @@ -441,8 +441,9 @@ public double doubleValue() {
* @return a string representation of the value of this object in
* base&nbsp;10.
*/
@Override
public String toString() {
return Integer.toString((int)value);
return Integer.toString(value);
}

/**
Expand Down

1 comment on commit 72145f3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.