hotspot/test/runtime/BoolReturn/libNativeSmallIntCalls.c
author dsamersoff
Sun, 01 May 2016 12:47:00 +0300
changeset 38152 80e5da81fb2c
parent 37483 8447cff6323d
permissions -rw-r--r--
8154258: [TESTBUG] Various serviceability tests fail compilation Summary: Replace sun.misc.Unsafe with jdk.internal.misc.Unsafe Reviewed-by: chegar, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37483
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     1
/*
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     4
 *
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     8
 *
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    13
 * accompanied this code).
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    14
 *
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    18
 *
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    21
 * questions.
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    22
 */
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    23
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    24
#include <jni.h>
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    25
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    26
JNIEXPORT void JNICALL
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    27
Java_NativeSmallIntCallsTest_nativeCallBoolConstructor(JNIEnv* env, jobject obj, int visible, int expected) {
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    28
    jclass cls;
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    29
    jmethodID ctor;
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    30
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    31
    cls = (*env)->FindClass(env, "BoolConstructor");
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    32
    if(NULL == cls) {
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    33
        return;
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    34
    }
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    35
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    36
    ctor = (*env)->GetMethodID(env, cls, "<init>", "(ZZ)V");
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    37
    if(NULL == ctor) {
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    38
        return;
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    39
    }
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    40
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    41
    // printf("visible 0x%x expected %d\n", visible, expected);
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    42
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    43
    (*env)->NewObject(env, cls, ctor, (jboolean) visible, expected);
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    44
}
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    45
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    46
JNIEXPORT jboolean JNICALL
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    47
Java_NativeSmallIntCallsTest_nativeCastToBoolCallTrue(JNIEnv* env, jobject obj) {
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    48
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    49
    return 55;
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    50
}
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    51
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    52
JNIEXPORT jboolean JNICALL
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    53
Java_NativeSmallIntCallsTest_nativeCastToBoolCallFalse(JNIEnv* env, jobject obj) {
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    54
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    55
    return 44;
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    56
}
8447cff6323d 8149170: Better byte behavior should normalize JNI arguments
coleenp
parents:
diff changeset
    57