[Rev 09] RFR: 6656: Allow capturing field values with path syntax

Kangcheng Xu kxu at openjdk.java.net
Thu Feb 6 16:29:10 UTC 2020


> This patch implements [JMC-6656: Allow capturing field values with path syntax](https://bugs.openjdk.java.net/browse/JMC-6656).
> 
> In the xml configuration, a field capture looks like:
> <field>
>   <name>a field value</name>
>   <description>a field value capture with a path syntax</description>
>   <expression>this.field.prop</expression>
> </field>
> See `org/openjdk/jmc/agent/test/jfrprobes_template.xml` for more examples.
> 
> There are currently two limitations to pay attention to:
> 
> 1. Instrumentation point cannot be in synthesized classes:
> Instrumented classes are first loaded by obtaining the bytecode and inspected reflectively to resolve typing information. This fails if the class load is unable to provide the bytecode when `ClassLoader.getResouce()` is called. The cases where it might fail are unlikely to be for classes like proxies or auxiliaries for Java frameworks that have no visible equivalent.
> 
> 2. Instrumentation is unable to access nestmates' private fields:
> Before [nest-base access control](https://openjdk.java.net/jeps/181) was introduced in Java 11, accessing nestmates' private fields is, while lexically correct, forbidden by the JVM. The Java compiler works around by inserting synthetic getters/setters. However, it's not for a BCI agent since changing the class structure is not allowed during class transformation.
> 
> Please let me know your thoughts. Thank you very much!

The pull request has been updated with 1 additional commit.

-------------

Added commits:
 - a207b813: lazy load inspection class only when needed for field evaluations

Changes:
  - all: https://git.openjdk.java.net/jmc/pull/20/files
  - new: https://git.openjdk.java.net/jmc/pull/20/files/5dc43be5..a207b813

Webrevs:
 - full: https://webrevs.openjdk.java.net/jmc/20/webrev.09
 - incr: https://webrevs.openjdk.java.net/jmc/20/webrev.08-09

  Stats: 71 lines in 5 files changed: 27 ins; 11 del; 33 mod
  Patch: https://git.openjdk.java.net/jmc/pull/20.diff
  Fetch: git fetch https://git.openjdk.java.net/jmc pull/20/head:pull/20

PR: https://git.openjdk.java.net/jmc/pull/20


More information about the jmc-dev mailing list