InheritAgent1011.java revision 2362
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil/*
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil *
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * This code is free software; you can redistribute it and/or modify it
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * under the terms of the GNU General Public License version 2 only, as
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * published by the Free Software Foundation.
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil *
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * This code is distributed in the hope that it will be useful, but WITHOUT
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * version 2 for more details (a copy is included in the LICENSE file that
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * accompanied this code).
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil *
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * You should have received a copy of the GNU General Public License version
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * 2 along with this work; if not, write to the Free Software Foundation,
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil *
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * or visit www.oracle.com if you need additional information or have any
b6ada49236374a1f4ae462c384d69bab7e6f0a1dGustavo Lopes * questions.
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil */
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil/**
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * @test
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * @bug 6289149
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * @summary test config (1,0,1,1): inherited 2-arg, declared 2-arg and declared 1-arg in agent class
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * @author Daniel D. Daugherty, Sun Microsystems
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil *
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes * @run shell ../MakeJAR3.sh InheritAgent1011
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil * @run main/othervm -javaagent:InheritAgent1011.jar DummyMain
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil */
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladilimport java.lang.instrument.*;
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladilclass InheritAgent1011 extends InheritAgent1011Super {
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil //
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil // This agent has a single argument premain() method which
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes // is NOT the one that should be called.
b6ada49236374a1f4ae462c384d69bab7e6f0a1dGustavo Lopes //
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil public static void premain (String agentArgs) {
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil System.out.println("Hello from Single-Arg InheritAgent1011!");
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil }
5c22aad0392c68f935e17cd0a1b14bd855a8080bMiroslav Osladil
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes //
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes // This agent has a double argument premain() method which
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes // is the one that should be called.
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes //
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes public static void premain (String agentArgs, Instrumentation instArg) {
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes System.out.println("Hello from Double-Arg InheritAgent1011!");
4ba71cbfd0bf73ffdb68d7bb3010f9dab9197aa6Gustavo Lopes }
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes}
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopes
656361374a9c4c7614c61b28c86f087773dc35dcGustavo Lopesclass InheritAgent1011Super {
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes // This agent does NOT have a single argument premain() method.
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes //
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes // This agent has a double argument premain() method which
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes // is NOT the one that should be called.
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes //
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes public static void premain (String agentArgs, Instrumentation instArg) {
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes System.out.println("Hello from Double-Arg InheritAgent1011Super!");
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
a96cbe15da1b5e0a83e9ad03ac103734fc6ef64dGustavo Lopes }
2f1d1e46769e539095f74416cad9129d31d2616eGustavo Lopes}
2f1d1e46769e539095f74416cad9129d31d2616eGustavo Lopes