jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java
changeset 42103 8e1fe4345fd7
parent 40684 2e37c119dc2a
equal deleted inserted replaced
42102:3e0a2861efe1 42103:8e1fe4345fd7
     1 /*
     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    35             Class.forName("Invoker").getMethod("invoke").invoke(null);
    35             Class.forName("Invoker").getMethod("invoke").invoke(null);
    36             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    36             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    37             failures++;
    37             failures++;
    38         } catch (InvocationTargetException e) {
    38         } catch (InvocationTargetException e) {
    39             Throwable c = e.getCause();
    39             Throwable c = e.getCause();
    40             if (BootstrapMethodError.class.isInstance(c)) {
    40             if (expected.isInstance(c))
    41                 c = c.getCause();
    41                 System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
    42                 if (expected.isInstance(c))
    42             else {
    43                     System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
       
    44                 else {
       
    45                     failures++;
       
    46                     System.out.println("FAIL: Unexpected wrapped exception " + c);
       
    47                     e.printStackTrace(System.out);
       
    48                 }
       
    49             } else {
       
    50                 failures++;
    43                 failures++;
    51                 System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + c);
    44                 System.out.println("FAIL: Unexpected wrapped exception " + c);
    52                 e.printStackTrace(System.out);
    45                 e.printStackTrace(System.out);
    53             }
    46             }
    54         } catch (Throwable e) {
    47         } catch (Throwable e) {
    55             failures++;
    48             failures++;
    56             System.out.println("FAIL: Unexpected exception has been caught " + e);
    49             System.out.println("FAIL: Unexpected exception has been caught " + e);
    78         System.out.println();
    71         System.out.println();
    79         try {
    72         try {
    80             Invoker.invoke();
    73             Invoker.invoke();
    81             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    74             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    82             failures++;
    75             failures++;
    83         } catch (BootstrapMethodError e) {
    76         } catch (Throwable e) {
    84             Throwable c = e.getCause();
    77             if (expected.isInstance(e))
    85             if (expected.isInstance(c))
    78                 System.out.println("EXPECTED: " + expected.getName() + ", "+ e);
    86                 System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
       
    87             else {
    79             else {
    88                 failures++;
    80                 failures++;
    89                 System.out.println("FAIL: Unexpected exception has been caught " + c);
    81                 System.out.println("FAIL: Unexpected exception has been caught " + e);
    90                 e.printStackTrace(System.out);
    82                 e.printStackTrace(System.out);
    91             }
    83             }
    92         } catch (Throwable e) {
       
    93             failures++;
       
    94             System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + e);
       
    95             e.printStackTrace(System.out);
       
    96         }
    84         }
    97         System.out.println();
    85         System.out.println();
    98         try {
    86         try {
    99             Invoker.invoke2();
    87             Invoker.invoke2();
   100             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
    88             System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");