jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java
changeset 31064 49d006561bec
parent 20498 6b1da6741f95
child 40684 2e37c119dc2a
equal deleted inserted replaced
30906:1b67cbb0adce 31064:49d006561bec
    36             Class.forName("Invoker").getMethod("invoke").invoke(null);
    36             Class.forName("Invoker").getMethod("invoke").invoke(null);
    37             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    37             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    38             failures++;
    38             failures++;
    39         } catch (InvocationTargetException e) {
    39         } catch (InvocationTargetException e) {
    40             Throwable c = e.getCause();
    40             Throwable c = e.getCause();
    41             if (expected.isInstance(c))
    41             if (BootstrapMethodError.class.isInstance(c)) {
    42                System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
    42                 c = c.getCause();
    43             else {
    43                 if (expected.isInstance(c))
    44                failures++;
    44                     System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
    45                System.out.println("FAIL: Unexpected wrapped exception " + c);
    45                 else {
    46                e.printStackTrace(System.out);
    46                     failures++;
       
    47                     System.out.println("FAIL: Unexpected wrapped exception " + c);
       
    48                     e.printStackTrace(System.out);
       
    49                 }
       
    50             } else {
       
    51                 failures++;
       
    52                 System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + c);
       
    53                 e.printStackTrace(System.out);
    47             }
    54             }
    48         } catch (Throwable e) {
    55         } catch (Throwable e) {
    49             failures++;
    56             failures++;
    50             System.out.println("FAIL: Unexpected exception has been caught " + e);
    57             System.out.println("FAIL: Unexpected exception has been caught " + e);
    51             e.printStackTrace(System.out);
    58             e.printStackTrace(System.out);
    72         System.out.println();
    79         System.out.println();
    73         try {
    80         try {
    74             Invoker.invoke();
    81             Invoker.invoke();
    75             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    82             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    76             failures++;
    83             failures++;
       
    84         } catch (BootstrapMethodError e) {
       
    85             Throwable c = e.getCause();
       
    86             if (expected.isInstance(c))
       
    87                 System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
       
    88             else {
       
    89                 failures++;
       
    90                 System.out.println("FAIL: Unexpected exception has been caught " + c);
       
    91                 e.printStackTrace(System.out);
       
    92             }
    77         } catch (Throwable e) {
    93         } catch (Throwable e) {
    78             if (expected.isInstance(e))
       
    79                System.out.println("EXPECTED: " + expected.getName() + ", "+ e);
       
    80             else {
       
    81             failures++;
    94             failures++;
    82             System.out.println("FAIL: Unexpected exception has been caught " + e);
    95             System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + e);
    83             e.printStackTrace(System.out);
    96             e.printStackTrace(System.out);
    84             }
       
    85         }
    97         }
    86         System.out.println();
    98         System.out.println();
    87         try {
    99         try {
    88             Invoker.invoke2();
   100             Invoker.invoke2();
    89             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
   101             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");