changeset 53368:eabbb779d3eb

8217000: Refactor Class::methodToString Reviewed-by: smarks
author darcy
date Tue, 15 Jan 2019 19:10:40 -0800
parents c79189826bbb
children 07c09e65ca0f
files src/java.base/share/classes/java/lang/Class.java src/java.base/share/classes/java/lang/reflect/Executable.java
diffstat 2 files changed, 25 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Tue Jan 15 15:45:39 2019 -0800
+++ b/src/java.base/share/classes/java/lang/Class.java	Tue Jan 15 19:10:40 2019 -0800
@@ -272,8 +272,9 @@
 
             TypeVariable<?>[] typeparms = component.getTypeParameters();
             if (typeparms.length > 0) {
-                sb.append(Stream.of(typeparms).map(Class::typeVarBounds).
-                          collect(Collectors.joining(",", "<", ">")));
+                sb.append(Arrays.stream(typeparms)
+                          .map(Class::typeVarBounds)
+                          .collect(Collectors.joining(",", "<", ">")));
             }
 
             for (int i = 0; i < arrayDepth; i++)
@@ -289,8 +290,9 @@
             return typeVar.getName();
         } else {
             return typeVar.getName() + " extends " +
-                Stream.of(bounds).map(Type::getTypeName).
-                collect(Collectors.joining(" & "));
+                Arrays.stream(bounds)
+                .map(Type::getTypeName)
+                .collect(Collectors.joining(" & "));
         }
     }
 
@@ -3419,8 +3421,9 @@
         StringBuilder sb = new StringBuilder();
         sb.append(getName() + "." + name + "(");
         if (argTypes != null) {
-            sb.append(Stream.of(argTypes).map(c -> {return (c == null) ? "null" : c.getName();}).
-                      collect(Collectors.joining(",")));
+            sb.append(Arrays.stream(argTypes)
+                      .map(c -> (c == null) ? "null" : c.getName())
+                      .collect(Collectors.joining(",")));
         }
         sb.append(")");
         return sb.toString();
--- a/src/java.base/share/classes/java/lang/reflect/Executable.java	Tue Jan 15 15:45:39 2019 -0800
+++ b/src/java.base/share/classes/java/lang/reflect/Executable.java	Tue Jan 15 19:10:40 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, 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
@@ -111,16 +111,13 @@
 
             printModifiersIfNonzero(sb, modifierMask, isDefault);
             specificToStringHeader(sb);
-            sb.append('(');
-
-            sb.append(Stream.of(parameterTypes).map(Type::getTypeName).
-                      collect(Collectors.joining(",")));
-
-            sb.append(')');
-
+            sb.append(Arrays.stream(parameterTypes)
+                      .map(Type::getTypeName)
+                      .collect(Collectors.joining(",", "(", ")")));
             if (exceptionTypes.length > 0) {
-                sb.append(Stream.of(exceptionTypes).map(Type::getTypeName).
-                          collect(Collectors.joining(",", " throws ", "")));
+                sb.append(Arrays.stream(exceptionTypes)
+                          .map(Type::getTypeName)
+                          .collect(Collectors.joining(",", " throws ", "")));
             }
             return sb.toString();
         } catch (Exception e) {
@@ -140,8 +137,9 @@
             return typeVar.getName();
         } else {
             return typeVar.getName() + " extends " +
-                Stream.of(bounds).map(Type::getTypeName).
-                collect(Collectors.joining(" & "));
+                Arrays.stream(bounds)
+                .map(Type::getTypeName)
+                .collect(Collectors.joining(" & "));
         }
     }
 
@@ -153,8 +151,9 @@
 
             TypeVariable<?>[] typeparms = getTypeParameters();
             if (typeparms.length > 0) {
-                sb.append(Stream.of(typeparms).map(Executable::typeVarBounds).
-                          collect(Collectors.joining(",", "<", "> ")));
+                sb.append(Arrays.stream(typeparms)
+                          .map(Executable::typeVarBounds)
+                          .collect(Collectors.joining(",", "<", "> ")));
             }
 
             specificToGenericStringHeader(sb);
@@ -173,8 +172,9 @@
 
             Type[] exceptionTypes = getGenericExceptionTypes();
             if (exceptionTypes.length > 0) {
-                sb.append(Stream.of(exceptionTypes).map(Type::getTypeName).
-                          collect(Collectors.joining(",", " throws ", "")));
+                sb.append(Arrays.stream(exceptionTypes)
+                          .map(Type::getTypeName)
+                          .collect(Collectors.joining(",", " throws ", "")));
             }
             return sb.toString();
         } catch (Exception e) {