src/share/vm/utilities/preserveException.cpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "incls/_precompiled.incl"
  26 #include "incls/_preserveException.cpp.incl"

  27 
  28 // TODO: These three classes should be refactored
  29 
  30 PreserveExceptionMark::PreserveExceptionMark(Thread*& thread) {
  31   thread     = Thread::current();
  32   _thread    = thread;
  33   _preserved_exception_oop = Handle(thread, _thread->pending_exception());
  34   _thread->clear_pending_exception(); // Needed to avoid infinite recursion
  35   _preserved_exception_line = _thread->exception_line();
  36   _preserved_exception_file = _thread->exception_file();
  37 }
  38 
  39 
  40 PreserveExceptionMark::~PreserveExceptionMark() {
  41   if (_thread->has_pending_exception()) {
  42     oop exception = _thread->pending_exception();
  43     _thread->clear_pending_exception(); // Needed to avoid infinite recursion
  44     exception->print();
  45     fatal("PreserveExceptionMark destructor expects no pending exceptions");
  46   }


   1 /*
   2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "runtime/handles.inline.hpp"
  27 #include "utilities/preserveException.hpp"
  28 
  29 // TODO: These three classes should be refactored
  30 
  31 PreserveExceptionMark::PreserveExceptionMark(Thread*& thread) {
  32   thread     = Thread::current();
  33   _thread    = thread;
  34   _preserved_exception_oop = Handle(thread, _thread->pending_exception());
  35   _thread->clear_pending_exception(); // Needed to avoid infinite recursion
  36   _preserved_exception_line = _thread->exception_line();
  37   _preserved_exception_file = _thread->exception_file();
  38 }
  39 
  40 
  41 PreserveExceptionMark::~PreserveExceptionMark() {
  42   if (_thread->has_pending_exception()) {
  43     oop exception = _thread->pending_exception();
  44     _thread->clear_pending_exception(); // Needed to avoid infinite recursion
  45     exception->print();
  46     fatal("PreserveExceptionMark destructor expects no pending exceptions");
  47   }