src/java.instrument/share/native/libinstrument/InvocationAdapter.c
changeset 54187 f554d3e88da3
parent 47777 d85284ccd1bd
equal deleted inserted replaced
54186:3827cd66e788 54187:f554d3e88da3
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   556     jboolean           success      = JNI_FALSE;
   556     jboolean           success      = JNI_FALSE;
   557 
   557 
   558     environment = getJPLISEnvironment(jvmtienv);
   558     environment = getJPLISEnvironment(jvmtienv);
   559 
   559 
   560     /* process the premain calls on the all the JPL agents */
   560     /* process the premain calls on the all the JPL agents */
   561     if ( environment != NULL ) {
   561     if (environment == NULL) {
   562         jthrowable outstandingException = NULL;
   562         abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART ", getting JPLIS environment failed");
   563         /*
   563     }
   564          * Add the jarfile to the system class path
   564     jthrowable outstandingException = NULL;
   565          */
   565     /*
   566         JPLISAgent * agent = environment->mAgent;
   566      * Add the jarfile to the system class path
   567         if (appendClassPath(agent, agent->mJarfile)) {
   567      */
   568             fprintf(stderr, "Unable to add %s to system class path - "
   568     JPLISAgent * agent = environment->mAgent;
   569                     "the system class loader does not define the "
   569     if (appendClassPath(agent, agent->mJarfile)) {
   570                     "appendToClassPathForInstrumentation method or the method failed\n",
   570         fprintf(stderr, "Unable to add %s to system class path - "
   571                     agent->mJarfile);
   571                 "the system class loader does not define the "
   572             free((void *)agent->mJarfile);
   572                 "appendToClassPathForInstrumentation method or the method failed\n",
   573             abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART);
   573                 agent->mJarfile);
   574         }
       
   575         free((void *)agent->mJarfile);
   574         free((void *)agent->mJarfile);
   576         agent->mJarfile = NULL;
   575         abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART ", appending to system class path failed");
   577 
   576     }
   578         outstandingException = preserveThrowable(jnienv);
   577     free((void *)agent->mJarfile);
   579         success = processJavaStart( environment->mAgent,
   578     agent->mJarfile = NULL;
   580                                     jnienv);
   579 
   581         restoreThrowable(jnienv, outstandingException);
   580     outstandingException = preserveThrowable(jnienv);
   582     }
   581     success = processJavaStart( environment->mAgent, jnienv);
       
   582     restoreThrowable(jnienv, outstandingException);
   583 
   583 
   584     /* if we fail to start cleanly, bring down the JVM */
   584     /* if we fail to start cleanly, bring down the JVM */
   585     if ( !success ) {
   585     if ( !success ) {
   586         abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART);
   586         abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART ", processJavaStart failed");
   587     }
   587     }
   588 }
   588 }
   589 
   589 
   590 void JNICALL
   590 void JNICALL
   591 eventHandlerClassFileLoadHook(  jvmtiEnv *              jvmtienv,
   591 eventHandlerClassFileLoadHook(  jvmtiEnv *              jvmtienv,