hotspot/test/compiler/calls/common/InvokeVirtual.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 InvokeVirtual instruction
       
    30  */
       
    31 
       
    32 public class InvokeVirtual extends CallsBase {
       
    33     private static final Object LOCK = new Object();
       
    34 
       
    35     public static void main(String args[]) {
       
    36         new InvokeVirtual().runTest(args);
       
    37     }
       
    38 
       
    39     /**
       
    40      * A native caller method, assumed to called "callee"/"calleeNative"
       
    41      */
       
    42     @Override
       
    43     public native void callerNative();
       
    44 
       
    45     /**
       
    46      * A caller method, assumed to called "callee"/"calleeNative"
       
    47      */
       
    48     @Override
       
    49     public void caller() {
       
    50         if (nativeCallee) {
       
    51             Asserts.assertTrue(calleeNative(1, 2L, 3.0f, 4.0d, "5"), CALL_ERR_MSG);
       
    52         } else {
       
    53             Asserts.assertTrue(callee(1, 2L, 3.0f, 4.0d, "5"), CALL_ERR_MSG);
       
    54         }
       
    55     }
       
    56 
       
    57     /**
       
    58      * A callee method, assumed to be called by "caller"/"callerNative"
       
    59      */
       
    60     public boolean callee(int param1, long param2, float param3, double param4,
       
    61             String param5) {
       
    62         calleeVisited = true;
       
    63         CallsBase.checkValues(param1, param2, param3, param4, param5);
       
    64         return true;
       
    65     }
       
    66 
       
    67     /**
       
    68      * A native callee method, assumed to be called by "caller"/"callerNative"
       
    69      */
       
    70     public native boolean calleeNative(int param1, long param2, float param3,
       
    71             double param4, String param5);
       
    72 
       
    73     /**
       
    74      * Returns object to lock execution on
       
    75      * @return lock object
       
    76      */
       
    77     @Override
       
    78     protected Object getLockObject() {
       
    79         return LOCK;
       
    80     }
       
    81 }