A java agent subscribes to the JVMTI_EVENT_CLASS_LOAD event.
Upon receiving the JVMTI_EVENT_CLASS_LOAD notification the agent invokes GetMethodID(env, klass, "toString", "()Ljava/lang/String;"); and prints the name of the loaded class.
However after some time the program always crashes with the same output:
Loaded class class java.lang.ExceptionInInitializerError
Loaded class class java.lang.IllegalAccessException
Loaded class class java.lang.IllegalAccessException
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/systemDictionary.cpp:849
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/HUDSON/workspace/9-2-build-linux-amd64-phase2/jdk9/4770/hotspot/src/share/vm/classfile/systemDictionary.cpp:849), pid=21145, tid=21146
# guarantee((!class_loader.is_null())) failed: dup definition for bootstrap loader?
#
# JRE version: Java(TM) SE Runtime Environment (9.0+112) (fastdebug build 9-ea+112)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 9-ea+112, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/akulyakh/nstep/core.21145)
#
# An error report file with more information is saved as:
# /home/akulyakh/nstep/hs_err_pid21145.log
Phoning home...
Using server: 10.161.186.18, port 4711
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Happens every time on b112 build. Does not happen on the Java 8 builds.
To reproduce, using the attached agent.c:
JDK_ROOT=${JAVA_HOME}
JDK_INCLUDE=${JDK_ROOT}/include
OS=linux
JDK_INCLUDE_PLATFORM=${JDK_INCLUDE}/${OS}
COMPILE_OPTS="-c -fPIC"
gcc ${COMPILE_OPTS} -I${JDK_INCLUDE} -I${JDK_INCLUDE_PLATFORM} -o agent.o agent.c
LIB_OPTS="-shared"
gcc ${LIB_OPTS} -o libagent.so agent.o
export LD_LIBRARY_PATH=${PWD}
AGENT=agent
java -agentlib:${AGENT}
Upon receiving the JVMTI_EVENT_CLASS_LOAD notification the agent invokes GetMethodID(env, klass, "toString", "()Ljava/lang/String;"); and prints the name of the loaded class.
However after some time the program always crashes with the same output:
Loaded class class java.lang.ExceptionInInitializerError
Loaded class class java.lang.IllegalAccessException
Loaded class class java.lang.IllegalAccessException
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/systemDictionary.cpp:849
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/HUDSON/workspace/9-2-build-linux-amd64-phase2/jdk9/4770/hotspot/src/share/vm/classfile/systemDictionary.cpp:849), pid=21145, tid=21146
# guarantee((!class_loader.is_null())) failed: dup definition for bootstrap loader?
#
# JRE version: Java(TM) SE Runtime Environment (9.0+112) (fastdebug build 9-ea+112)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 9-ea+112, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/akulyakh/nstep/core.21145)
#
# An error report file with more information is saved as:
# /home/akulyakh/nstep/hs_err_pid21145.log
Phoning home...
Using server: 10.161.186.18, port 4711
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Happens every time on b112 build. Does not happen on the Java 8 builds.
To reproduce, using the attached agent.c:
JDK_ROOT=${JAVA_HOME}
JDK_INCLUDE=${JDK_ROOT}/include
OS=linux
JDK_INCLUDE_PLATFORM=${JDK_INCLUDE}/${OS}
COMPILE_OPTS="-c -fPIC"
gcc ${COMPILE_OPTS} -I${JDK_INCLUDE} -I${JDK_INCLUDE_PLATFORM} -o agent.o agent.c
LIB_OPTS="-shared"
gcc ${LIB_OPTS} -o libagent.so agent.o
export LD_LIBRARY_PATH=${PWD}
AGENT=agent
java -agentlib:${AGENT}