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.cpp
          +++ new/hotspot/src/share/vm/runtime/jniHandles.cpp
   1    1  /*
   2      - * Copyright (c) 1998, 2014, 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 ↓ 276 lines elided ↑ open up ↑
 289  289        #endif
 290  290      } else {
 291  291        // Get block from free list
 292  292        block = _block_free_list;
 293  293        _block_free_list = _block_free_list->_next;
 294  294      }
 295  295    }
 296  296    block->_top  = 0;
 297  297    block->_next = NULL;
 298  298    block->_pop_frame_link = NULL;
      299 +  block->_planned_capacity = block_size_in_oops;
 299  300    // _last, _free_list & _allocate_before_rebuild initialized in allocate_handle
 300  301    debug_only(block->_last = NULL);
 301  302    debug_only(block->_free_list = NULL);
 302  303    debug_only(block->_allocate_before_rebuild = -1);
 303  304    return block;
 304  305  }
 305  306  
 306  307  
 307  308  void JNIHandleBlock::release_block(JNIHandleBlock* block, Thread* thread) {
 308  309    assert(thread == NULL || thread == Thread::current(), "sanity check");
↓ open down ↓ 213 lines elided ↑ open up ↑
 522  523  
 523  524  
 524  525  int JNIHandleBlock::length() const {
 525  526    int result = 1;
 526  527    for (JNIHandleBlock* current = _next; current != NULL; current = current->_next) {
 527  528      result++;
 528  529    }
 529  530    return result;
 530  531  }
 531  532  
      533 +const size_t JNIHandleBlock::get_number_of_live_handles() {
      534 +  CountHandleClosure counter;
      535 +  oops_do(&counter);
      536 +  return counter.count();
      537 +}
      538 +
 532  539  // This method is not thread-safe, i.e., must be called whule holding a lock on the
 533  540  // structure.
 534  541  long JNIHandleBlock::memory_usage() const {
 535  542    return length() * sizeof(JNIHandleBlock);
 536  543  }
 537  544  
 538  545  
 539  546  #ifndef PRODUCT
 540  547  
 541  548  bool JNIHandleBlock::any_contains(jobject handle) {
↓ open down ↓ 33 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX