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

Kangcheng Xu kxu at openjdk.java.net
Fri Jan 17 21:00:34 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 a new target base due to a merge or a rebase.

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

Commits:
 - 5dc43be5: Merge remote-tracking branch 'upstream/master' into agent-path-expression
 - 10e48d58: update license header year values
 - 09abbb99: remove unused function
 - 4bb163b9: update TestSetTransforms with new changes
 - 04185668: Merge remote-tracking branch 'upstream/master' into agent-path-expression
 - c78ce947: lazy-load class with InspectionClassLoader
 - c35788f2: add javadoc
 - 9782c758: update license header year
 - caaa7e7e: resolve conflicts after merging from master
 - 3383c080: Merge branch 'master' into agent-path-expression
 - a3e0c61e: error on private member access between nestmates
 - 5c19b765: add test cases for field capture feature
 - e05ea8bf: support legacy JFR api
 - 1019ca0d: change indentations to using tabs. add license headers
 - 1c7b0ac6: rename "watch" to "field"
 - e93a31e2: refactor error handling. cache resolved reference chain
 - 92b92502: add a QualifiedThisReference only when making qualified .this or .super
 - db3d6266: WIP: refactor
 - 040a42d8: add final modifiers
 - a803e7e7: remove unnecessary null checks
 - af33e32f: implemented path-syntax evaluation
 - 4cc7b9ea: WIP: add check for access and static context. improves error messages
 - 036b324e: WIP: state machine for parsing expression
 - 3f2f4023: WIP: syntax parsing with state machine
 - b58a44e4: WIP: implement implicit upwards reference in a nest
 - ad7d64f6: WIP: enforce access checks on reference chains
 - 5e46ed6f: WIP: avoid loading instrumentation pending classes with parent loader
 - 1964111f: WIP: fix loading "this"
 - 74624291: WIP: BCI agent path-syntax evaluation

Changes: https://git.openjdk.java.net/jmc/pull/20/files
 Webrev: https://webrevs.openjdk.java.net/jmc/20/webrev.08
  Stats: 2396 lines in 24 files changed: 2282 ins; 1 del; 113 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