publicclass IllegalArgumentsTest { staticclass T { public T(int i) {}
publicstaticvoid m(int i) {}
publicvoid m1(String s) {}
}
@Test publicvoid wrongArgumentType() throws ReflectiveOperationException { for (int i = 0; i < 100_000; ++i) { try {
Constructor<T> ctor = T.class.getConstructor(int.class);
ctor.newInstance(int.class); // wrong argument type thrownew RuntimeException("Expected IAE not thrown");
} catch (IllegalArgumentException e) {}
}
for (int i = 0; i < 100_000; ++i) { try {
Method method = T.class.getMethod("m", int.class);
method.invoke(null, int.class); // wrong argument type thrownew RuntimeException("Expected IAE not thrown");
} catch (IllegalArgumentException e) {}
}
}
@Test publicvoid nullArguments() throws ReflectiveOperationException { for (int i = 0; i < 100_000; ++i) { try {
Constructor<T> ctor = T.class.getConstructor(int.class);
ctor.newInstance(new Object[] {null}); thrownew RuntimeException("Expected IAE not thrown");
} catch (IllegalArgumentException e) {}
}
for (int i = 0; i < 100_000; ++i) { try {
Method method = T.class.getMethod("m", int.class);
method.invoke(null, new Object[] {null}); thrownew RuntimeException("Expected IAE not thrown");
} catch (IllegalArgumentException e) {}
}
}
@Test publicvoid illegalArguments() throws ReflectiveOperationException { for (int i = 0; i < 100_000; ++i) { try {
Constructor<T> ctor = T.class.getConstructor(int.class);
ctor.newInstance(new Object[] { 10, 20}); thrownew RuntimeException("Expected IAE not thrown");
} catch (IllegalArgumentException e) {}
}
for (int i = 0; i < 100_000; ++i) { try {
Method method = T.class.getMethod("m", int.class);
method.invoke(null, new Object[] { 10, 20}); thrownew RuntimeException("Expected IAE not thrown");
} catch (IllegalArgumentException e) {}
}
}
@Test publicvoid wrongReceiver() throws ReflectiveOperationException { for (int i = 0; i < 100_000; ++i) { try {
Method method = T.class.getMethod("m1", String.class);
method.invoke(this, "bad receiver"); thrownew RuntimeException("Expected IAE not thrown");
} catch (IllegalArgumentException e) {}
}
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.