summaryrefslogtreecommitdiff
path: root/test/044-proxy/src/BasicTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/044-proxy/src/BasicTest.java')
-rw-r--r--test/044-proxy/src/BasicTest.java19
1 files changed, 8 insertions, 11 deletions
diff --git a/test/044-proxy/src/BasicTest.java b/test/044-proxy/src/BasicTest.java
index 7f301f667b..c23576c699 100644
--- a/test/044-proxy/src/BasicTest.java
+++ b/test/044-proxy/src/BasicTest.java
@@ -22,7 +22,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
-import java.util.Comparator;
/**
* Do some basic tests.
@@ -54,6 +53,11 @@ public class BasicTest {
Trace trace = (Trace) proxy;
trace.getTrace();
+ // Test the proxy spec: These Object functions are supposed to be given to the handler.
+ int unusedHashCode = ((Object)trace).hashCode();
+ boolean unusedEquals = ((Object)trace).equals(trace);
+ String unusedString = ((Object)trace).toString();
+
try {
shapes.upChuck();
System.out.println("Didn't get expected exception");
@@ -73,15 +77,7 @@ public class BasicTest {
*/
System.out.println("");
Method[] methods = proxy.getClass().getDeclaredMethods();
- Arrays.sort(methods, new Comparator<Method>() {
- public int compare(Method o1, Method o2) {
- int result = o1.getName().compareTo(o2.getName());
- if (result != 0) {
- return result;
- }
- return o1.getReturnType().getName().compareTo(o2.getReturnType().getName());
- }
- });
+ Arrays.sort(methods, new MethodComparator());
System.out.println("Proxy interfaces: " +
Arrays.deepToString(proxy.getClass().getInterfaces()));
System.out.println("Proxy methods: " +
@@ -239,6 +235,8 @@ class MyInvocationHandler implements InvocationHandler {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
+ System.out.println("Invoke " + method);
+
Object result = null;
// Trap Object calls. This is important here to avoid a recursive
@@ -286,7 +284,6 @@ class MyInvocationHandler implements InvocationHandler {
}
}
- System.out.println("Invoke " + method);
if (args == null || args.length == 0) {
System.out.println(" (no args)");
} else {