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/jniHandles.hpp
          +++ new/hotspot/src/share/vm/runtime/jniHandles.hpp
   1    1  /*
   2      - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 1998, 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 ↓ 92 lines elided ↑ open up ↑
 105  105    int             _top;                         // Index of next unused handle
 106  106    JNIHandleBlock* _next;                        // Link to next block
 107  107  
 108  108    // The following instance variables are only used by the first block in a chain.
 109  109    // Having two types of blocks complicates the code and the space overhead in negligble.
 110  110    JNIHandleBlock* _last;                        // Last block in use
 111  111    JNIHandleBlock* _pop_frame_link;              // Block to restore on PopLocalFrame call
 112  112    oop*            _free_list;                   // Handle free list
 113  113    int             _allocate_before_rebuild;     // Number of blocks to allocate before rebuilding free list
 114  114  
      115 +  // Check JNI, "planned capacity" for current frame (or push/ensure)
      116 +  size_t          _planned_capacity;
      117 +
 115  118    #ifndef PRODUCT
 116  119    JNIHandleBlock* _block_list_link;             // Link for list below
 117  120    static JNIHandleBlock* _block_list;           // List of all allocated blocks (for debugging only)
 118  121    #endif
 119  122  
 120  123    static JNIHandleBlock* _block_free_list;      // Free list of currently unused blocks
 121  124    static int      _blocks_allocated;            // For debugging/printing
 122  125  
 123  126    // Fill block with bad_handle values
 124  127    void zap();
↓ open down ↓ 20 lines elided ↑ open up ↑
 145  148  
 146  149    // Stub generator support
 147  150    static int top_offset_in_bytes()                { return offset_of(JNIHandleBlock, _top); }
 148  151  
 149  152    // Garbage collection support
 150  153    // Traversal of regular handles
 151  154    void oops_do(OopClosure* f);
 152  155    // Traversal of weak handles. Unreachable oops are cleared.
 153  156    void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
 154  157  
      158 +  // Checked JNI support
      159 +  void set_planned_capacity(size_t planned_capacity) { _planned_capacity = planned_capacity; }
      160 +  const size_t get_planned_capacity() { return _planned_capacity; }
      161 +  const size_t get_number_of_live_handles();
      162 +
 155  163    // Debugging
 156  164    bool chain_contains(jobject handle) const;    // Does this block or following blocks contain handle
 157  165    bool contains(jobject handle) const;          // Does this block contain handle
 158  166    int length() const;                           // Length of chain starting with this block
 159  167    long memory_usage() const;
 160  168    #ifndef PRODUCT
 161  169    static bool any_contains(jobject handle);     // Does any block currently in use contain handle
 162  170    static void print_statistics();
 163  171    #endif
 164  172  };
↓ open down ↓ 35 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX