提交 97b7d277 编写于 作者: E emcmanus

6643627: JMX source code includes incorrect Java code

Summary: javac compiler bug accepts incorrect code; JMX code inadvertently has such code
Reviewed-by: dfuchs
上级 ae9e48e3
...@@ -1118,11 +1118,11 @@ public abstract class OpenConverter { ...@@ -1118,11 +1118,11 @@ public abstract class OpenConverter {
final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class; final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class;
Class targetClass = getTargetClass(); Class targetClass = getTargetClass();
Constructor[] constrs = targetClass.getConstructors(); Constructor<?>[] constrs = targetClass.getConstructors();
// Applicable if and only if there are any annotated constructors // Applicable if and only if there are any annotated constructors
List<Constructor> annotatedConstrList = newList(); List<Constructor<?>> annotatedConstrList = newList();
for (Constructor constr : constrs) { for (Constructor<?> constr : constrs) {
if (Modifier.isPublic(constr.getModifiers()) if (Modifier.isPublic(constr.getModifiers())
&& constr.getAnnotation(propertyNamesClass) != null) && constr.getAnnotation(propertyNamesClass) != null)
annotatedConstrList.add(constr); annotatedConstrList.add(constr);
...@@ -1152,7 +1152,7 @@ public abstract class OpenConverter { ...@@ -1152,7 +1152,7 @@ public abstract class OpenConverter {
// Also remember the set of properties in that constructor // Also remember the set of properties in that constructor
// so we can test unambiguity. // so we can test unambiguity.
Set<BitSet> getterIndexSets = newSet(); Set<BitSet> getterIndexSets = newSet();
for (Constructor constr : annotatedConstrList) { for (Constructor<?> constr : annotatedConstrList) {
String[] propertyNames = String[] propertyNames =
constr.getAnnotation(propertyNamesClass).value(); constr.getAnnotation(propertyNamesClass).value();
...@@ -1309,10 +1309,10 @@ public abstract class OpenConverter { ...@@ -1309,10 +1309,10 @@ public abstract class OpenConverter {
} }
private static class Constr { private static class Constr {
final Constructor constructor; final Constructor<?> constructor;
final int[] paramIndexes; final int[] paramIndexes;
final BitSet presentParams; final BitSet presentParams;
Constr(Constructor constructor, int[] paramIndexes, Constr(Constructor<?> constructor, int[] paramIndexes,
BitSet presentParams) { BitSet presentParams) {
this.constructor = constructor; this.constructor = constructor;
this.paramIndexes = paramIndexes; this.paramIndexes = paramIndexes;
......
...@@ -1553,7 +1553,7 @@ class MetaData { ...@@ -1553,7 +1553,7 @@ class MetaData {
private static String[] getConstructorProperties(Class type) { private static String[] getConstructorProperties(Class type) {
String[] names = null; String[] names = null;
int length = 0; int length = 0;
for (Constructor constructor : type.getConstructors()) { for (Constructor<?> constructor : type.getConstructors()) {
String[] value = getAnnotationValue(constructor); String[] value = getAnnotationValue(constructor);
if ((value != null) && (length < value.length) && isValid(constructor, value)) { if ((value != null) && (length < value.length) && isValid(constructor, value)) {
names = value; names = value;
...@@ -1563,14 +1563,14 @@ class MetaData { ...@@ -1563,14 +1563,14 @@ class MetaData {
return names; return names;
} }
private static String[] getAnnotationValue(Constructor constructor) { private static String[] getAnnotationValue(Constructor<?> constructor) {
ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class); ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class);
return (annotation != null) return (annotation != null)
? annotation.value() ? annotation.value()
: null; : null;
} }
private static boolean isValid(Constructor constructor, String[] names) { private static boolean isValid(Constructor<?> constructor, String[] names) {
Class[] parameters = constructor.getParameterTypes(); Class[] parameters = constructor.getParameterTypes();
if (names.length != parameters.length) { if (names.length != parameters.length) {
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册