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 |
387 /* |
387 /* |
388 * OK, Java is up now. We can start everything that needs Java. |
388 * OK, Java is up now. We can start everything that needs Java. |
389 */ |
389 */ |
390 |
390 |
391 /* |
391 /* |
392 * First make our emergency fallback InternalError throwable. |
392 * First make our fallback InternalError throwable. |
393 */ |
393 */ |
394 result = initializeFallbackError(jnienv); |
394 result = initializeFallbackError(jnienv); |
395 jplis_assert(result); |
395 jplis_assert_msg(result, "fallback init failed"); |
396 |
396 |
397 /* |
397 /* |
398 * Now make the InstrumentationImpl instance. |
398 * Now make the InstrumentationImpl instance. |
399 */ |
399 */ |
400 if ( result ) { |
400 if ( result ) { |
401 result = createInstrumentationImpl(jnienv, agent); |
401 result = createInstrumentationImpl(jnienv, agent); |
402 jplis_assert(result); |
402 jplis_assert_msg(result, "instrumentation instance creation failed"); |
403 } |
403 } |
404 |
404 |
405 |
405 |
406 /* |
406 /* |
407 * Register a handler for ClassFileLoadHook (without enabling this event). |
407 * Register a handler for ClassFileLoadHook (without enabling this event). |
408 * Turn off the VMInit handler. |
408 * Turn off the VMInit handler. |
409 */ |
409 */ |
410 if ( result ) { |
410 if ( result ) { |
411 result = setLivePhaseEventHandlers(agent); |
411 result = setLivePhaseEventHandlers(agent); |
412 jplis_assert(result); |
412 jplis_assert_msg(result, "setting of live phase VM handlers failed"); |
413 } |
413 } |
414 |
414 |
415 /* |
415 /* |
416 * Load the Java agent, and call the premain. |
416 * Load the Java agent, and call the premain. |
417 */ |
417 */ |
418 if ( result ) { |
418 if ( result ) { |
419 result = startJavaAgent(agent, jnienv, |
419 result = startJavaAgent(agent, jnienv, |
420 agent->mAgentClassName, agent->mOptionsString, |
420 agent->mAgentClassName, agent->mOptionsString, |
421 agent->mPremainCaller); |
421 agent->mPremainCaller); |
|
422 jplis_assert_msg(result, "agent load/premain call failed"); |
422 } |
423 } |
423 |
424 |
424 /* |
425 /* |
425 * Finally surrender all of the tracking data that we don't need any more. |
426 * Finally surrender all of the tracking data that we don't need any more. |
426 * If something is wrong, skip it, we will be aborting the JVM anyway. |
427 * If something is wrong, skip it, we will be aborting the JVM anyway. |