mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}
Reviewed-by: shade, rriggs, liach
This commit is contained in:
parent
1c514b34c0
commit
27af19d921
4 changed files with 176 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2024, 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
|
||||
|
@ -266,7 +266,7 @@ public final class Constructor<T> extends Executable {
|
|||
*/
|
||||
@Override
|
||||
public Class<?>[] getParameterTypes() {
|
||||
return parameterTypes.clone();
|
||||
return parameterTypes.length == 0 ? parameterTypes : parameterTypes.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -292,10 +292,9 @@ public final class Constructor<T> extends Executable {
|
|||
*/
|
||||
@Override
|
||||
public Class<?>[] getExceptionTypes() {
|
||||
return exceptionTypes.clone();
|
||||
return exceptionTypes.length == 0 ? exceptionTypes : exceptionTypes.clone();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws GenericSignatureFormatError {@inheritDoc}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2024, 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
|
||||
|
@ -315,7 +315,7 @@ public final class Method extends Executable {
|
|||
*/
|
||||
@Override
|
||||
public Class<?>[] getParameterTypes() {
|
||||
return parameterTypes.clone();
|
||||
return parameterTypes.length == 0 ? parameterTypes: parameterTypes.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,7 +342,7 @@ public final class Method extends Executable {
|
|||
*/
|
||||
@Override
|
||||
public Class<?>[] getExceptionTypes() {
|
||||
return exceptionTypes.clone();
|
||||
return exceptionTypes.length == 0 ? exceptionTypes : exceptionTypes.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue