mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8217000: Refactor Class::methodToString
Reviewed-by: smarks
This commit is contained in:
parent
3a1f460d19
commit
38cf9d76c8
2 changed files with 25 additions and 22 deletions
|
@ -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 @@ public abstract class Executable extends AccessibleObject
|
|||
|
||||
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 @@ public abstract class Executable extends AccessibleObject
|
|||
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 @@ public abstract class Executable extends AccessibleObject
|
|||
|
||||
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 @@ public abstract class Executable extends AccessibleObject
|
|||
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue