From fa681a7650c53034d14f071030e8a13069070cc8 Mon Sep 17 00:00:00 2001 From: dholmes Date: Thu, 6 Jun 2013 05:32:26 -0400 Subject: [PATCH] 8015470: Remove redundant calls of toString() on String objects Reviewed-by: dholmes, alanb Contributed-by: Otavio Goncalves --- .../classes/com/sun/jndi/toolkit/dir/SearchFilter.java | 2 +- .../java/lang/annotation/IncompleteAnnotationException.java | 3 +-- src/share/classes/sun/rmi/rmic/Main.java | 6 +++--- src/share/classes/sun/tools/java/MemberDefinition.java | 4 ++-- src/share/classes/sun/tools/jconsole/inspector/Utils.java | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java b/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java index 351e5f26c..4ad7a622b 100644 --- a/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java +++ b/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java @@ -396,7 +396,7 @@ public class SearchFilter implements AttrFilter { // do we need to begin with the first token? if(proto.charAt(0) != WILDCARD_TOKEN && - !value.toString().toLowerCase(Locale.ENGLISH).startsWith( + !value.toLowerCase(Locale.ENGLISH).startsWith( subStrs.nextToken().toLowerCase(Locale.ENGLISH))) { if(debug) { System.out.println("faild initial test"); diff --git a/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java b/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java index dcd4f2a34..1f11b72bc 100644 --- a/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java +++ b/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java @@ -55,8 +55,7 @@ public class IncompleteAnnotationException extends RuntimeException { public IncompleteAnnotationException( Class annotationType, String elementName) { - super(annotationType.getName().toString() + - " missing element " + + super(annotationType.getName() + " missing element " + elementName.toString()); this.annotationType = annotationType; diff --git a/src/share/classes/sun/rmi/rmic/Main.java b/src/share/classes/sun/rmi/rmic/Main.java index 2f9c8c8ff..8e0eb3a9a 100644 --- a/src/share/classes/sun/rmi/rmic/Main.java +++ b/src/share/classes/sun/rmi/rmic/Main.java @@ -879,9 +879,9 @@ public class Main implements sun.rmi.rmic.Constants { } String[] args = new String[3]; - args[0] = (arg0 != null ? arg0.toString() : "null"); - args[1] = (arg1 != null ? arg1.toString() : "null"); - args[2] = (arg2 != null ? arg2.toString() : "null"); + args[0] = (arg0 != null ? arg0 : "null"); + args[1] = (arg1 != null ? arg1 : "null"); + args[2] = (arg2 != null ? arg2 : "null"); return java.text.MessageFormat.format(format, (Object[]) args); } diff --git a/src/share/classes/sun/tools/java/MemberDefinition.java b/src/share/classes/sun/tools/java/MemberDefinition.java index c750f1bb6..c970137ed 100644 --- a/src/share/classes/sun/tools/java/MemberDefinition.java +++ b/src/share/classes/sun/tools/java/MemberDefinition.java @@ -256,8 +256,8 @@ class MemberDefinition implements Constants { } String name = this.name.toString(); return name.startsWith(prefixVal) - || name.toString().startsWith(prefixLoc) - || name.toString().startsWith(prefixThis); + || name.startsWith(prefixLoc) + || name.startsWith(prefixThis); } public boolean isAccessMethod() { diff --git a/src/share/classes/sun/tools/jconsole/inspector/Utils.java b/src/share/classes/sun/tools/jconsole/inspector/Utils.java index 0ff44bd60..01279d98a 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/Utils.java +++ b/src/share/classes/sun/tools/jconsole/inspector/Utils.java @@ -352,7 +352,7 @@ public class Utils { result = new Character(value.charAt(0)); } else if (Number.class.isAssignableFrom(Utils.getClass(type))) { result = createNumberFromStringValue(value); - } else if (value == null || value.toString().equals("null")) { + } else if (value == null || value.equals("null")) { // hack for null value result = null; } else { -- GitLab