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

6656: Allow capturing field values with path syntax #20

Closed
wants to merge 30 commits into from

Conversation

@tabjy
Copy link
Contributor

tabjy commented Dec 17, 2019

This patch implements JMC-6656: Allow capturing field values with path syntax.

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 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!

Progress

  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

JMC-6656: Allow capturing field values with path syntax

Approvers

  • Marcus Hirt (hirt - Reviewer)
tabjy added 21 commits Nov 27, 2019
# Conflicts:
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/Parameter.java
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/TransformDescriptor.java
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/impl/DefaultTransformRegistry.java
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfr/JFRTransformDescriptor.java
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfr/impl/JFRMethodAdvisor.java
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfrnext/impl/JFRNextEventClassGenerator.java
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfrnext/impl/JFRNextMethodAdvisor.java
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/TypeUtils.java
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 17, 2019

👋 Welcome back kxu! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request (refresh this page to view it).

@tabjy tabjy marked this pull request as ready for review Dec 17, 2019
@tabjy
Copy link
Contributor Author

tabjy commented Dec 18, 2019

/help

@openjdk
Copy link

openjdk bot commented Dec 18, 2019

@tabjy Available commands:

  • contributor - adds or removes additional contributors for a PR
  • covered - used when employer has signed the OCA
  • help - shows this text
  • integrate - performs integration of the changes in the PR
  • signed - used after signing the OCA
  • solves - add an additional issue that this PR solves
  • sponsor - performs integration of a PR that is authored by a non-committer
  • summary - updates the summary in the commit message
  • test - used to run tests
@thegreystone thegreystone self-requested a review Dec 18, 2019
@edvbld
Copy link
Member

edvbld commented Dec 18, 2019

Please ignore this comment, it is just for the bots to refresh their caches and re-evaluate this PR

@openjdk openjdk bot added the rfr label Dec 18, 2019
@mlbridge
Copy link

mlbridge bot commented Dec 18, 2019

Webrevs

@tabjy tabjy requested a review from thegreystone Dec 19, 2019
aptmac added a commit to aptmac/jmc that referenced this pull request Jan 2, 2020
tabjy added 2 commits Jan 10, 2020
…sion

# Conflicts:
#	core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/Transformer.java
@tabjy tabjy force-pushed the tabjy:agent-path-expression branch from 4bb163b to 0418566 Jan 13, 2020
and to re-trigger GitHub actions
@tabjy tabjy force-pushed the tabjy:agent-path-expression branch from f7c3e52 to 09abbb9 Jan 13, 2020
@thegreystone
Copy link
Collaborator

thegreystone commented Jan 14, 2020

All copyrights need to have 2020 added now, like so:

  • Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.

Happy New Year! :)

@tabjy tabjy requested a review from thegreystone Feb 6, 2020
@thegreystone
Copy link
Collaborator

thegreystone commented Feb 11, 2020

Please ensure that the code is formatted with the Mission Control formatting settings. The agent isn't taking part in the automated formatting checks yet.

@thegreystone
Copy link
Collaborator

thegreystone commented Feb 13, 2020

It's fine. I'll accept this, and open a new issue for getting the agent built, and the formatting applied, as part of the check in tests. Thanks for the contribution!

@openjdk
Copy link

openjdk bot commented Feb 13, 2020

@tabjy This change now passes all automated pre-integration checks. When the change also fulfills all project specific requirements, type /integrate in a new comment to proceed. After integration, the commit message will be:

6656: Allow capturing field values with path syntax

Reviewed-by: hirt
  • If you would like to add a summary, use the /summary command.
  • To credit additional contributors, use the /contributor command.
  • To add additional solved issues, use the /solves command.

Since the source branch of this PR was last updated there have been 14 commits pushed to the master branch. Since there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge master into your branch, and then specify the current head hash when integrating, like this: /integrate 7731ae960af49e9933a3adb15f1e270dd78aa143.

As you do not have Committer status in this project, an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@thegreystone) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Feb 13, 2020
@tabjy
Copy link
Contributor Author

tabjy commented Feb 13, 2020

/integrate

@openjdk openjdk bot added the sponsor label Feb 13, 2020
@openjdk
Copy link

openjdk bot commented Feb 13, 2020

@tabjy
Your change (at version a207b81) is now ready to be sponsored by a Committer.

@thegreystone
Copy link
Collaborator

thegreystone commented Feb 13, 2020

/sponsor

@openjdk openjdk bot closed this Feb 13, 2020
@openjdk openjdk bot added integrated and removed sponsor ready rfr labels Feb 13, 2020
@openjdk
Copy link

openjdk bot commented Feb 13, 2020

@thegreystone @tabjy The following commits have been pushed to master since your change was applied:

  • 7731ae9: 6694: JDK8 RCP launch configurations should set -XX:+IgnoreUnrecognizedVMOptions
  • ef91b05: 6693: Eclipse projects core/org.openjdk.jmc.jdp* should have the correct JRE target level
  • ec4630f: 6687: Add icon to the flame view to render as icicle graph
  • eb59321: 6684: Adding CONTRIBUTING.md file
  • 490f619: 6677: Search to highlight cells in the flame view
  • ef7f807: 6688: Adding project file for the 2019-12 platform
  • 7485fad: 6686: Adding FAQ to wiki/readme
  • c85d31b: 6685: Parse more fields directly to primitive values
  • 6dd19dd: 6674: Optimize finding of first start time and first & last end times
  • 875abcd: 6670: Harmonize ~ Unclassifiable ~ across Flame View and Stacktrace View
  • 2dd271f: 6572: Make mbean functions protected by permission checks
  • 1676ecc: 6673: Upgrading to Tycho 1.6.0
  • e647a9d: 6661: Simplify Agent JMX tests
  • c2134e2: 6672: JavaScript formatting template

Your commit was automatically rebased without conflicts.

Pushed as commit 689812b.

@mlbridge
Copy link

mlbridge bot commented Feb 13, 2020

Mailing list message from Marcus Hirt on jmc-dev:

Changeset: 689812b
Author: Kangcheng Xu <kxu at openjdk.org>
Committer: Marcus Hirt <hirt at openjdk.org>
Date: 2020-02-13 15:37:19 +0000
URL: https://git.openjdk.java.net/jmc/commit/689812b0

6656: Allow capturing field values with path syntax

Reviewed-by: hirt

+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/Attribute.java
+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/Field.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/Parameter.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/ReturnValue.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/TransformDescriptor.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/Transformer.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/impl/DefaultTransformRegistry.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfr/JFRTransformDescriptor.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfr/impl/JFRClassVisitor.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfr/impl/JFREventClassGenerator.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfr/impl/JFRMethodAdvisor.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfrnext/impl/JFRNextClassVisitor.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfrnext/impl/JFRNextEventClassGenerator.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/jfrnext/impl/JFRNextMethodAdvisor.java
+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/AccessUtils.java
+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/InspectionClassLoader.java
! core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/TypeUtils.java
+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/expression/ExpressionResolver.java
+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/expression/IllegalSyntaxException.java
+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/expression/ReferenceChain.java
+ core/org.openjdk.jmc.agent/src/main/java/org/openjdk/jmc/agent/util/expression/ReferenceChainElement.java
! core/org.openjdk.jmc.agent/src/test/java/org/openjdk/jmc/agent/test/InstrumentMe.java
! core/org.openjdk.jmc.agent/src/test/java/org/openjdk/jmc/agent/test/TestDefineEventProbes.java
! core/org.openjdk.jmc.agent/src/test/resources/org/openjdk/jmc/agent/test/jfrprobes_template.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.