Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8269665: Clean-up toString() methods of some primitive wrappers #4633

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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
@@ -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);
}

/**
@@ -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);
}

/**
@@ -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
@@ -90,7 +90,7 @@
* @see java.lang.Integer#toString(int)
*/
public static String toString(byte b) {
return Integer.toString((int)b, 10);
return Integer.toString(b);

This comment has been minimized.

@cl4es

cl4es Aug 2, 2021
Member

This change makes sense given the evidence that the radix tests in Integer.toString(int, int) are not elided. Same for the equivalent change in Short.java.

}

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

/**
@@ -8656,6 +8656,7 @@ public boolean equals(Object obj) {
*
* @return a string representation of this object.
*/
@Override
public String toString() {
return String.valueOf(value);
}
@@ -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
@@ -89,7 +89,7 @@
* @see java.lang.Integer#toString(int)
*/
public static String toString(short s) {
return Integer.toString((int)s, 10);
return Integer.toString(s);
}

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

/**