hotspot/src/share/vm/prims/jniCheck.cpp
author goetz
Fri, 04 Jul 2014 11:46:01 +0200
changeset 25715 d5a8dbdc5150
parent 25059 fff9b51f4be4
child 25716 fc9bd7814b10
permissions -rw-r--r--
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Summary: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Reviewed-by: lfoltan, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24351
diff changeset
     2
 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4571
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4571
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4571
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "classfile/vmSymbols.hpp"
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
    28
#include "memory/guardedMemory.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/instanceKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "oops/oop.inline.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7414
diff changeset
    31
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "prims/jni.h"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "prims/jniCheck.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "prims/jvm_misc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "runtime/fieldDescriptor.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "runtime/handles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "runtime/jfieldIDWorkaround.hpp"
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22234
diff changeset
    39
#include "runtime/thread.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
    41
// Complain every extra number of unplanned local refs
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
    42
#define CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD 32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// Heap objects are allowed to be directly referenced only in VM code,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// not in native code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
#define ASSERT_OOPS_ALLOWED                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    assert(JavaThread::current()->thread_state() == _thread_in_vm,   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
           "jniCheck examining oops in bad state.")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// Execute the given block of source code with the thread in VM state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// To do this, transition from the NATIVE state to the VM state, execute
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// the code, and transtition back.  The ThreadInVMfromNative constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// performs the transition to VM state, its destructor restores the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// NATIVE state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
#define IN_VM(source_code)   {                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    {                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
      ThreadInVMfromNative __tiv(thr);                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
      source_code                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    }                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
 * DECLARATIONS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
static struct JNINativeInterface_ * unchecked_jni_NativeInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
 * MACRO DEFINITIONS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// All JNI checked functions here use JNI_ENTRY_CHECKED() instead of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// QUICK_ENTRY or LEAF variants found in jni.cpp.  This allows handles
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
// to be created if a fatal error should occur.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// Check for thread not attached to VM;  need to catch this before
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// assertions in the wrapper routines might fire
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// Check for env being the one value appropriate for this thread.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
#define JNI_ENTRY_CHECKED(result_type, header)                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
extern "C" {                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  result_type JNICALL header {                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    JavaThread* thr = (JavaThread*)ThreadLocalStorage::get_thread_slow();\
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    if (thr == NULL || !thr->is_Java_thread()) {                         \
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24351
diff changeset
    91
      tty->print_cr("%s", fatal_using_jnienv_in_nonjava);                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      os::abort(true);                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    JNIEnv* xenv = thr->jni_environment();                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    if (env != xenv) {                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      NativeReportJNIFatalError(thr, warn_wrong_jnienv);                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    }                                                                    \
10969
3ecf25293e5a 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 8725
diff changeset
    98
    VM_ENTRY_BASE(result_type, header, thr)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
#define UNCHECKED() (unchecked_jni_NativeInterface)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
static const char * warn_wrong_jnienv = "Using JNIEnv in the wrong thread";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
static const char * warn_bad_class_descriptor = "JNI FindClass received a bad class descriptor \"%s\".  A correct class descriptor " \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  "has no leading \"L\" or trailing \";\".  Incorrect descriptors will not be accepted in future releases.";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
static const char * fatal_using_jnienv_in_nonjava = "FATAL ERROR in native method: Using JNIEnv in non-Java thread";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
static const char * warn_other_function_in_critical = "Warning: Calling other JNI functions in the scope of " \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  "Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
static const char * fatal_bad_ref_to_jni = "Bad global or local ref passed to JNI";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
static const char * fatal_received_null_class = "JNI received a null class";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
static const char * fatal_class_not_a_class = "JNI received a class argument that is not a class";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
static const char * fatal_class_not_a_throwable_class = "JNI Throw or ThrowNew received a class argument that is not a Throwable or Throwable subclass";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
static const char * fatal_wrong_class_or_method = "Wrong object class or methodID passed to JNI call";
3672
65e946046d1e 6862945: 4/3 conversion of jmethodID to methodOop in JVMTI is too expensive
dcubed
parents: 1623
diff changeset
   114
static const char * fatal_non_weak_method = "non-weak methodID passed to JNI call";
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
static const char * fatal_unknown_array_object = "Unknown array object passed to JNI array operations";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
static const char * fatal_object_array_expected = "Object array expected but not received for JNI array operation";
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   117
static const char * fatal_prim_type_array_expected = "Primitive type array expected but not received for JNI array operation";
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
static const char * fatal_non_array  = "Non-array passed to JNI array operations";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
static const char * fatal_element_type_mismatch = "Array element type mismatch in JNI";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
static const char * fatal_should_be_static = "Non-static field ID passed to JNI";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
static const char * fatal_wrong_static_field = "Wrong static field ID passed to JNI";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
static const char * fatal_static_field_not_found = "Static field not found in JNI get/set field operations";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
static const char * fatal_static_field_mismatch = "Field type (static) mismatch in JNI get/set field operations";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
static const char * fatal_should_be_nonstatic = "Static field ID passed to JNI";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
static const char * fatal_null_object = "Null object passed to JNI";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
static const char * fatal_wrong_field = "Wrong field ID passed to JNI";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
static const char * fatal_instance_field_not_found = "Instance field not found in JNI get/set field operations";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
static const char * fatal_instance_field_mismatch = "Field type (instance) mismatch in JNI get/set field operations";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
static const char * fatal_non_string = "JNI string operation received a non-string";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
// When in VM state:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
static void ReportJNIWarning(JavaThread* thr, const char *msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  tty->print_cr("WARNING in native method: %s", msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  thr->print_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
// When in NATIVE state:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
static void NativeReportJNIFatalError(JavaThread* thr, const char *msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    ReportJNIFatalError(thr, msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
static void NativeReportJNIWarning(JavaThread* thr, const char *msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    ReportJNIWarning(thr, msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
 * SUPPORT FUNCTIONS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   158
/**
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   159
 * Check whether or not a programmer has actually checked for exceptions. According
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   160
 * to the JNI Specification ("jni/spec/design.html#java_exceptions"):
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   161
 *
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   162
 * There are two cases where the programmer needs to check for exceptions without
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   163
 * being able to first check an error code:
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   164
 *
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   165
 * - The JNI functions that invoke a Java method return the result of the Java method.
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   166
 * The programmer must call ExceptionOccurred() to check for possible exceptions
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   167
 * that occurred during the execution of the Java method.
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   168
 *
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   169
 * - Some of the JNI array access functions do not return an error code, but may
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   170
 * throw an ArrayIndexOutOfBoundsException or ArrayStoreException.
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   171
 *
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   172
 * In all other cases, a non-error return value guarantees that no exceptions have been thrown.
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   173
 */
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   174
static inline void
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   175
check_pending_exception(JavaThread* thr) {
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   176
  if (thr->has_pending_exception()) {
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   177
    NativeReportJNIWarning(thr, "JNI call made with exception pending");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   178
  }
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   179
  if (thr->is_pending_jni_exception_check()) {
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   180
    IN_VM(
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   181
      tty->print_cr("WARNING in native method: JNI call made without checking exceptions when required to from %s",
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   182
        thr->get_pending_jni_exception_check());
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   183
      thr->print_stack();
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   184
    )
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   185
    thr->clear_pending_jni_exception_check(); // Just complain once
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   186
  }
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   187
}
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   188
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   189
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
static inline void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
functionEnterCritical(JavaThread* thr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
{
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   193
  check_pending_exception(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
static inline void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
functionEnterCriticalExceptionAllowed(JavaThread* thr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
static inline void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
functionEnter(JavaThread* thr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  if (thr->in_critical()) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24351
diff changeset
   205
    tty->print_cr("%s", warn_other_function_in_critical);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  }
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   207
  check_pending_exception(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
static inline void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
functionEnterExceptionAllowed(JavaThread* thr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  if (thr->in_critical()) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24351
diff changeset
   214
    tty->print_cr("%s", warn_other_function_in_critical);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
static inline void
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   219
functionExit(JavaThread* thr)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
{
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   221
  JNIHandleBlock* handles = thr->active_handles();
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   222
  size_t planned_capacity = handles->get_planned_capacity();
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   223
  size_t live_handles = handles->get_number_of_live_handles();
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   224
  if (live_handles > planned_capacity) {
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   225
    IN_VM(
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   226
      tty->print_cr("WARNING: JNI local refs: %zu, exceeds capacity: %zu",
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   227
          live_handles, planned_capacity);
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   228
      thr->print_stack();
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   229
    )
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   230
    // Complain just the once, reset to current + warn threshold
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   231
    handles->set_planned_capacity(live_handles + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   232
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
static inline void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
checkStaticFieldID(JavaThread* thr, jfieldID fid, jclass cls, int ftype)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  fieldDescriptor fd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  /* make sure it is a static field */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  if (!jfieldIDWorkaround::is_static_jfieldID(fid))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    ReportJNIFatalError(thr, fatal_should_be_static);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  /* validate the class being passed */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  ASSERT_OOPS_ALLOWED;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   246
  Klass* k_oop = jniCheck::validate_class(thr, cls, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  /* check for proper subclass hierarchy */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fid);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   250
  Klass* f_oop = id->holder();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   251
  if (!InstanceKlass::cast(k_oop)->is_subtype_of(f_oop))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    ReportJNIFatalError(thr, fatal_wrong_static_field);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  /* check for proper field type */
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8107
diff changeset
   255
  if (!id->find_local_field(&fd))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    ReportJNIFatalError(thr, fatal_static_field_not_found);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  if ((fd.field_type() != ftype) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    ReportJNIFatalError(thr, fatal_static_field_mismatch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
static inline void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
checkInstanceFieldID(JavaThread* thr, jfieldID fid, jobject obj, int ftype)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  fieldDescriptor fd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  /* make sure it is an instance field */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  if (jfieldIDWorkaround::is_static_jfieldID(fid))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    ReportJNIFatalError(thr, fatal_should_be_nonstatic);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  /* validate the object being passed and then get its class */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  oop oopObj = jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  if (!oopObj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    ReportJNIFatalError(thr, fatal_null_object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   278
  Klass* k_oop = oopObj->klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  if (!jfieldIDWorkaround::is_valid_jfieldID(k_oop, fid)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    ReportJNIFatalError(thr, fatal_wrong_field);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  /* make sure the field exists */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  int offset = jfieldIDWorkaround::from_instance_jfieldID(k_oop, fid);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   286
  if (!InstanceKlass::cast(k_oop)->contains_field_offset(offset))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    ReportJNIFatalError(thr, fatal_wrong_field);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  /* check for proper field type */
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   290
  if (!InstanceKlass::cast(k_oop)->find_field_from_offset(offset,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
                                                              false, &fd))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    ReportJNIFatalError(thr, fatal_instance_field_not_found);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  if ((fd.field_type() != ftype) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    ReportJNIFatalError(thr, fatal_instance_field_mismatch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
static inline void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
checkString(JavaThread* thr, jstring js)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  oop s = jniCheck::validate_object(thr, js);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  if (!s || !java_lang_String::is_instance(s))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    ReportJNIFatalError(thr, fatal_non_string);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   309
static inline arrayOop
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   310
check_is_array(JavaThread* thr, jarray jArray)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  arrayOop aOop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  aOop = (arrayOop)jniCheck::validate_object(thr, jArray);
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   316
  if (aOop == NULL || !aOop->is_array()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    ReportJNIFatalError(thr, fatal_non_array);
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   318
  }
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   319
  return aOop;
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   320
}
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   321
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   322
static inline arrayOop
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   323
check_is_primitive_array(JavaThread* thr, jarray jArray) {
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   324
  arrayOop aOop = check_is_array(thr, jArray);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   326
  if (!aOop->is_typeArray()) {
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   327
     ReportJNIFatalError(thr, fatal_prim_type_array_expected);
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   328
  }
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   329
  return aOop;
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   330
}
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   331
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   332
static inline void
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   333
check_primitive_array_type(JavaThread* thr, jarray jArray, BasicType elementType)
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   334
{
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   335
  BasicType array_type;
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   336
  arrayOop aOop;
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   337
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   338
  aOop = check_is_primitive_array(thr, jArray);
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   339
  array_type = TypeArrayKlass::cast(aOop->klass())->element_type();
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   340
  if (array_type != elementType) {
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   341
    ReportJNIFatalError(thr, fatal_element_type_mismatch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   345
static inline void
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   346
check_is_obj_array(JavaThread* thr, jarray jArray) {
18942
705506c1bf49 8020697: jniCheck.cpp:check_is_obj_array asserts on TypeArrayKlass::cast(aOop->klass())
dholmes
parents: 18937
diff changeset
   347
  arrayOop aOop = check_is_array(thr, jArray);
705506c1bf49 8020697: jniCheck.cpp:check_is_obj_array asserts on TypeArrayKlass::cast(aOop->klass())
dholmes
parents: 18937
diff changeset
   348
  if (!aOop->is_objArray()) {
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   349
    ReportJNIFatalError(thr, fatal_object_array_expected);
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   350
  }
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
   351
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   353
/*
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   354
 * Copy and wrap array elements for bounds checking.
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   355
 * Remember the original elements (GuardedMemory::get_tag())
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   356
 */
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   357
static void* check_jni_wrap_copy_array(JavaThread* thr, jarray array,
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   358
    void* orig_elements) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   359
  void* result;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   360
  IN_VM(
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   361
    oop a = JNIHandles::resolve_non_null(array);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   362
    size_t len = arrayOop(a)->length() <<
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   363
        TypeArrayKlass::cast(a->klass())->log2_element_size();
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   364
    result = GuardedMemory::wrap_copy(orig_elements, len, orig_elements);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   365
  )
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   366
  return result;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   367
}
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   368
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   369
static void* check_wrapped_array(JavaThread* thr, const char* fn_name,
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   370
    void* obj, void* carray, size_t* rsz) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   371
  if (carray == NULL) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   372
    tty->print_cr("%s: elements vector NULL" PTR_FORMAT, fn_name, p2i(obj));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   373
    NativeReportJNIFatalError(thr, "Elements vector NULL");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   374
  }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   375
  GuardedMemory guarded(carray);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   376
  void* orig_result = guarded.get_tag();
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   377
  if (!guarded.verify_guards()) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   378
    tty->print_cr("ReleasePrimitiveArrayCritical: release array failed bounds "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   379
        "check, incorrect pointer returned ? array: " PTR_FORMAT " carray: "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   380
        PTR_FORMAT, p2i(obj), p2i(carray));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   381
    guarded.print_on(tty);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   382
    NativeReportJNIFatalError(thr, "ReleasePrimitiveArrayCritical: "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   383
        "failed bounds check");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   384
  }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   385
  if (orig_result == NULL) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   386
    tty->print_cr("ReleasePrimitiveArrayCritical: unrecognized elements. array: "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   387
        PTR_FORMAT " carray: " PTR_FORMAT, p2i(obj), p2i(carray));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   388
    guarded.print_on(tty);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   389
    NativeReportJNIFatalError(thr, "ReleasePrimitiveArrayCritical: "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   390
        "unrecognized elements");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   391
  }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   392
  if (rsz != NULL) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   393
    *rsz = guarded.get_user_size();
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   394
  }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   395
  return orig_result;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   396
}
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   397
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   398
static void* check_wrapped_array_release(JavaThread* thr, const char* fn_name,
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   399
    void* obj, void* carray, jint mode) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   400
  size_t sz;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   401
  void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   402
  switch (mode) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   403
  case 0:
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   404
    memcpy(orig_result, carray, sz);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   405
    GuardedMemory::free_copy(carray);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   406
    break;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   407
  case JNI_COMMIT:
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   408
    memcpy(orig_result, carray, sz);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   409
    break;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   410
  case JNI_ABORT:
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   411
    GuardedMemory::free_copy(carray);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   412
    break;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   413
  default:
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   414
    tty->print_cr("%s: Unrecognized mode %i releasing array "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   415
        PTR_FORMAT " elements " PTR_FORMAT, fn_name, mode, p2i(obj), p2i(carray));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   416
    NativeReportJNIFatalError(thr, "Unrecognized array release mode");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   417
  }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   418
  return orig_result;
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   419
}
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
   420
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
oop jniCheck::validate_handle(JavaThread* thr, jobject obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  if (JNIHandles::is_frame_handle(thr, obj) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      JNIHandles::is_local_handle(thr, obj) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      JNIHandles::is_global_handle(obj) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
      JNIHandles::is_weak_global_handle(obj)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    return JNIHandles::resolve_external_guard(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  ReportJNIFatalError(thr, fatal_bad_ref_to_jni);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   434
Method* jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  ASSERT_OOPS_ALLOWED;
3672
65e946046d1e 6862945: 4/3 conversion of jmethodID to methodOop in JVMTI is too expensive
dcubed
parents: 1623
diff changeset
   436
  // do the fast jmethodID check first
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   437
  Method* moop = Method::checked_resolve_jmethod_id(method_id);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  if (moop == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    ReportJNIFatalError(thr, fatal_wrong_class_or_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   441
  // jmethodIDs are supposed to be weak handles in the class loader data,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   442
  // but that can be expensive so check it last
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   443
  else if (!Method::is_method_id(method_id)) {
3672
65e946046d1e 6862945: 4/3 conversion of jmethodID to methodOop in JVMTI is too expensive
dcubed
parents: 1623
diff changeset
   444
    ReportJNIFatalError(thr, fatal_non_weak_method);
65e946046d1e 6862945: 4/3 conversion of jmethodID to methodOop in JVMTI is too expensive
dcubed
parents: 1623
diff changeset
   445
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  return moop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
oop jniCheck::validate_object(JavaThread* thr, jobject obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    if (!obj)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
        return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    oop oopObj = jniCheck::validate_handle(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    if (!oopObj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
      ReportJNIFatalError(thr, fatal_bad_ref_to_jni);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    return oopObj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
// Warn if a class descriptor is in decorated form; class descriptors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
// passed to JNI findClass should not be decorated unless they are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
// array descriptors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
void jniCheck::validate_class_descriptor(JavaThread* thr, const char* name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  if (name == NULL) return;  // implementation accepts NULL so just return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  size_t len = strlen(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  if (len >= 2 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
      name[0] == JVM_SIGNATURE_CLASS &&            // 'L'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
      name[len-1] == JVM_SIGNATURE_ENDCLASS ) {    // ';'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    char msg[JVM_MAXPATHLEN];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    jio_snprintf(msg, JVM_MAXPATHLEN, warn_bad_class_descriptor, name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    ReportJNIWarning(thr, msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   478
Klass* jniCheck::validate_class(JavaThread* thr, jclass clazz, bool allow_primitive) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  oop mirror = jniCheck::validate_handle(thr, clazz);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  if (!mirror) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
    ReportJNIFatalError(thr, fatal_received_null_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
4571
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 3672
diff changeset
   485
  if (mirror->klass() != SystemDictionary::Class_klass()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    ReportJNIFatalError(thr, fatal_class_not_a_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   489
  Klass* k = java_lang_Class::as_Klass(mirror);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  // Make allowances for primitive classes ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  if (!(k != NULL || allow_primitive && java_lang_Class::is_primitive(mirror))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    ReportJNIFatalError(thr, fatal_class_not_a_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  return k;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   497
void jniCheck::validate_throwable_klass(JavaThread* thr, Klass* klass) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  assert(klass != NULL, "klass argument must have a value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13952
diff changeset
   501
  if (!klass->oop_is_instance() ||
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   502
      !InstanceKlass::cast(klass)->is_subclass_of(SystemDictionary::Throwable_klass())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    ReportJNIFatalError(thr, fatal_class_not_a_throwable_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
void jniCheck::validate_call_object(JavaThread* thr, jobject obj, jmethodID method_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  /* validate the object being passed */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  jniCheck::validate_jmethod_id(thr, method_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
void jniCheck::validate_call_class(JavaThread* thr, jclass clazz, jmethodID method_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  /* validate the class being passed */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  ASSERT_OOPS_ALLOWED;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  jniCheck::validate_jmethod_id(thr, method_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
 * IMPLEMENTATION OF FUNCTIONS IN CHECKED TABLE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
JNI_ENTRY_CHECKED(jclass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  checked_jni_DefineClass(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
                          const char *name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
                          jobject loader,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
                          const jbyte *buf,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
                          jsize len))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
      jniCheck::validate_object(thr, loader);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
    jclass result = UNCHECKED()->DefineClass(env, name, loader, buf, len);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   537
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
JNI_ENTRY_CHECKED(jclass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  checked_jni_FindClass(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
                        const char *name))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
      jniCheck::validate_class_descriptor(thr, name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    jclass result = UNCHECKED()->FindClass(env, name);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   549
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
JNI_ENTRY_CHECKED(jmethodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  checked_jni_FromReflectedMethod(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
                                  jobject method))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
      jniCheck::validate_object(thr, method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
    jmethodID result = UNCHECKED()->FromReflectedMethod(env, method);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   561
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
JNI_ENTRY_CHECKED(jfieldID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  checked_jni_FromReflectedField(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
                                 jobject field))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
      jniCheck::validate_object(thr, field);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    jfieldID result = UNCHECKED()->FromReflectedField(env, field);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   573
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  checked_jni_ToReflectedMethod(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
                                jclass cls,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
                                jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
                                jboolean isStatic))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      jniCheck::validate_class(thr, cls, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
      jniCheck::validate_jmethod_id(thr, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    jobject result = UNCHECKED()->ToReflectedMethod(env, cls, methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
                                                    isStatic);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   589
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
JNI_ENTRY_CHECKED(jclass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  checked_jni_GetSuperclass(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
                            jclass sub))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
      jniCheck::validate_class(thr, sub, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    jclass result = UNCHECKED()->GetSuperclass(env, sub);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   601
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
JNI_ENTRY_CHECKED(jboolean,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  checked_jni_IsAssignableFrom(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
                               jclass sub,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
                               jclass sup))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
      jniCheck::validate_class(thr, sub, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
      jniCheck::validate_class(thr, sup, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    jboolean result = UNCHECKED()->IsAssignableFrom(env, sub, sup);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   615
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  checked_jni_ToReflectedField(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
                               jclass cls,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
                               jfieldID fieldID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
                               jboolean isStatic))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
      jniCheck::validate_class(thr, cls, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
    jobject result = UNCHECKED()->ToReflectedField(env, cls, fieldID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
                                                   isStatic);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   630
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  checked_jni_Throw(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
                    jthrowable obj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      oop oopObj = jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
      if (oopObj == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
        // Unchecked Throw tolerates a NULL obj, so just warn
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
        ReportJNIWarning(thr, "JNI Throw called with NULL throwable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
        jniCheck::validate_throwable_klass(thr, oopObj->klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    jint result = UNCHECKED()->Throw(env, obj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   648
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  checked_jni_ThrowNew(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
                       jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
                       const char *msg))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    IN_VM(
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   658
      Klass* k = jniCheck::validate_class(thr, clazz, false);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   659
      assert(k != NULL, "validate_class shouldn't return NULL Klass*");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
      jniCheck::validate_throwable_klass(thr, k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    jint result = UNCHECKED()->ThrowNew(env, clazz, msg);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   663
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
JNI_ENTRY_CHECKED(jthrowable,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
  checked_jni_ExceptionOccurred(JNIEnv *env))
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   669
    thr->clear_pending_jni_exception_check();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
    jthrowable result = UNCHECKED()->ExceptionOccurred(env);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   672
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  checked_jni_ExceptionDescribe(JNIEnv *env))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    UNCHECKED()->ExceptionDescribe(env);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   680
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  checked_jni_ExceptionClear(JNIEnv *env))
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   685
    thr->clear_pending_jni_exception_check();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    UNCHECKED()->ExceptionClear(env);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   688
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  checked_jni_FatalError(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
                         const char *msg))
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   694
    thr->clear_pending_jni_exception_check();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
    UNCHECKED()->FatalError(env, msg);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   697
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  checked_jni_PushLocalFrame(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
                             jint capacity))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    if (capacity < 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
      NativeReportJNIFatalError(thr, "negative capacity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
    jint result = UNCHECKED()->PushLocalFrame(env, capacity);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   707
    if (result == JNI_OK) {
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   708
      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   709
    }
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   710
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  checked_jni_PopLocalFrame(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
                            jobject result))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
    jobject res = UNCHECKED()->PopLocalFrame(env, result);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   719
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
    return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  checked_jni_NewGlobalRef(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
                           jobject lobj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
      if (lobj != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
        jniCheck::validate_handle(thr, lobj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
    jobject result = UNCHECKED()->NewGlobalRef(env,lobj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   733
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  checked_jni_DeleteGlobalRef(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
                              jobject gref))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
      jniCheck::validate_object(thr, gref);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
      if (gref && !JNIHandles::is_global_handle(gref)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
        ReportJNIFatalError(thr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
            "Invalid global JNI handle passed to DeleteGlobalRef");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    UNCHECKED()->DeleteGlobalRef(env,gref);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   749
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  checked_jni_DeleteLocalRef(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
                             jobject obj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
      jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
      if (obj && !(JNIHandles::is_local_handle(thr, obj) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
                   JNIHandles::is_frame_handle(thr, obj)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
        ReportJNIFatalError(thr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
            "Invalid local JNI handle passed to DeleteLocalRef");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
    UNCHECKED()->DeleteLocalRef(env, obj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   764
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
JNI_ENTRY_CHECKED(jboolean,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  checked_jni_IsSameObject(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
                           jobject obj1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
                           jobject obj2))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
      /* This JNI function can be used to compare weak global references
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
       * to NULL objects. If the handles are valid, but contain NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
       * then don't attempt to validate the object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
       */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
      if (obj1 != NULL && jniCheck::validate_handle(thr, obj1) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
        jniCheck::validate_object(thr, obj1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
      if (obj2 != NULL && jniCheck::validate_handle(thr, obj2) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
        jniCheck::validate_object(thr, obj2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    jboolean result = UNCHECKED()->IsSameObject(env,obj1,obj2);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   785
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  checked_jni_NewLocalRef(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
                          jobject ref))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
      if (ref != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
        jniCheck::validate_handle(thr, ref);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    jobject result = UNCHECKED()->NewLocalRef(env, ref);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   799
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
  checked_jni_EnsureLocalCapacity(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
                                  jint capacity))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
    if (capacity < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
      NativeReportJNIFatalError(thr, "negative capacity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
    jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   811
    if (result == JNI_OK) {
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   812
      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   813
    }
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   814
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  checked_jni_AllocObject(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
                          jclass clazz))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
    jobject result = UNCHECKED()->AllocObject(env,clazz);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   826
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
  checked_jni_NewObject(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
                        jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
                        jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
                        ...))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
    va_list args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
      jniCheck::validate_jmethod_id(thr, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
    va_start(args, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
    va_end(args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   844
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  checked_jni_NewObjectV(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
                         jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
                         jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
                         va_list args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
      jniCheck::validate_jmethod_id(thr, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
    jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   859
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  checked_jni_NewObjectA(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
                         jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
                         jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
                         const jvalue *args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
      jniCheck::validate_jmethod_id(thr, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
    jobject result = UNCHECKED()->NewObjectA(env,clazz,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   874
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
JNI_ENTRY_CHECKED(jclass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  checked_jni_GetObjectClass(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
                             jobject obj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
      jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
    jclass result = UNCHECKED()->GetObjectClass(env,obj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   886
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
JNI_ENTRY_CHECKED(jboolean,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  checked_jni_IsInstanceOf(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
                           jobject obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
                           jclass clazz))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
      jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
      jniCheck::validate_class(thr, clazz, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
    jboolean result = UNCHECKED()->IsInstanceOf(env,obj,clazz);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   900
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
JNI_ENTRY_CHECKED(jmethodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  checked_jni_GetMethodID(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
                          jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
                          const char *name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
                          const char *sig))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
    jmethodID result = UNCHECKED()->GetMethodID(env,clazz,name,sig);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   914
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
#define WRAPPER_CallMethod(ResultType, Result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
JNI_ENTRY_CHECKED(ResultType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
  checked_jni_Call##Result##Method(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
                                   jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
                                   jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
                                   ...)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
    va_list args; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
      jniCheck::validate_call_object(thr, obj, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
    va_start(args,methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
    ResultType result =UNCHECKED()->Call##Result##MethodV(env, obj, methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
                                                          args); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
    va_end(args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   933
    thr->set_pending_jni_exception_check("Call"#Result"Method"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   934
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
JNI_END \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
JNI_ENTRY_CHECKED(ResultType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  checked_jni_Call##Result##MethodV(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
                                    jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
                                    jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
                                    va_list args)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
    IN_VM(\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
      jniCheck::validate_call_object(thr, obj, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
    ResultType result = UNCHECKED()->Call##Result##MethodV(env, obj, methodID,\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
                                                           args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   949
    thr->set_pending_jni_exception_check("Call"#Result"MethodV"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   950
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
JNI_END \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
JNI_ENTRY_CHECKED(ResultType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  checked_jni_Call##Result##MethodA(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
                                    jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
                                    jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
                                    const jvalue * args)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
      jniCheck::validate_call_object(thr, obj, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
    ResultType result = UNCHECKED()->Call##Result##MethodA(env, obj, methodID,\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
                                                           args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   965
    thr->set_pending_jni_exception_check("Call"#Result"MethodA"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   966
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
WRAPPER_CallMethod(jobject,Object)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
WRAPPER_CallMethod(jboolean,Boolean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
WRAPPER_CallMethod(jbyte,Byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
WRAPPER_CallMethod(jshort,Short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
WRAPPER_CallMethod(jchar,Char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
WRAPPER_CallMethod(jint,Int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
WRAPPER_CallMethod(jlong,Long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
WRAPPER_CallMethod(jfloat,Float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
WRAPPER_CallMethod(jdouble,Double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
  checked_jni_CallVoidMethod(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
                             jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
                             jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
                             ...))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
    va_list args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
      jniCheck::validate_call_object(thr, obj, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
    va_start(args,methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
    UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
    va_end(args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   993
    thr->set_pending_jni_exception_check("CallVoidMethod");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
   994
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
  checked_jni_CallVoidMethodV(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
                              jobject obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
                              jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
                              va_list args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
      jniCheck::validate_call_object(thr, obj, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
    UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1007
    thr->set_pending_jni_exception_check("CallVoidMethodV");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1008
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
  checked_jni_CallVoidMethodA(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
                              jobject obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
                              jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
                              const jvalue * args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
      jniCheck::validate_call_object(thr, obj, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
    UNCHECKED()->CallVoidMethodA(env,obj,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1021
    thr->set_pending_jni_exception_check("CallVoidMethodA");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1022
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
#define WRAPPER_CallNonvirtualMethod(ResultType, Result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
JNI_ENTRY_CHECKED(ResultType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
  checked_jni_CallNonvirtual##Result##Method(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
                                             jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
                                             jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
                                             jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
                                             ...)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
    va_list args; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
      jniCheck::validate_call_object(thr, obj, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
      jniCheck::validate_call_class(thr, clazz, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
    va_start(args,methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
    ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
                                                                     obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
                                                                     clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
                                                                     methodID,\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
                                                                     args); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
    va_end(args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1045
    thr->set_pending_jni_exception_check("CallNonvirtual"#Result"Method"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1046
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
JNI_END \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
JNI_ENTRY_CHECKED(ResultType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
  checked_jni_CallNonvirtual##Result##MethodV(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
                                              jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
                                              jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
                                              jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
                                              va_list args)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
      jniCheck::validate_call_object(thr, obj, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
      jniCheck::validate_call_class(thr, clazz, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
    ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
                                                                     obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
                                                                     clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
                                                                     methodID,\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
                                                                     args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1066
    thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodV"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1067
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
JNI_END \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
JNI_ENTRY_CHECKED(ResultType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
  checked_jni_CallNonvirtual##Result##MethodA(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
                                              jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
                                              jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
                                              jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
                                              const jvalue * args)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
      jniCheck::validate_call_object(thr, obj, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
      jniCheck::validate_call_class(thr, clazz, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
    ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodA(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
                                                                     obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
                                                                     clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
                                                                     methodID,\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
                                                                     args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1087
    thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodA"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1088
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
WRAPPER_CallNonvirtualMethod(jobject,Object)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
WRAPPER_CallNonvirtualMethod(jboolean,Boolean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
WRAPPER_CallNonvirtualMethod(jbyte,Byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
WRAPPER_CallNonvirtualMethod(jshort,Short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
WRAPPER_CallNonvirtualMethod(jchar,Char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
WRAPPER_CallNonvirtualMethod(jint,Int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
WRAPPER_CallNonvirtualMethod(jlong,Long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
WRAPPER_CallNonvirtualMethod(jfloat,Float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
WRAPPER_CallNonvirtualMethod(jdouble,Double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
  checked_jni_CallNonvirtualVoidMethod(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
                                       jobject obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
                                       jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
                                       jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
                                       ...))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
    va_list args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
      jniCheck::validate_call_object(thr, obj, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
      jniCheck::validate_call_class(thr, clazz, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
    va_start(args,methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
    UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
    va_end(args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1117
    thr->set_pending_jni_exception_check("CallNonvirtualVoidMethod");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1118
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  checked_jni_CallNonvirtualVoidMethodV(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
                                        jobject obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
                                        jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
                                        jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
                                        va_list args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
      jniCheck::validate_call_object(thr, obj, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
      jniCheck::validate_call_class(thr, clazz, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
    UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1133
    thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodV");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1134
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
  checked_jni_CallNonvirtualVoidMethodA(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
                                        jobject obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
                                        jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
                                        jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
                                        const jvalue * args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
      jniCheck::validate_call_object(thr, obj, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
      jniCheck::validate_call_class(thr, clazz, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
    UNCHECKED()->CallNonvirtualVoidMethodA(env,obj,clazz,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1149
    thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodA");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1150
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
JNI_ENTRY_CHECKED(jfieldID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
  checked_jni_GetFieldID(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
                         jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
                         const char *name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
                         const char *sig))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
    jfieldID result = UNCHECKED()->GetFieldID(env,clazz,name,sig);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1163
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
#define WRAPPER_GetField(ReturnType,Result,FieldType) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
JNI_ENTRY_CHECKED(ReturnType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
  checked_jni_Get##Result##Field(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
                                 jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
                                 jfieldID fieldID)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
      checkInstanceFieldID(thr, fieldID, obj, FieldType); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
    ReturnType result = UNCHECKED()->Get##Result##Field(env,obj,fieldID); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1177
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
WRAPPER_GetField(jobject,  Object,  T_OBJECT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
WRAPPER_GetField(jboolean, Boolean, T_BOOLEAN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
WRAPPER_GetField(jbyte,    Byte,    T_BYTE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
WRAPPER_GetField(jshort,   Short,   T_SHORT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
WRAPPER_GetField(jchar,    Char,    T_CHAR)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
WRAPPER_GetField(jint,     Int,     T_INT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
WRAPPER_GetField(jlong,    Long,    T_LONG)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
WRAPPER_GetField(jfloat,   Float,   T_FLOAT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
WRAPPER_GetField(jdouble,  Double,  T_DOUBLE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
#define WRAPPER_SetField(ValueType,Result,FieldType) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
JNI_ENTRY_CHECKED(void,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
  checked_jni_Set##Result##Field(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
                                 jobject obj, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
                                 jfieldID fieldID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
                                 ValueType val)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
      checkInstanceFieldID(thr, fieldID, obj, FieldType); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
    UNCHECKED()->Set##Result##Field(env,obj,fieldID,val); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1202
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
WRAPPER_SetField(jobject,  Object,  T_OBJECT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
WRAPPER_SetField(jboolean, Boolean, T_BOOLEAN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
WRAPPER_SetField(jbyte,    Byte,    T_BYTE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
WRAPPER_SetField(jshort,   Short,   T_SHORT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
WRAPPER_SetField(jchar,    Char,    T_CHAR)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
WRAPPER_SetField(jint,     Int,     T_INT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
WRAPPER_SetField(jlong,    Long,    T_LONG)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
WRAPPER_SetField(jfloat,   Float,   T_FLOAT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
WRAPPER_SetField(jdouble,  Double,  T_DOUBLE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
JNI_ENTRY_CHECKED(jmethodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
  checked_jni_GetStaticMethodID(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
                                jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
                                const char *name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
                                const char *sig))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
    jmethodID result = UNCHECKED()->GetStaticMethodID(env,clazz,name,sig);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1226
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
#define WRAPPER_CallStaticMethod(ReturnType,Result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
JNI_ENTRY_CHECKED(ReturnType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
  checked_jni_CallStatic##Result##Method(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
                                         jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
                                         jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
                                         ...)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
    va_list args; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
      jniCheck::validate_jmethod_id(thr, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
      jniCheck::validate_class(thr, clazz, false); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
    va_start(args,methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
    ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
                                                                 clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
                                                                 methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
                                                                 args); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
    va_end(args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1248
    thr->set_pending_jni_exception_check("CallStatic"#Result"Method"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1249
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
JNI_END \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
JNI_ENTRY_CHECKED(ReturnType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  checked_jni_CallStatic##Result##MethodV(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
                                          jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
                                          jmethodID methodID,\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
                                          va_list args)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
      jniCheck::validate_jmethod_id(thr, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
      jniCheck::validate_class(thr, clazz, false); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
    ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
                                                                 clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
                                                                 methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
                                                                 args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1267
    thr->set_pending_jni_exception_check("CallStatic"#Result"MethodV"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1268
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
JNI_END \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
\
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
JNI_ENTRY_CHECKED(ReturnType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
  checked_jni_CallStatic##Result##MethodA(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
                                          jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
                                          jmethodID methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
                                          const jvalue *args)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
      jniCheck::validate_jmethod_id(thr, methodID); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
      jniCheck::validate_class(thr, clazz, false); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
    ReturnType result = UNCHECKED()->CallStatic##Result##MethodA(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
                                                                 clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
                                                                 methodID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
                                                                 args); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1286
    thr->set_pending_jni_exception_check("CallStatic"#Result"MethodA"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1287
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
WRAPPER_CallStaticMethod(jobject,Object)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
WRAPPER_CallStaticMethod(jboolean,Boolean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
WRAPPER_CallStaticMethod(jbyte,Byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
WRAPPER_CallStaticMethod(jshort,Short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
WRAPPER_CallStaticMethod(jchar,Char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
WRAPPER_CallStaticMethod(jint,Int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
WRAPPER_CallStaticMethod(jlong,Long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
WRAPPER_CallStaticMethod(jfloat,Float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
WRAPPER_CallStaticMethod(jdouble,Double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
  checked_jni_CallStaticVoidMethod(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
                                   jclass cls,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
                                   jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
                                   ...))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
    va_list args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
      jniCheck::validate_jmethod_id(thr, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
      jniCheck::validate_class(thr, cls, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
    va_start(args,methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
    UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
    va_end(args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1315
    thr->set_pending_jni_exception_check("CallStaticVoidMethod");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1316
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
  checked_jni_CallStaticVoidMethodV(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
                                    jclass cls,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
                                    jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
                                    va_list args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
      jniCheck::validate_jmethod_id(thr, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
      jniCheck::validate_class(thr, cls, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
    UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1330
    thr->set_pending_jni_exception_check("CallStaticVoidMethodV");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1331
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
  checked_jni_CallStaticVoidMethodA(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
                                    jclass cls,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
                                    jmethodID methodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
                                    const jvalue * args))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
      jniCheck::validate_jmethod_id(thr, methodID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
      jniCheck::validate_class(thr, cls, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
    UNCHECKED()->CallStaticVoidMethodA(env,cls,methodID,args);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1345
    thr->set_pending_jni_exception_check("CallStaticVoidMethodA");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1346
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
JNI_ENTRY_CHECKED(jfieldID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
  checked_jni_GetStaticFieldID(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
                               jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
                               const char *name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
                               const char *sig))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
      jniCheck::validate_class(thr, clazz, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
    jfieldID result = UNCHECKED()->GetStaticFieldID(env,clazz,name,sig);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1359
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
#define WRAPPER_GetStaticField(ReturnType,Result,FieldType) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
JNI_ENTRY_CHECKED(ReturnType,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
  checked_jni_GetStatic##Result##Field(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
                                       jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
                                       jfieldID fieldID)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
      jniCheck::validate_class(thr, clazz, false); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
      checkStaticFieldID(thr, fieldID, clazz, FieldType); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
    ReturnType result = UNCHECKED()->GetStatic##Result##Field(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
                                                              clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
                                                              fieldID); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1376
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
WRAPPER_GetStaticField(jobject,  Object,  T_OBJECT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
WRAPPER_GetStaticField(jboolean, Boolean, T_BOOLEAN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
WRAPPER_GetStaticField(jbyte,    Byte,    T_BYTE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
WRAPPER_GetStaticField(jshort,   Short,   T_SHORT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
WRAPPER_GetStaticField(jchar,    Char,    T_CHAR)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
WRAPPER_GetStaticField(jint,     Int,     T_INT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
WRAPPER_GetStaticField(jlong,    Long,    T_LONG)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
WRAPPER_GetStaticField(jfloat,   Float,   T_FLOAT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
WRAPPER_GetStaticField(jdouble,  Double,  T_DOUBLE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
#define WRAPPER_SetStaticField(ValueType,Result,FieldType) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
JNI_ENTRY_CHECKED(void,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
  checked_jni_SetStatic##Result##Field(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
                                       jclass clazz, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
                                       jfieldID fieldID, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
                                       ValueType value)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
    IN_VM( \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
      jniCheck::validate_class(thr, clazz, false); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
      checkStaticFieldID(thr, fieldID, clazz, FieldType); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
    UNCHECKED()->SetStatic##Result##Field(env,clazz,fieldID,value); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1402
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
WRAPPER_SetStaticField(jobject,  Object,  T_OBJECT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
WRAPPER_SetStaticField(jboolean, Boolean, T_BOOLEAN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
WRAPPER_SetStaticField(jbyte,    Byte,    T_BYTE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
WRAPPER_SetStaticField(jshort,   Short,   T_SHORT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
WRAPPER_SetStaticField(jchar,    Char,    T_CHAR)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
WRAPPER_SetStaticField(jint,     Int,     T_INT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
WRAPPER_SetStaticField(jlong,    Long,    T_LONG)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
WRAPPER_SetStaticField(jfloat,   Float,   T_FLOAT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
WRAPPER_SetStaticField(jdouble,  Double,  T_DOUBLE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
JNI_ENTRY_CHECKED(jstring,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
  checked_jni_NewString(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
                        const jchar *unicode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
                        jsize len))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
    jstring result = UNCHECKED()->NewString(env,unicode,len);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1422
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
JNI_ENTRY_CHECKED(jsize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
  checked_jni_GetStringLength(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
                              jstring str))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
    jsize result = UNCHECKED()->GetStringLength(env,str);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1434
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1438
// Arbitrary (but well-known) tag
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1439
const void* STRING_TAG = (void*)0x47114711;
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1440
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
JNI_ENTRY_CHECKED(const jchar *,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
  checked_jni_GetStringChars(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
                             jstring str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
                             jboolean *isCopy))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
    )
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1449
    jchar* new_result = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
    const jchar *result = UNCHECKED()->GetStringChars(env,str,isCopy);
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1451
    assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringChars didn't return a copy as expected");
20387
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1452
    if (result != NULL) {
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1453
      size_t len = UNCHECKED()->GetStringLength(env,str) + 1; // + 1 for NULL termination
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1454
      len *= sizeof(jchar);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1455
      new_result = (jchar*) GuardedMemory::wrap_copy(result, len, STRING_TAG);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1456
      if (new_result == NULL) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1457
        vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringChars");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1458
      }
20387
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1459
      // Avoiding call to UNCHECKED()->ReleaseStringChars() since that will fire unexpected dtrace probes
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1460
      // Note that the dtrace arguments for the allocated memory will not match up with this solution.
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1461
      FreeHeap((char*)result);
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1462
    }
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1463
    functionExit(thr);
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1464
    return new_result;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
  checked_jni_ReleaseStringChars(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
                                 jstring str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
                                 const jchar *chars))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
    )
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1475
    if (chars == NULL) {
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1476
       // still do the unchecked call to allow dtrace probes
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1477
       UNCHECKED()->ReleaseStringChars(env,str,chars);
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1478
    }
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1479
    else {
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1480
      GuardedMemory guarded((void*)chars);
25059
fff9b51f4be4 8046662: Check JNI ReleaseStringChars / ReleaseStringUTFChars verify_guards test inverted
dsimms
parents: 25058
diff changeset
  1481
      if (!guarded.verify_guards()) {
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1482
        tty->print_cr("ReleaseStringChars: release chars failed bounds check. "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1483
            "string: " PTR_FORMAT " chars: " PTR_FORMAT, p2i(str), p2i(chars));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1484
        guarded.print_on(tty);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1485
        NativeReportJNIFatalError(thr, "ReleaseStringChars: "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1486
            "release chars failed bounds check.");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1487
      }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1488
      if (guarded.get_tag() != STRING_TAG) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1489
        tty->print_cr("ReleaseStringChars: called on something not allocated "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1490
            "by GetStringChars. string: " PTR_FORMAT " chars: " PTR_FORMAT,
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1491
            p2i(str), p2i(chars));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1492
        NativeReportJNIFatalError(thr, "ReleaseStringChars called on something "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1493
            "not allocated by GetStringChars");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1494
      }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1495
       UNCHECKED()->ReleaseStringChars(env, str,
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1496
           (const jchar*) guarded.release_for_freeing());
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1497
    }
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1498
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
JNI_ENTRY_CHECKED(jstring,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  checked_jni_NewStringUTF(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
                           const char *utf))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
    jstring result = UNCHECKED()->NewStringUTF(env,utf);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1506
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
JNI_ENTRY_CHECKED(jsize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
  checked_jni_GetStringUTFLength(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
                                 jstring str))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
    jsize result = UNCHECKED()->GetStringUTFLength(env,str);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1518
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1522
// Arbitrary (but well-known) tag - different than GetStringChars
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1523
const void* STRING_UTF_TAG = (void*) 0x48124812;
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1524
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
JNI_ENTRY_CHECKED(const char *,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
  checked_jni_GetStringUTFChars(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
                                jstring str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
                                jboolean *isCopy))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
    )
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1533
    char* new_result = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
    const char *result = UNCHECKED()->GetStringUTFChars(env,str,isCopy);
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1535
    assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringUTFChars didn't return a copy as expected");
20387
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1536
    if (result != NULL) {
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1537
      size_t len = strlen(result) + 1; // + 1 for NULL termination
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1538
      new_result = (char*) GuardedMemory::wrap_copy(result, len, STRING_UTF_TAG);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1539
      if (new_result == NULL) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1540
        vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringUTFChars");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1541
      }
20387
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1542
      // Avoiding call to UNCHECKED()->ReleaseStringUTFChars() since that will fire unexpected dtrace probes
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1543
      // Note that the dtrace arguments for the allocated memory will not match up with this solution.
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1544
      FreeHeap((char*)result, mtInternal);
df9f9f220120 8025922: JNI access to Strings need to check if the value field is non-null
sla
parents: 18942
diff changeset
  1545
    }
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1546
    functionExit(thr);
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1547
    return new_result;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
  checked_jni_ReleaseStringUTFChars(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
                                    jstring str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
                                    const char* chars))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
    )
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1558
    if (chars == NULL) {
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1559
       // still do the unchecked call to allow dtrace probes
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1560
       UNCHECKED()->ReleaseStringUTFChars(env,str,chars);
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1561
    }
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1562
    else {
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1563
      GuardedMemory guarded((void*)chars);
25059
fff9b51f4be4 8046662: Check JNI ReleaseStringChars / ReleaseStringUTFChars verify_guards test inverted
dsimms
parents: 25058
diff changeset
  1564
      if (!guarded.verify_guards()) {
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1565
        tty->print_cr("ReleaseStringUTFChars: release chars failed bounds check. "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1566
            "string: " PTR_FORMAT " chars: " PTR_FORMAT, p2i(str), p2i(chars));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1567
        guarded.print_on(tty);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1568
        NativeReportJNIFatalError(thr, "ReleaseStringUTFChars: "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1569
            "release chars failed bounds check.");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1570
      }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1571
      if (guarded.get_tag() != STRING_UTF_TAG) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1572
        tty->print_cr("ReleaseStringUTFChars: called on something not "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1573
            "allocated by GetStringUTFChars. string: " PTR_FORMAT " chars: "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1574
            PTR_FORMAT, p2i(str), p2i(chars));
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1575
        NativeReportJNIFatalError(thr, "ReleaseStringUTFChars "
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1576
            "called on something not allocated by GetStringUTFChars");
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1577
      }
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1578
      UNCHECKED()->ReleaseStringUTFChars(env, str,
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1579
          (const char*) guarded.release_for_freeing());
7414
940d84ca7fca 6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents: 7397
diff changeset
  1580
    }
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1581
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
JNI_ENTRY_CHECKED(jsize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
  checked_jni_GetArrayLength(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
                             jarray array))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
    IN_VM(
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1589
      check_is_array(thr, array);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
    jsize result = UNCHECKED()->GetArrayLength(env,array);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1592
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
JNI_ENTRY_CHECKED(jobjectArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
  checked_jni_NewObjectArray(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
                             jsize len,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
                             jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
                             jobject init))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
    jobjectArray result = UNCHECKED()->NewObjectArray(env,len,clazz,init);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1603
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  checked_jni_GetObjectArrayElement(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
                                    jobjectArray array,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
                                    jsize index))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
    IN_VM(
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1613
      check_is_obj_array(thr, array);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
    jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1616
    thr->set_pending_jni_exception_check("GetObjectArrayElement");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1617
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
  checked_jni_SetObjectArrayElement(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
                                    jobjectArray array,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
                                    jsize index,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
                                    jobject val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
    IN_VM(
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1628
      check_is_obj_array(thr, array);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
    UNCHECKED()->SetObjectArrayElement(env,array,index,val);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1631
    thr->set_pending_jni_exception_check("SetObjectArrayElement");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1632
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
#define WRAPPER_NewScalarArray(Return, Result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
JNI_ENTRY_CHECKED(Return, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
  checked_jni_New##Result##Array(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
                                 jsize len)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
    Return result = UNCHECKED()->New##Result##Array(env,len); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1641
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
    return (Return) result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
WRAPPER_NewScalarArray(jbooleanArray, Boolean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
WRAPPER_NewScalarArray(jbyteArray, Byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
WRAPPER_NewScalarArray(jshortArray, Short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
WRAPPER_NewScalarArray(jcharArray, Char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
WRAPPER_NewScalarArray(jintArray, Int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
WRAPPER_NewScalarArray(jlongArray, Long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
WRAPPER_NewScalarArray(jfloatArray, Float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
WRAPPER_NewScalarArray(jdoubleArray, Double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
#define WRAPPER_GetScalarArrayElements(ElementTag,ElementType,Result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
JNI_ENTRY_CHECKED(ElementType *,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
  checked_jni_Get##Result##ArrayElements(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
                                         ElementType##Array array, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
                                         jboolean *isCopy)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
    IN_VM( \
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1661
      check_primitive_array_type(thr, array, ElementTag); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
    ElementType *result = UNCHECKED()->Get##Result##ArrayElements(env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
                                                                  array, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
                                                                  isCopy); \
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1666
    if (result != NULL) { \
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1667
      result = (ElementType *) check_jni_wrap_copy_array(thr, array, result); \
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1668
    } \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1669
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
    return result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
WRAPPER_GetScalarArrayElements(T_BOOLEAN, jboolean, Boolean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
WRAPPER_GetScalarArrayElements(T_BYTE,    jbyte,    Byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
WRAPPER_GetScalarArrayElements(T_SHORT,   jshort,   Short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
WRAPPER_GetScalarArrayElements(T_CHAR,    jchar,    Char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
WRAPPER_GetScalarArrayElements(T_INT,     jint,     Int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
WRAPPER_GetScalarArrayElements(T_LONG,    jlong,    Long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
WRAPPER_GetScalarArrayElements(T_FLOAT,   jfloat,   Float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
WRAPPER_GetScalarArrayElements(T_DOUBLE,  jdouble,  Double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
#define WRAPPER_ReleaseScalarArrayElements(ElementTag,ElementType,Result,Tag) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
JNI_ENTRY_CHECKED(void,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
  checked_jni_Release##Result##ArrayElements(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
                                             ElementType##Array array, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
                                             ElementType *elems, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
                                             jint mode)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
    functionEnterExceptionAllowed(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
    IN_VM( \
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1690
      check_primitive_array_type(thr, array, ElementTag); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
      ASSERT_OOPS_ALLOWED; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
      typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
    ) \
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1694
    ElementType* orig_result = (ElementType *) check_wrapped_array_release( \
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1695
        thr, "checked_jni_Release"#Result"ArrayElements", array, elems, mode); \
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1696
    UNCHECKED()->Release##Result##ArrayElements(env, array, orig_result, mode); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1697
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
WRAPPER_ReleaseScalarArrayElements(T_BOOLEAN,jboolean, Boolean, bool)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
WRAPPER_ReleaseScalarArrayElements(T_BYTE,   jbyte,    Byte,    byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
WRAPPER_ReleaseScalarArrayElements(T_SHORT,  jshort,   Short,   short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
WRAPPER_ReleaseScalarArrayElements(T_CHAR,   jchar,    Char,    char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
WRAPPER_ReleaseScalarArrayElements(T_INT,    jint,     Int,     int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
WRAPPER_ReleaseScalarArrayElements(T_LONG,   jlong,    Long,    long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
WRAPPER_ReleaseScalarArrayElements(T_FLOAT,  jfloat,   Float,   float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
WRAPPER_ReleaseScalarArrayElements(T_DOUBLE, jdouble,  Double,  double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
#define WRAPPER_GetScalarArrayRegion(ElementTag,ElementType,Result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
JNI_ENTRY_CHECKED(void,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
  checked_jni_Get##Result##ArrayRegion(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
                                       ElementType##Array array, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
                                       jsize start, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
                                       jsize len, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
                                       ElementType *buf)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
    IN_VM( \
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1718
      check_primitive_array_type(thr, array, ElementTag); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
    UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1721
    thr->set_pending_jni_exception_check("Get"#Result"ArrayRegion"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1722
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
WRAPPER_GetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
WRAPPER_GetScalarArrayRegion(T_BYTE,    jbyte,    Byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
WRAPPER_GetScalarArrayRegion(T_SHORT,   jshort,   Short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
WRAPPER_GetScalarArrayRegion(T_CHAR,    jchar,    Char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
WRAPPER_GetScalarArrayRegion(T_INT,     jint,     Int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
WRAPPER_GetScalarArrayRegion(T_LONG,    jlong,    Long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
WRAPPER_GetScalarArrayRegion(T_FLOAT,   jfloat,   Float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
WRAPPER_GetScalarArrayRegion(T_DOUBLE,  jdouble,  Double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
#define WRAPPER_SetScalarArrayRegion(ElementTag,ElementType,Result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
JNI_ENTRY_CHECKED(void,  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
  checked_jni_Set##Result##ArrayRegion(JNIEnv *env, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
                                       ElementType##Array array, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
                                       jsize start, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
                                       jsize len, \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
                                       const ElementType *buf)) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
    functionEnter(thr); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
    IN_VM( \
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1743
      check_primitive_array_type(thr, array, ElementTag); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
    ) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
    UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1746
    thr->set_pending_jni_exception_check("Set"#Result"ArrayRegion"); \
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1747
    functionExit(thr); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
WRAPPER_SetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
WRAPPER_SetScalarArrayRegion(T_BYTE,    jbyte,    Byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
WRAPPER_SetScalarArrayRegion(T_SHORT,   jshort,   Short)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
WRAPPER_SetScalarArrayRegion(T_CHAR,    jchar,    Char)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
WRAPPER_SetScalarArrayRegion(T_INT,     jint,     Int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
WRAPPER_SetScalarArrayRegion(T_LONG,    jlong,    Long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
WRAPPER_SetScalarArrayRegion(T_FLOAT,   jfloat,   Float)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
WRAPPER_SetScalarArrayRegion(T_DOUBLE,  jdouble,  Double)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
  checked_jni_RegisterNatives(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
                              jclass clazz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
                              const JNINativeMethod *methods,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
                              jint nMethods))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
    jint result = UNCHECKED()->RegisterNatives(env,clazz,methods,nMethods);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1766
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
  checked_jni_UnregisterNatives(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
                                jclass clazz))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
    jint result = UNCHECKED()->UnregisterNatives(env,clazz);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1775
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
  checked_jni_MonitorEnter(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
                           jobject obj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
      jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
    jint result = UNCHECKED()->MonitorEnter(env,obj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1787
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
  checked_jni_MonitorExit(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
                          jobject obj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
      jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
    jint result = UNCHECKED()->MonitorExit(env,obj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1799
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
  checked_jni_GetJavaVM(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
                        JavaVM **vm))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
    jint result = UNCHECKED()->GetJavaVM(env,vm);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1808
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
  checked_jni_GetStringRegion(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
                              jstring str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
                              jsize start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
                              jsize len,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
                              jchar *buf))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
    UNCHECKED()->GetStringRegion(env, str, start, len, buf);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1823
    thr->set_pending_jni_exception_check("GetStringRegion");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1824
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
  checked_jni_GetStringUTFRegion(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
                                 jstring str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
                                 jsize start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
                                 jsize len,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
                                 char *buf))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
    UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1838
    thr->set_pending_jni_exception_check("GetStringUTFRegion");
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1839
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
JNI_ENTRY_CHECKED(void *,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
  checked_jni_GetPrimitiveArrayCritical(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
                                        jarray array,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
                                        jboolean *isCopy))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1846
    functionEnterCritical(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
    IN_VM(
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1848
      check_is_primitive_array(thr, array);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1849
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
    void *result = UNCHECKED()->GetPrimitiveArrayCritical(env, array, isCopy);
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1851
    if (result != NULL) {
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1852
      result = check_jni_wrap_copy_array(thr, array, result);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1853
    }
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1854
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
  checked_jni_ReleasePrimitiveArrayCritical(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
                                            jarray array,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
                                            void *carray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
                                            jint mode))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
    functionEnterCriticalExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
    IN_VM(
18937
34f568c7e7ca 6671508: JNI GetPrimitiveArrayCritical should not be callable on object arrays
mgerdin
parents: 14488
diff changeset
  1865
      check_is_primitive_array(thr, array);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
    )
25056
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1867
    // Check the element array...
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1868
    void* orig_result = check_wrapped_array_release(thr, "ReleasePrimitiveArrayCritical", array, carray, mode);
5ad92b0d1beb 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents: 24424
diff changeset
  1869
    UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, orig_result, mode);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1870
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
JNI_ENTRY_CHECKED(const jchar*,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
  checked_jni_GetStringCritical(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
                                jstring string,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
                                jboolean *isCopy))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
    functionEnterCritical(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
      checkString(thr, string);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
    const jchar *result = UNCHECKED()->GetStringCritical(env, string, isCopy);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1882
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
  checked_jni_ReleaseStringCritical(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
                                    jstring str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
                                    const jchar *chars))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
    functionEnterCriticalExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
      checkString(thr, str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1894
    /* The Hotspot JNI code does not use the parameters, so just check the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
     * string parameter as a minor sanity check
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
     */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
    UNCHECKED()->ReleaseStringCritical(env, str, chars);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1898
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
JNI_ENTRY_CHECKED(jweak,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
  checked_jni_NewWeakGlobalRef(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
                               jobject obj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
      if (obj != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
        jniCheck::validate_handle(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
    jweak result = UNCHECKED()->NewWeakGlobalRef(env, obj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1911
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
JNI_ENTRY_CHECKED(void,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
  checked_jni_DeleteWeakGlobalRef(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
                                  jweak ref))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
    UNCHECKED()->DeleteWeakGlobalRef(env, ref);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1920
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
JNI_ENTRY_CHECKED(jboolean,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
  checked_jni_ExceptionCheck(JNIEnv *env))
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1925
    thr->clear_pending_jni_exception_check();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
    functionEnterExceptionAllowed(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
    jboolean result = UNCHECKED()->ExceptionCheck(env);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1928
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
JNI_ENTRY_CHECKED(jobject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
  checked_jni_NewDirectByteBuffer(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
                                  void *address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
                                  jlong capacity))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
    jobject result = UNCHECKED()->NewDirectByteBuffer(env, address, capacity);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1938
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
JNI_ENTRY_CHECKED(void *,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
  checked_jni_GetDirectBufferAddress(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
                                     jobject buf))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
    void* result = UNCHECKED()->GetDirectBufferAddress(env, buf);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1947
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
JNI_ENTRY_CHECKED(jlong,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
  checked_jni_GetDirectBufferCapacity(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
                                      jobject buf))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
    jlong result = UNCHECKED()->GetDirectBufferCapacity(env, buf);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1956
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
JNI_ENTRY_CHECKED(jobjectRefType,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  checked_jni_GetObjectRefType(JNIEnv *env,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
                               jobject obj))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
    /* validate the object being passed */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
    IN_VM(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
      jniCheck::validate_object(thr, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
    )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
    jobjectRefType result = UNCHECKED()->GetObjectRefType(env, obj);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1969
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
JNI_ENTRY_CHECKED(jint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
  checked_jni_GetVersion(JNIEnv *env))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
    functionEnter(thr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
    jint result = UNCHECKED()->GetVersion(env);
25058
4542f853c2ac 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
dsimms
parents: 25056
diff changeset
  1978
    functionExit(thr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
JNI_END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
 * Structure containing all checked jni functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
struct JNINativeInterface_  checked_jni_NativeInterface = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
    NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
    NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
    NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
    NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
    checked_jni_GetVersion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
    checked_jni_DefineClass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
    checked_jni_FindClass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
    checked_jni_FromReflectedMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
    checked_jni_FromReflectedField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
    checked_jni_ToReflectedMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
    checked_jni_GetSuperclass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
    checked_jni_IsAssignableFrom,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
    checked_jni_ToReflectedField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
    checked_jni_Throw,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
    checked_jni_ThrowNew,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
    checked_jni_ExceptionOccurred,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
    checked_jni_ExceptionDescribe,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
    checked_jni_ExceptionClear,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
    checked_jni_FatalError,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
    checked_jni_PushLocalFrame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
    checked_jni_PopLocalFrame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
    checked_jni_NewGlobalRef,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
    checked_jni_DeleteGlobalRef,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
    checked_jni_DeleteLocalRef,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
    checked_jni_IsSameObject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
    checked_jni_NewLocalRef,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
    checked_jni_EnsureLocalCapacity,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
    checked_jni_AllocObject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
    checked_jni_NewObject,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
    checked_jni_NewObjectV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
    checked_jni_NewObjectA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
    checked_jni_GetObjectClass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
    checked_jni_IsInstanceOf,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
    checked_jni_GetMethodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
    checked_jni_CallObjectMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
    checked_jni_CallObjectMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
    checked_jni_CallObjectMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
    checked_jni_CallBooleanMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
    checked_jni_CallBooleanMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
    checked_jni_CallBooleanMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
    checked_jni_CallByteMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
    checked_jni_CallByteMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
    checked_jni_CallByteMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
    checked_jni_CallCharMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
    checked_jni_CallCharMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
    checked_jni_CallCharMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
    checked_jni_CallShortMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
    checked_jni_CallShortMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
    checked_jni_CallShortMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
    checked_jni_CallIntMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
    checked_jni_CallIntMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
    checked_jni_CallIntMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
    checked_jni_CallLongMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
    checked_jni_CallLongMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
    checked_jni_CallLongMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
    checked_jni_CallFloatMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
    checked_jni_CallFloatMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
    checked_jni_CallFloatMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
    checked_jni_CallDoubleMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
    checked_jni_CallDoubleMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
    checked_jni_CallDoubleMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
    checked_jni_CallVoidMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
    checked_jni_CallVoidMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
    checked_jni_CallVoidMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
    checked_jni_CallNonvirtualObjectMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
    checked_jni_CallNonvirtualObjectMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
    checked_jni_CallNonvirtualObjectMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
    checked_jni_CallNonvirtualBooleanMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
    checked_jni_CallNonvirtualBooleanMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
    checked_jni_CallNonvirtualBooleanMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
    checked_jni_CallNonvirtualByteMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
    checked_jni_CallNonvirtualByteMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
    checked_jni_CallNonvirtualByteMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
    checked_jni_CallNonvirtualCharMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
    checked_jni_CallNonvirtualCharMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
    checked_jni_CallNonvirtualCharMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
    checked_jni_CallNonvirtualShortMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
    checked_jni_CallNonvirtualShortMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
    checked_jni_CallNonvirtualShortMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
    checked_jni_CallNonvirtualIntMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
    checked_jni_CallNonvirtualIntMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
    checked_jni_CallNonvirtualIntMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
    checked_jni_CallNonvirtualLongMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
    checked_jni_CallNonvirtualLongMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
    checked_jni_CallNonvirtualLongMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
    checked_jni_CallNonvirtualFloatMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
    checked_jni_CallNonvirtualFloatMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
    checked_jni_CallNonvirtualFloatMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
    checked_jni_CallNonvirtualDoubleMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
    checked_jni_CallNonvirtualDoubleMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
    checked_jni_CallNonvirtualDoubleMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
    checked_jni_CallNonvirtualVoidMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
    checked_jni_CallNonvirtualVoidMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
    checked_jni_CallNonvirtualVoidMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
    checked_jni_GetFieldID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
    checked_jni_GetObjectField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
    checked_jni_GetBooleanField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
    checked_jni_GetByteField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
    checked_jni_GetCharField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
    checked_jni_GetShortField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
    checked_jni_GetIntField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
    checked_jni_GetLongField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
    checked_jni_GetFloatField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
    checked_jni_GetDoubleField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
    checked_jni_SetObjectField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
    checked_jni_SetBooleanField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
    checked_jni_SetByteField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
    checked_jni_SetCharField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
    checked_jni_SetShortField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
    checked_jni_SetIntField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
    checked_jni_SetLongField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
    checked_jni_SetFloatField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
    checked_jni_SetDoubleField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
    checked_jni_GetStaticMethodID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
    checked_jni_CallStaticObjectMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
    checked_jni_CallStaticObjectMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
    checked_jni_CallStaticObjectMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
    checked_jni_CallStaticBooleanMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
    checked_jni_CallStaticBooleanMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
    checked_jni_CallStaticBooleanMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
    checked_jni_CallStaticByteMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
    checked_jni_CallStaticByteMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
    checked_jni_CallStaticByteMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
    checked_jni_CallStaticCharMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
    checked_jni_CallStaticCharMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
    checked_jni_CallStaticCharMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
    checked_jni_CallStaticShortMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
    checked_jni_CallStaticShortMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
    checked_jni_CallStaticShortMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
    checked_jni_CallStaticIntMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
    checked_jni_CallStaticIntMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
    checked_jni_CallStaticIntMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
    checked_jni_CallStaticLongMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
    checked_jni_CallStaticLongMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
    checked_jni_CallStaticLongMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
    checked_jni_CallStaticFloatMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
    checked_jni_CallStaticFloatMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
    checked_jni_CallStaticFloatMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
    checked_jni_CallStaticDoubleMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
    checked_jni_CallStaticDoubleMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
    checked_jni_CallStaticDoubleMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
    checked_jni_CallStaticVoidMethod,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
    checked_jni_CallStaticVoidMethodV,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
    checked_jni_CallStaticVoidMethodA,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
    checked_jni_GetStaticFieldID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2155
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
    checked_jni_GetStaticObjectField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
    checked_jni_GetStaticBooleanField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
    checked_jni_GetStaticByteField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
    checked_jni_GetStaticCharField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
    checked_jni_GetStaticShortField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2161
    checked_jni_GetStaticIntField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
    checked_jni_GetStaticLongField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
    checked_jni_GetStaticFloatField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
    checked_jni_GetStaticDoubleField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
    checked_jni_SetStaticObjectField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
    checked_jni_SetStaticBooleanField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
    checked_jni_SetStaticByteField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
    checked_jni_SetStaticCharField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
    checked_jni_SetStaticShortField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
    checked_jni_SetStaticIntField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
    checked_jni_SetStaticLongField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
    checked_jni_SetStaticFloatField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
    checked_jni_SetStaticDoubleField,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
    checked_jni_NewString,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
    checked_jni_GetStringLength,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
    checked_jni_GetStringChars,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
    checked_jni_ReleaseStringChars,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
    checked_jni_NewStringUTF,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
    checked_jni_GetStringUTFLength,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
    checked_jni_GetStringUTFChars,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
    checked_jni_ReleaseStringUTFChars,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
    checked_jni_GetArrayLength,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
    checked_jni_NewObjectArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
    checked_jni_GetObjectArrayElement,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
    checked_jni_SetObjectArrayElement,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
    checked_jni_NewBooleanArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
    checked_jni_NewByteArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
    checked_jni_NewCharArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
    checked_jni_NewShortArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
    checked_jni_NewIntArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
    checked_jni_NewLongArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
    checked_jni_NewFloatArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
    checked_jni_NewDoubleArray,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
    checked_jni_GetBooleanArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
    checked_jni_GetByteArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
    checked_jni_GetCharArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
    checked_jni_GetShortArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
    checked_jni_GetIntArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
    checked_jni_GetLongArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
    checked_jni_GetFloatArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
    checked_jni_GetDoubleArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
    checked_jni_ReleaseBooleanArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
    checked_jni_ReleaseByteArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
    checked_jni_ReleaseCharArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
    checked_jni_ReleaseShortArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
    checked_jni_ReleaseIntArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
    checked_jni_ReleaseLongArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
    checked_jni_ReleaseFloatArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
    checked_jni_ReleaseDoubleArrayElements,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
    checked_jni_GetBooleanArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
    checked_jni_GetByteArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
    checked_jni_GetCharArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
    checked_jni_GetShortArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
    checked_jni_GetIntArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
    checked_jni_GetLongArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
    checked_jni_GetFloatArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
    checked_jni_GetDoubleArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
    checked_jni_SetBooleanArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
    checked_jni_SetByteArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
    checked_jni_SetCharArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
    checked_jni_SetShortArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
    checked_jni_SetIntArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
    checked_jni_SetLongArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
    checked_jni_SetFloatArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
    checked_jni_SetDoubleArrayRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
    checked_jni_RegisterNatives,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
    checked_jni_UnregisterNatives,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
    checked_jni_MonitorEnter,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
    checked_jni_MonitorExit,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
    checked_jni_GetJavaVM,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
    checked_jni_GetStringRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
    checked_jni_GetStringUTFRegion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
    checked_jni_GetPrimitiveArrayCritical,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
    checked_jni_ReleasePrimitiveArrayCritical,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
    checked_jni_GetStringCritical,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
    checked_jni_ReleaseStringCritical,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
    checked_jni_NewWeakGlobalRef,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
    checked_jni_DeleteWeakGlobalRef,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
    checked_jni_ExceptionCheck,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
    checked_jni_NewDirectByteBuffer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
    checked_jni_GetDirectBufferAddress,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
    checked_jni_GetDirectBufferCapacity,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
    // New 1.6 Features
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
    checked_jni_GetObjectRefType
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
// Returns the function structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
struct JNINativeInterface_* jni_functions_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
  unchecked_jni_NativeInterface = jni_functions_nocheck();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
  // make sure the last pointer in the checked table is not null, indicating
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
  // an addition to the JNINativeInterface_ structure without initializing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
  // it in the checked table.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
  debug_only(int *lastPtr = (int *)((char *)&checked_jni_NativeInterface + \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
             sizeof(*unchecked_jni_NativeInterface) - sizeof(char *));)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
  assert(*lastPtr != 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
         "Mismatched JNINativeInterface tables, check for new entries");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
  // with -verbose:jni this message will print
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
  if (PrintJNIResolving) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
    tty->print_cr("Checked JNI functions are being used to " \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
                  "validate JNI usage");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
  return &checked_jni_NativeInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
}