Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance classes don't work in JDK11 #482

Closed
mikeb01 opened this issue Jun 15, 2021 · 1 comment
Closed

Instance classes don't work in JDK11 #482

mikeb01 opened this issue Jun 15, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@mikeb01
Copy link

mikeb01 commented Jun 15, 2021

If I attempt to trace using a BTrace script that is using an instance class, e.g. Profiling.java, then is will fail to load the script. The scripts that only use static methods work. The instance based scripts work okay in JDK8.

Running:

> ./bin/btrace -v 256912 /home/mike/sources/real_logic/aeron-btrace/btrace/samples/Profiling.java

Trace from running JVM

btrace DEBUG: client accepted Socket[addr=/127.0.0.1,port=56866,localport=2020]
btrace DEBUG: got instrument command
btrace DEBUG: loading BTrace class
btrace DEBUG: verifying BTrace class ...
btrace DEBUG: BTrace class org.openjdk.btrace.runtime.aux.Profiling$1 verified
btrace DEBUG: preprocessing BTrace class org.openjdk.btrace.runtime.aux.Profiling$1 ...
btrace DEBUG: ... preprocessed
btrace DEBUG: XML bindings are missing. @OnProbe support is disabled.
btrace DEBUG: loaded 'org.openjdk.btrace.runtime.aux.Profiling$1' successfully
btrace DEBUG: class renamed to org.openjdk.btrace.runtime.aux.Profiling$1
btrace DEBUG: client org.openjdk.btrace.runtime.aux.Profiling$1: got org.openjdk.btrace.core.comm.RenameCommand@22670d7d
btrace DEBUG: creating BTraceRuntime instance for org.openjdk.btrace.runtime.aux.Profiling$1
btrace DEBUG: created BTraceRuntime instance for org.openjdk.btrace.runtime.aux.Profiling$1
btrace DEBUG: sending Okay command
btrace DEBUG: client org.openjdk.btrace.runtime.aux.Profiling$1: got org.openjdk.btrace.core.comm.StatusCommand@171fd35b
btrace DEBUG: about to defineClass org/openjdk/btrace/runtime/aux/Profiling$1
btrace DEBUG: skipping transform for BTrace class org/openjdk/btrace/runtime/aux/Profiling$1
btrace DEBUG: defineClass succeeded for org.openjdk.btrace.runtime.aux.Profiling$1
btrace DEBUG: java.lang.RuntimeException: can not load BTrace class
java.lang.RuntimeException: can not load BTrace class
        at org.openjdk.btrace.agent.RemoteClient.<init>(RemoteClient.java:151)
        at org.openjdk.btrace.agent.RemoteClient.getClient(RemoteClient.java:94)
        at org.openjdk.btrace.agent.Main.startServer(Main.java:858)
        at org.openjdk.btrace.agent.Main.lambda$main$1(Main.java:161)
        at java.base/java.lang.Thread.run(Thread.java:829)
btrace DEBUG: waiting for clients
> java -version
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment Zulu11.48+21-CA (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.48+21-CA (build 11.0.11+9-LTS, mixed mode)
> uname -a
Linux plinth 5.8.0-55-generic #62~20.04.1-Ubuntu SMP Wed Jun 2 08:55:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
@jbachorik
Copy link
Collaborator

Hi @mikeb01, thanks for reaching out!

I have reproduced the problem.

The gory details are:

  • The script pre-processor converts the non-static version to all-static version - in the process it converts the constructor into a class init block
  • The script loader is trying to pre-init the class by instantiating a dummy instance (using the default no-arg constructor)
  • This constructor has been removed by the post-processor and no default empty constructor was generated in its stead

The quick workaround is not to use the non-static version of a script until this gets fixed.

@jbachorik jbachorik self-assigned this Jul 25, 2021
@jbachorik jbachorik added this to the 2.2.1 milestone Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants