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

8273656: Improve java.lang.invoke.MethodType.parameterList() and its usage #5489

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -5882,8 +5882,8 @@ private static void filterReturnValueChecks(MethodType targetType, MethodType fi
BoundMethodHandle result = target.rebind();
LambdaForm lform = result.editor().collectReturnValueForm(filterType.basicType());
MethodType newType = targetType.changeReturnType(filterType.returnType());
if (filterType.parameterList().size() > 1) {
for (int i = 0 ; i < filterType.parameterList().size() - 1 ; i++) {
if (filterType.parameterCount() > 1) {
for (int i = 0 ; i < filterType.parameterCount() - 1 ; i++) {
newType = newType.appendParameterTypes(filterType.parameterType(i));
}
}
@@ -6735,7 +6735,7 @@ private static List<Class<?>> longestParameterList(Stream<MethodHandle> mhs, int
filter(t -> t.parameterCount() > skipSize).
map(MethodType::parameterList).
reduce((p, q) -> p.size() >= q.size() ? p : q).orElse(empty);
return longest.size() == 0 ? empty : longest.subList(skipSize, longest.size());
return longest.isEmpty() ? empty : longest.subList(skipSize, longest.size());
}

private static List<Class<?>> longestParameterList(List<List<Class<?>>> lists) {
@@ -7019,7 +7019,7 @@ private static void whileLoopChecks(MethodHandle init, MethodHandle pred, Method
List<Class<?>> outerList = innerList;
if (returnType == void.class) {
// OK
} else if (innerList.size() == 0 || innerList.get(0) != returnType) {
} else if (innerList.isEmpty() || innerList.get(0) != returnType) {
// leading V argument missing => error
MethodType expected = bodyType.insertParameterTypes(0, returnType);
throw misMatchedTypes("body function", bodyType, expected);
@@ -7349,7 +7349,7 @@ private static void countedLoopChecks(MethodHandle start, MethodHandle end, Meth
List<Class<?>> innerList = bodyType.parameterList();
// strip leading V value if present
int vsize = (returnType == void.class ? 0 : 1);
if (vsize != 0 && (innerList.size() == 0 || innerList.get(0) != returnType)) {
if (vsize != 0 && (innerList.isEmpty() || innerList.get(0) != returnType)) {
// argument list has no "V" => error
MethodType expected = bodyType.insertParameterTypes(0, returnType);
throw misMatchedTypes("body function", bodyType, expected);
@@ -7573,7 +7573,7 @@ private static Class<?> iteratedLoopChecks(MethodHandle iterator, MethodHandle i
List<Class<?>> internalParamList = bodyType.parameterList();
// strip leading V value if present
int vsize = (returnType == void.class ? 0 : 1);
if (vsize != 0 && (internalParamList.size() == 0 || internalParamList.get(0) != returnType)) {
if (vsize != 0 && (internalParamList.isEmpty() || internalParamList.get(0) != returnType)) {
// argument list has no "V" => error
MethodType expected = bodyType.insertParameterTypes(0, returnType);
throw misMatchedTypes("body function", bodyType, expected);
@@ -792,7 +792,7 @@ public Class<?> returnType() {
* @return the parameter types (as an immutable list)
*/
public List<Class<?>> parameterList() {
return Collections.unmodifiableList(Arrays.asList(ptypes.clone()));
return List.of(ptypes);
}

/**