1620N/A/*
1620N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
1620N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1620N/A *
1620N/A * This code is free software; you can redistribute it and/or modify it
1620N/A * under the terms of the GNU General Public License version 2 only, as
1620N/A * published by the Free Software Foundation.
1620N/A *
1620N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1620N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1620N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1620N/A * version 2 for more details (a copy is included in the LICENSE file that
1620N/A * accompanied this code).
1620N/A *
1620N/A * You should have received a copy of the GNU General Public License version
1620N/A * 2 along with this work; if not, write to the Free Software Foundation,
1620N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1620N/A *
1620N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1620N/A * or visit www.oracle.com if you need additional information or have any
1620N/A * questions.
1620N/A */
1620N/A
1620N/Aimport java.lang.instrument.Instrumentation;
1620N/A
1620N/A/*
1620N/A * Copyright 2003 Wily Technology, Inc.
1620N/A */
1620N/A
1620N/A/**
1620N/A * A JPLIS agent that makes the Instrumentation available via a static accessor.
1620N/A * Used so that unit test frameworks that run as apps can exercise the Instrumentation--
1620N/A * configure this guy as a JPLIS agent, then call the Instrumentation fetcher from the test case.
1620N/A *
1620N/A */
1620N/Apublic class InstrumentationHandoff
1620N/A{
1620N/A private static Instrumentation sInstrumentation;
1620N/A
1620N/A // disallow construction
1620N/A private
1620N/A InstrumentationHandoff()
1620N/A {
1620N/A }
1620N/A
1620N/A public static void
1620N/A premain(String options, Instrumentation inst)
1620N/A {
1620N/A System.out.println("InstrumentationHandoff JPLIS agent initialized");
1620N/A sInstrumentation = inst;
1620N/A }
1620N/A
1620N/A // may return null
1620N/A public static Instrumentation
1620N/A getInstrumentation()
1620N/A {
1620N/A return sInstrumentation;
1620N/A }
1620N/A
1620N/A public static Instrumentation
1620N/A getInstrumentationOrThrow()
1620N/A {
1620N/A Instrumentation result = getInstrumentation();
1620N/A if ( result == null )
1620N/A {
1620N/A throw new NullPointerException("instrumentation instance not initialized");
1620N/A }
1620N/A return result;
1620N/A }
1620N/A
1620N/A
1620N/A}
1620N/A