From 4460ea6b35d81fd8a5ad531fb13b506206476b95 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Wed, 12 Mar 2014 08:42:34 -0700 Subject: [PATCH] Test Method.getModifiers() result for proxy methods Change-Id: I2ba3be80ea21c5cfc0e2b9463270e34622c8c92b --- test/044-proxy/expected.txt | 1 + test/044-proxy/src/BasicTest.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/044-proxy/expected.txt b/test/044-proxy/expected.txt index 12df250b9..105d9296f 100644 --- a/test/044-proxy/expected.txt +++ b/test/044-proxy/expected.txt @@ -54,6 +54,7 @@ Proxy interfaces: [interface Quads, interface Colors, interface Trace] Proxy methods: [public final java.lang.String $Proxy1.blob(), public final double $Proxy1.blue(int), public final R0a $Proxy1.checkMe(), public final R0aa $Proxy1.checkMe(), public final R0base $Proxy1.checkMe(), public final void $Proxy1.circle(int), public final boolean $Proxy1.equals(java.lang.Object), public final void $Proxy1.getTrace(), public final int $Proxy1.green(double), public final int $Proxy1.hashCode(), public final int $Proxy1.mauve(java.lang.String), public final int $Proxy1.rectangle(int,int), public final int $Proxy1.red(float), public final int $Proxy1.square(int,int), public final java.lang.String $Proxy1.toString(), public final int $Proxy1.trapezoid(int,double,int), public final void $Proxy1.upCheck() throws java.lang.InterruptedException, public final void $Proxy1.upChuck()] Decl annos: [] Param annos (0) : [] +Modifiers: 17 Dupe threw expected exception Clash threw expected exception Clash2 threw expected exception diff --git a/test/044-proxy/src/BasicTest.java b/test/044-proxy/src/BasicTest.java index ea46f49f2..d4ce71fa1 100644 --- a/test/044-proxy/src/BasicTest.java +++ b/test/044-proxy/src/BasicTest.java @@ -90,6 +90,7 @@ public class BasicTest { Annotation[][] paramAnnos = meth.getParameterAnnotations(); System.out.println("Param annos (" + paramAnnos.length + ") : " + Arrays.deepToString(paramAnnos)); + System.out.println("Modifiers: " + meth.getModifiers()); } static Object createProxy(Object proxyMe) { @@ -244,14 +245,15 @@ class MyInvocationHandler implements InvocationHandler { // invocation of toString() in the print statements below. if (method.getDeclaringClass() == java.lang.Object.class) { //System.out.println("!!! object " + method.getName()); - if (method.getName().equals("toString")) + if (method.getName().equals("toString")) { return super.toString(); - else if (method.getName().equals("hashCode")) + } else if (method.getName().equals("hashCode")) { return Integer.valueOf(super.hashCode()); - else if (method.getName().equals("equals")) + } else if (method.getName().equals("equals")) { return Boolean.valueOf(super.equals(args[0])); - else + } else { throw new RuntimeException("huh?"); + } } if (method.getDeclaringClass() == Trace.class) { @@ -277,10 +279,11 @@ class MyInvocationHandler implements InvocationHandler { } try { - if (true) + if (true) { result = method.invoke(mObj, args); - else + } else { result = -1; + } System.out.println("Success: method " + method.getName() + " res=" + result); } catch (InvocationTargetException ite) { -- 2.11.0