make Class.getMethod (and getConstructor) more strict about parameter types

This matches the JDK behavior.
This commit is contained in:
Joel Dice
2014-08-28 16:59:06 -06:00
parent 8bd28937df
commit 831c529a98
3 changed files with 37 additions and 1 deletions

View File

@ -260,6 +260,15 @@ public class Reflection {
.getEnclosingMethod().equals
(Reflection.class.getMethod
("main", new Class[] { String[].class })));
Slithy.class.getMethod("tove", Gybe.class);
try {
Slithy.class.getMethod("tove", Bandersnatch.class);
expect(false);
} catch (NoSuchMethodException e) {
// cool
}
}
protected static class Baz {
@ -267,6 +276,16 @@ public class Reflection {
}
}
class Bandersnatch { }
class Gybe extends Bandersnatch { }
class Slithy {
public static void tove(Gybe gybe) {
// ignore
}
}
class Foo {
static {
if (true) throw new MyException();