Print this page
rev 7151 : 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
Summary: Warning when not checking exceptions from function that require so, also when local refs expand beyond capacity.
Reviewed-by: dsimms

Split Split Close
Expand all
Collapse all
          --- old/hotspot/src/share/vm/runtime/thread.hpp
          +++ new/hotspot/src/share/vm/runtime/thread.hpp
   1    1  /*
   2      - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 906 lines elided ↑ open up ↑
 919  919    // used to temp. parsing values into and out of the runtime system during exception handling for compiled
 920  920    // code)
 921  921    volatile oop     _exception_oop;               // Exception thrown in compiled code
 922  922    volatile address _exception_pc;                // PC where exception happened
 923  923    volatile address _exception_handler_pc;        // PC for handler of exception
 924  924    volatile int     _is_method_handle_return;     // true (== 1) if the current exception PC is a MethodHandle call site.
 925  925  
 926  926    // support for JNI critical regions
 927  927    jint    _jni_active_critical;                  // count of entries into JNI critical region
 928  928  
      929 +  // Checked JNI: function name requires exception check
      930 +  char* _pending_jni_exception_check_fn;
      931 +
 929  932    // For deadlock detection.
 930  933    int _depth_first_number;
 931  934  
 932  935    // JVMTI PopFrame support
 933  936    // This is set to popframe_pending to signal that top Java frame should be popped immediately
 934  937    int _popframe_condition;
 935  938  
 936  939    // If reallocation of scalar replaced objects fails, we throw OOM
 937  940    // and during exception propagation, pop the top
 938  941    // _frames_to_pop_failed_realloc frames, the ones that reference
↓ open down ↓ 462 lines elided ↑ open up ↑
1401 1404    void enter_critical() { assert(Thread::current() == this ||
1402 1405                                   Thread::current()->is_VM_thread() && SafepointSynchronize::is_synchronizing(),
1403 1406                                   "this must be current thread or synchronizing");
1404 1407                            _jni_active_critical++; }
1405 1408    void exit_critical()  { assert(Thread::current() == this,
1406 1409                                   "this must be current thread");
1407 1410                            _jni_active_critical--;
1408 1411                            assert(_jni_active_critical >= 0,
1409 1412                                   "JNI critical nesting problem?"); }
1410 1413  
     1414 +  // Checked JNI, is the programmer required to check for exceptions, specify which function name
     1415 +  bool is_pending_jni_exception_check() const { return _pending_jni_exception_check_fn != NULL; }
     1416 +  void clear_pending_jni_exception_check() { _pending_jni_exception_check_fn = NULL; }
     1417 +  const char* get_pending_jni_exception_check() const { return _pending_jni_exception_check_fn; }
     1418 +  void set_pending_jni_exception_check(const char* fn_name) { _pending_jni_exception_check_fn = (char*) fn_name; }
     1419 +
1411 1420    // For deadlock detection
1412 1421    int depth_first_number() { return _depth_first_number; }
1413 1422    void set_depth_first_number(int dfn) { _depth_first_number = dfn; }
1414 1423  
1415 1424   private:
1416 1425    void set_monitor_chunks(MonitorChunk* monitor_chunks) { _monitor_chunks = monitor_chunks; }
1417 1426  
1418 1427   public:
1419 1428    MonitorChunk* monitor_chunks() const           { return _monitor_chunks; }
1420 1429    void add_monitor_chunk(MonitorChunk* chunk);
↓ open down ↓ 591 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX