Skip to content

Instantly share code, notes, and snippets.

@raphw
Last active September 23, 2016 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raphw/4044df5d106766edac8b9addd135e1fb to your computer and use it in GitHub Desktop.
Save raphw/4044df5d106766edac8b9addd135e1fb to your computer and use it in GitHub Desktop.
Java agent problem on J9.
public class Foo {
public static void main(String[] args) throws UnmodifiableClassException, InterruptedException {
// jar: https://bintray.com/raphw/maven/download_file?file_path=net%2Fbytebuddy%2Fbyte-buddy-agent%2F1.4.26%2Fbyte-buddy-agent-1.4.26.jar
Instrumentation instrumentation = ByteBuddyAgent.install();
System.out.println(instrumentation.isRedefineClassesSupported());
System.out.println(instrumentation.isRetransformClassesSupported());
// Successfully attaches agent to running process but also prints:
// *** java.lang.instrument ASSERTION FAILED ***: "jvmtierror == JVMTI_ERROR_NOT_AVAILABLE" at JPLISAgent.c line: 1009
// Prints 'false, false' even though manifest headers are specified correctly
// However: prints 'true, true' if another transformation-capable Javaagent was attached at startup.
// Its the easiest to attach the debugger to the process which implies such an agent.
// This also avoids the assertion.
// java version "1.8.0"
// Java(TM) SE Runtime Environment (build pxa6480sr3fp11-20160817_02(SR3 FP11))
// IBM J9 VM (build 2.8, JRE 1.8.0 Linux amd64-64 Compressed References 20160816_315341 (JIT enabled, AOT enabled)
// J9VM - R28_20160816_1459_B315341
// JIT - tr.r14.java.green_20160726_121883
// GC - R28_20160816_1459_B315341_CMPRSS
// J9CL - 20160816_315341)
// JCL - 20160816_01 based on Oracle jdk8u101-b13
// Googling this issue shows a dozen similar issues.
}
}
@DanHeidinga
Copy link

J9 doesn't support redefinition / retransformation when using late attach. Those capabilities need to be requested at startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment