annotations on FIELD int android.test.anno.FullyNoted.mBar:
@android.test.anno.AnnoFancyField(nombre=fubar)
interface android.test.anno.AnnoFancyField
- aff: @android.test.anno.AnnoFancyField(nombre=fubar) / class $Proxy13
+ aff: @android.test.anno.AnnoFancyField(nombre=fubar) / true
--> nombre is 'fubar'
SimplyNoted.get(AnnoSimpleType) = @android.test.anno.AnnoSimpleType()
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.TreeMap;
public class TestAnnotations {
AnnoFancyField aff;
aff = (AnnoFancyField) f.getAnnotation(AnnoFancyField.class);
if (aff != null) {
- System.out.println(" aff: " + aff + " / " + aff.getClass());
+ System.out.println(" aff: " + aff + " / " + Proxy.isProxyClass(aff.getClass()));
System.out.println(" --> nombre is '" + aff.nombre() + "'");
}
}
(no args)
--- blob
Success: method blob res=mix
-$Proxy1.getTrace null:-1
+$PROXY_CLASS_NAME0$.getTrace null:-1
Invoke public abstract void Shapes.upChuck()
(no args)
Got expected ioobe
Got expected ie
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()]
+Proxy methods: [public final java.lang.String $PROXY_CLASS_NAME0$.blob(), public final double $PROXY_CLASS_NAME0$.blue(int), public final R0a $PROXY_CLASS_NAME0$.checkMe(), public final R0aa $PROXY_CLASS_NAME0$.checkMe(), public final R0base $PROXY_CLASS_NAME0$.checkMe(), public final void $PROXY_CLASS_NAME0$.circle(int), public final boolean $PROXY_CLASS_NAME0$.equals(java.lang.Object), public final void $PROXY_CLASS_NAME0$.getTrace(), public final int $PROXY_CLASS_NAME0$.green(double), public final int $PROXY_CLASS_NAME0$.hashCode(), public final int $PROXY_CLASS_NAME0$.mauve(java.lang.String), public final int $PROXY_CLASS_NAME0$.rectangle(int,int), public final int $PROXY_CLASS_NAME0$.red(float), public final int $PROXY_CLASS_NAME0$.square(int,int), public final java.lang.String $PROXY_CLASS_NAME0$.toString(), public final int $PROXY_CLASS_NAME0$.trapezoid(int,double,int), public final void $PROXY_CLASS_NAME0$.upCheck() throws java.lang.InterruptedException, public final void $PROXY_CLASS_NAME0$.upChuck()]
Decl annos: []
Param annos (0) : []
Modifiers: 17
Invoke public abstract void InterfaceW1.bothThrowBase() throws BaseException,SubException,SubSubException
(no args)
Got expected exception
-Proxy methods: [public final boolean $Proxy3.equals(java.lang.Object), public final java.lang.Object $Proxy3.foo(), public final java.lang.String $Proxy3.foo(), public final int $Proxy3.hashCode(), public final java.lang.String $Proxy3.toString()]
+Proxy methods: [public final boolean $PROXY_CLASS_NAME1$.equals(java.lang.Object), public final java.lang.Object $PROXY_CLASS_NAME1$.foo(), public final java.lang.String $PROXY_CLASS_NAME1$.foo(), public final int $PROXY_CLASS_NAME1$.hashCode(), public final java.lang.String $PROXY_CLASS_NAME1$.toString()]
Invocation of public abstract java.lang.String NarrowingTest$I2.foo()
Invoking foo using I2 type: hello
Invocation of public abstract java.lang.Object NarrowingTest$I1.foo()
});
System.out.println("Proxy interfaces: " +
Arrays.deepToString(proxy.getClass().getInterfaces()));
- System.out.println("Proxy methods: " + Arrays.deepToString(methods));
+ System.out.println("Proxy methods: " +
+ Main.replaceProxyClassNamesForOutput(Arrays.deepToString(methods)));
Method meth = methods[methods.length -1];
System.out.println("Decl annos: " + Arrays.deepToString(meth.getDeclaredAnnotations()));
Annotation[][] paramAnnos = meth.getParameterAnnotations();
/* create the proxy class */
Class proxyClass = Proxy.getProxyClass(Shapes.class.getClassLoader(),
new Class[] { Quads.class, Colors.class, Trace.class });
+ Main.registerProxyClassName(proxyClass.getCanonicalName());
/* create a proxy object, passing the handler object in */
Object proxy = null;
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement ste = stackTrace[i];
if (ste.getMethodName().equals("getTrace")) {
- System.out.println(ste.getClassName() + "." + ste.getMethodName() + " " +
+ String outputClassName = Main.replaceProxyClassNamesForOutput(ste.getClassName());
+ System.out.println(outputClassName + "." + ste.getMethodName() + " " +
ste.getFileName() + ":" + ste.getLineNumber());
}
}
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement ste = stackTrace[i];
if (ste.getMethodName().equals("getTrace")) {
- System.out.println(ste.getClassName() + "." + ste.getMethodName() + " " +
+ String outputClassName = Main.replaceProxyClassNamesForOutput(ste.getClassName());
+ System.out.println(outputClassName + "." + ste.getMethodName() + " " +
ste.getFileName() + ":" + ste.getLineNumber());
}
}
* limitations under the License.
*/
+import java.util.HashMap;
+
/**
* Test java.lang.reflect.Proxy
*/
FloatSelect.main(null);
NativeProxy.main(args);
}
+
+ // The following code maps from the actual proxy class names (eg $Proxy2) to their test output
+ // names (eg $PROXY_CLASS_NAME1$). This is to avoid the flaky test failures due to potentially
+ // undeterministic proxy class naming.
+
+ public static void registerProxyClassName(String proxyClassName) {
+ proxyClassNameMap.put(proxyClassName,
+ "$PROXY_CLASS_NAME" + (uniqueTestProxyClassNum++) + "$");
+ }
+
+ public static String replaceProxyClassNamesForOutput(String str) {
+ for (String key : proxyClassNameMap.keySet()) {
+ str = str.replace(key, proxyClassNameMap.get(key));
+ }
+ return str;
+ }
+
+ private static final HashMap<String, String> proxyClassNameMap = new HashMap<String, String>();
+
+ private static int uniqueTestProxyClassNum = 0;
}
}
}
});
+ Main.registerProxyClassName(proxy.getClass().getCanonicalName());
Method[] methods = proxy.getClass().getDeclaredMethods();
- System.out.println("Proxy methods: " + Arrays.deepToString(methods));
+ System.out.println("Proxy methods: " +
+ Main.replaceProxyClassNamesForOutput(Arrays.deepToString(methods)));
System.out.println("Invoking foo using I2 type: " + proxy.foo());