mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8263763: Synthetic constructor parameters of enum are not considered for annotation indices
Reviewed-by: darcy, jfranck
This commit is contained in:
parent
1ee80e03ad
commit
9dd96257c6
4 changed files with 73 additions and 9 deletions
|
@ -605,9 +605,14 @@ public final class Constructor<T> extends Executable {
|
|||
}
|
||||
|
||||
@Override
|
||||
boolean handleParameterNumberMismatch(int resultLength, int numParameters) {
|
||||
boolean handleParameterNumberMismatch(int resultLength, Class<?>[] parameterTypes) {
|
||||
int numParameters = parameterTypes.length;
|
||||
Class<?> declaringClass = getDeclaringClass();
|
||||
if (declaringClass.isEnum() ||
|
||||
if (declaringClass.isEnum()) {
|
||||
return resultLength + 2 == numParameters &&
|
||||
parameterTypes[0] == String.class &&
|
||||
parameterTypes[1] == int.class;
|
||||
} else if (
|
||||
declaringClass.isAnonymousClass() ||
|
||||
declaringClass.isLocalClass() )
|
||||
return false; // Can't do reliable parameter counting
|
||||
|
|
|
@ -566,17 +566,19 @@ public abstract class Executable extends AccessibleObject
|
|||
Annotation[][] result = parseParameterAnnotations(parameterAnnotations);
|
||||
|
||||
if (result.length != numParameters &&
|
||||
handleParameterNumberMismatch(result.length, numParameters)) {
|
||||
Annotation[][] tmp = new Annotation[result.length+1][];
|
||||
// Shift annotations down one to account for an implicit leading parameter
|
||||
System.arraycopy(result, 0, tmp, 1, result.length);
|
||||
tmp[0] = new Annotation[0];
|
||||
handleParameterNumberMismatch(result.length, parameterTypes)) {
|
||||
Annotation[][] tmp = new Annotation[numParameters][];
|
||||
// Shift annotations down to account for any implicit leading parameters
|
||||
System.arraycopy(result, 0, tmp, numParameters - result.length, result.length);
|
||||
for (int i = 0; i < numParameters - result.length; i++) {
|
||||
tmp[i] = new Annotation[0];
|
||||
}
|
||||
result = tmp;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
abstract boolean handleParameterNumberMismatch(int resultLength, int numParameters);
|
||||
abstract boolean handleParameterNumberMismatch(int resultLength, Class<?>[] parameterTypes);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
|
@ -760,7 +760,7 @@ public final class Method extends Executable {
|
|||
}
|
||||
|
||||
@Override
|
||||
boolean handleParameterNumberMismatch(int resultLength, int numParameters) {
|
||||
boolean handleParameterNumberMismatch(int resultLength, Class<?>[] parameterTypes) {
|
||||
throw new AnnotationFormatError("Parameter annotations don't match number of parameters");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue