blob: 06832f4d44a38deedbd9b75579f06b19ea7e003a [file] [log] [blame]
/**********************************************************************
// @@@ START COPYRIGHT @@@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
// @@@ END COPYRIGHT @@@
**********************************************************************/
#ifndef LMJAVAHOOKS_H
#define LMJAVAHOOKS_H
/* -*-C++-*-
******************************************************************************
*
* File: LmJavaHooks.h
* Description: A class containing static functions that we register
* as callback functions when we create a JVM
*
* Created: June 2003
* Language: C++
*
*
******************************************************************************
*/
#include "Platform.h"
#include "lmjni.h"
#include <stdarg.h>
#include <stdio.h>
#define LMJ_HOOK_TEXT_BUF_SIZE 2048
class LmJavaHooks
{
public:
// These are the callback functions that the JVM will call
static void JNICALL abortHookJVM();
static void JNICALL exitHookJVM(jint);
static jint JNICALL vfprintfHookJVM(FILE *, const char *, va_list);
// These are functions called by the layer of code that creates the
// JVM. init_vfprintfHook() should be called before creating the
// JVM. get_vfprintfText() can can be called anytime after JVM
// creation or anytime the JVM is running, to see if any console
// messages have been generated by the JVM.
static void init_vfprintfHook();
static const char *get_vfprintfText() { return textBuf_; }
private:
// We are storing JVM console messages in a global text
// buffer. Sometimes after an MXUDR crash it is useful to load the
// saveabend file into a debugger and display the contents of this
// buffer (e.g. in INSPECT enter "d LmJavaHooks::textBuf_"). You may
// discover some error information reported by the JVM that did not
// get packaged into SQL diagnostics for the calling application.
static char textBuf_[LMJ_HOOK_TEXT_BUF_SIZE];
};
#endif // LMJAVAHOOKS_H