8223723: j.l.c.MethodTypeDesc.dropParameterTypes throws the undocumented exception: IllegalArgumentException
Reviewed-by: rriggs
This commit is contained in:
parent
0b9afd7a5a
commit
6002c4e426
@ -141,8 +141,8 @@ public interface MethodTypeDesc
|
||||
* @param end the index after the last parameter to remove
|
||||
* @return a {@linkplain MethodTypeDesc} describing the desired method type
|
||||
* @throws IndexOutOfBoundsException if {@code start} is outside the half-open
|
||||
* range {[0, parameterCount)}, or {@code end} is outside the closed range
|
||||
* {@code [0, parameterCount]}
|
||||
* range {@code [0, parameterCount)}, or {@code end} is outside the closed range
|
||||
* {@code [0, parameterCount]}, or if {@code start > end}
|
||||
*/
|
||||
MethodTypeDesc dropParameterTypes(int start, int end);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 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,10 +111,8 @@ final class MethodTypeDescImpl implements MethodTypeDesc {
|
||||
|
||||
@Override
|
||||
public MethodTypeDesc dropParameterTypes(int start, int end) {
|
||||
if (start < 0 || start >= argTypes.length || end < 0 || end > argTypes.length)
|
||||
if (start < 0 || start >= argTypes.length || end < 0 || end > argTypes.length || start > end)
|
||||
throw new IndexOutOfBoundsException();
|
||||
else if (start > end)
|
||||
throw new IllegalArgumentException(String.format("Range (%d, %d) not valid for size %d", start, end, argTypes.length));
|
||||
ClassDesc[] newArgs = new ClassDesc[argTypes.length - (end - start)];
|
||||
System.arraycopy(argTypes, 0, newArgs, 0, start);
|
||||
System.arraycopy(argTypes, end, newArgs, start, argTypes.length - end);
|
||||
|
@ -237,7 +237,7 @@ public class MethodTypeDescTest extends SymbolicDescTest {
|
||||
try {
|
||||
MethodTypeDesc newDesc = mtDesc.dropParameterTypes(1, 0);
|
||||
fail("start index > end index should have failed");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
// good
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user