--- old/test/java/lang/StackWalker/Basic.java 2017-08-31 22:38:29.000000000 -0700 +++ new/test/java/lang/StackWalker/Basic.java 2017-08-31 22:38:28.000000000 -0700 @@ -29,8 +29,10 @@ */ import java.lang.StackWalker.StackFrame; +import java.lang.invoke.MethodType; +import java.util.HashMap; import java.util.List; -import java.util.Objects; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; import static java.lang.StackWalker.Option.*; @@ -74,6 +76,29 @@ found); } + @Test + public static void testMethodSignature() throws Exception { + List frames = new StackBuilder(16, 16).build(); + Map methodTypes = StackBuilder.methodTypes(); + for (StackFrame f : frames) { + MethodType type = methodTypes.get(f.getMethodName()); + if (type != null) { + System.out.format("%s.%s %s%n", f.getClassName(), f.getMethodName(), + f.getDescriptor()); + + if (!f.getDescriptor().equals(type.toMethodDescriptorString())) { + throw new RuntimeException("Expected: " + type.toMethodDescriptorString() + + " got: " + f.getDescriptor()); + } + + if (!f.getMethodType().equals(type)) { + throw new RuntimeException("Expected: " + type + + " got: " + f.getMethodType()); + } + } + } + } + private final int depth; Basic(int depth) { this.depth = depth; @@ -132,7 +157,7 @@ } } - class StackBuilder { + static class StackBuilder { private final int stackDepth; private final int limit; private int depth = 0; @@ -150,15 +175,17 @@ trace("m1"); m2(); } - void m2() { + List m2() { trace("m2"); m3(); + return null; } - void m3() { + int m3() { trace("m3"); - m4(); + m4(null); + return 0; } - void m4() { + void m4(Object o) { trace("m4"); int remaining = stackDepth-depth-1; if (remaining >= 4) { @@ -184,6 +211,15 @@ if (verbose) System.out.format("%2d: %s%n", depth, methodname); } + + static Map methodTypes() throws Exception { + Map methodTypes = new HashMap<>(); + methodTypes.put("m1", MethodType.methodType(void.class)); + methodTypes.put("m2", MethodType.methodType(List.class)); + methodTypes.put("m3",MethodType.methodType(int.class)); + methodTypes.put("m4", MethodType.methodType(void.class, Object.class)); + return methodTypes; + } } }