< prev index next >

test/java/lang/reflect/Method/GenericStringTest.java

Print this page

        

*** 21,31 **** * questions. */ /* * @test ! * @bug 5033583 6316717 6470106 8004979 8161500 * @summary Check toGenericString() and toString() methods * @author Joseph D. Darcy */ import java.lang.reflect.*; --- 21,31 ---- * questions. */ /* * @test ! * @bug 5033583 6316717 6470106 8004979 8161500 8162539 * @summary Check toGenericString() and toString() methods * @author Joseph D. Darcy */ import java.lang.reflect.*;
*** 42,73 **** ExpectedGenericString egs = method.getAnnotation(ExpectedGenericString.class); if (egs != null) { String actual = method.toGenericString(); System.out.println(actual); if (method.isBridge()) { ! if (! egs.bridgeValue().equals(actual)) { ! failures++; ! System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n", ! egs.value(), actual); ! } } else { ! if (! egs.value().equals(actual)) { ! failures++; ! System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n", ! egs.value(), actual); ! } } } if (method.isAnnotationPresent(ExpectedString.class)) { ExpectedString es = method.getAnnotation(ExpectedString.class); String actual = method.toString(); ! if (! es.value().equals(actual)) { ! failures++; ! System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n", ! es.value(), actual); ! } } } // Bridge Test; no "volatile" methods --- 42,61 ---- ExpectedGenericString egs = method.getAnnotation(ExpectedGenericString.class); if (egs != null) { String actual = method.toGenericString(); System.out.println(actual); if (method.isBridge()) { ! failures += checkForFailure(egs.bridgeValue(), actual); } else { ! failures += checkForFailure(egs.value(), actual); } } if (method.isAnnotationPresent(ExpectedString.class)) { ExpectedString es = method.getAnnotation(ExpectedString.class); String actual = method.toString(); ! failures += checkForFailure(es.value(), actual); } } // Bridge Test; no "volatile" methods
*** 86,95 **** --- 74,92 ---- if (failures > 0) { System.err.println("Test failed."); throw new RuntimeException(); } } + + private static int checkForFailure(String expected, String actual) { + if (!expected.equals(actual)) { + System.err.printf("ERROR: Expected ''%s'';%ngot ''%s''.\n", + expected, actual); + return 1; + } else + return 0; + } } class TestClass1 { @ExpectedGenericString( "void TestClass1.method1(int,double)")
*** 113,122 **** --- 110,121 ---- "public <T> T TestClass2.method1(E,T)") public <T> T method1(E e, T t) {return null;} @ExpectedGenericString( "public void TestClass2.method2() throws F") + @ExpectedString( + "public void TestClass2.method2() throws java.lang.Exception") public void method2() throws F {return;} @ExpectedGenericString( "public E[] TestClass2.method3()") public E[] method3() {return null;}
< prev index next >