hotspot/test/compiler/calls/common/InvokeInterface.java
changeset 35128 bb8baf284c67
equal deleted inserted replaced
35127:483603d4c7b2 35128:bb8baf284c67
       
     1 /*
       
     2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 package compiler.calls.common;
       
    25 
       
    26 import jdk.test.lib.Asserts;
       
    27 
       
    28 /**
       
    29  * A test class checking InvokeInterface instruction
       
    30  */
       
    31 public class InvokeInterface extends CallsBase implements CallInterface {
       
    32     private static final Object LOCK = new Object();
       
    33 
       
    34     public static void main(String args[]) {
       
    35         new InvokeInterface().runTest(args);
       
    36     }
       
    37 
       
    38     /**
       
    39      * A caller method, assumed to called "callee"/"calleeNative"
       
    40      */
       
    41     @Override
       
    42     public void caller() {
       
    43         // cast to CallInterface to force invokeinterface usage
       
    44         if (nativeCallee) {
       
    45             Asserts.assertTrue(((CallInterface) this)
       
    46                     .calleeNative(1, 2L, 3.0f, 4.0d, "5"), CALL_ERR_MSG);
       
    47         } else {
       
    48             Asserts.assertTrue(((CallInterface) this)
       
    49                     .callee(1, 2L, 3.0f, 4.0d, "5"), CALL_ERR_MSG);
       
    50         }
       
    51     }
       
    52 
       
    53     /**
       
    54      * A callee method, assumed to be called by "caller"/"callerNative"
       
    55      */
       
    56     @Override
       
    57     public boolean callee(int param1, long param2, float param3, double param4,
       
    58             String param5) {
       
    59         calleeVisited = true;
       
    60         CallsBase.checkValues(param1, param2, param3, param4, param5);
       
    61         return true;
       
    62     }
       
    63 
       
    64     /**
       
    65      * A native callee method, assumed to be called by "caller"/"callerNative"
       
    66      */
       
    67     @Override
       
    68     public native boolean calleeNative(int param1, long param2, float param3,
       
    69             double param4, String param5);
       
    70 
       
    71     /**
       
    72      * Returns object to lock execution on
       
    73      * @return lock object
       
    74      */
       
    75     @Override
       
    76     protected Object getLockObject() {
       
    77         return LOCK;
       
    78     }
       
    79 
       
    80     @Override
       
    81     protected void callerNative() {
       
    82         throw new Error("No native call for invokeinterface");
       
    83     }
       
    84 }