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

Add Muzzle reference creation for interfaces #2155

Merged
merged 2 commits into from
Dec 3, 2020
Merged

Conversation

tylerbenson
Copy link
Contributor

This will allow muzzle to fail if an implemented interface is missing. Additional work should be done in the future to ensure the implementation satisfies the interfaces and abstract types. (open-telemetry/opentelemetry-java-instrumentation#1357)

@tylerbenson tylerbenson requested a review from a team as a code owner December 2, 2020 20:56
for (String iface : interfaces) {
addReference(
new Reference.Builder(iface)
.withSource(refSourceClassName, 0) // We don't have a specific line number to use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is inconsistent with behaviour elsewhere in the class where the value -1 is used when no line number is known.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that the existing behaviour is correct. Line numbers will be missing if code has been passed through an obfuscator, for instance, in which case MethodVisitor.visitLineNumber wouldn't be entered, and line number 0 may be a better fallback value than -1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only matters for our own code, so the case of an obfuscator doesn't likely apply. I don't care between -1 and 0, but I did extract it out to a static final.

Comment on lines -98 to +100
// public static MethodBodyAdvice.SomeInterface indyMethod(
// final MethodBodyAdvice.SomeImplementation a) {
// public static MethodBodyAdvice.HasMethod indyMethod(final MethodBodyAdvice.HasMethod a) {
// Runnable aStaticMethod = MethodBodyAdvice.B::aStaticMethod;
// return a::someMethod;
// return a::requiredMethod;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also an unrelated change... I uncommented it to verify it still worked and found it didn't, so I updated it here.

This will allow muzzle to fail if an implemented interface is missing.
@tylerbenson
Copy link
Contributor Author

I added this so that #2054 is able to distinguish a version where the implemented interface name changed/moved.

@tylerbenson tylerbenson merged commit cfd7f94 into master Dec 3, 2020
@tylerbenson tylerbenson deleted the tyler/muzzle-super branch December 3, 2020 21:05
@github-actions github-actions bot added this to the 0.69.0 milestone Dec 3, 2020
@@ -240,7 +240,8 @@ private void decrementRefAndMaybeWrite(boolean isRootSpan) {
}
}
if (log.isDebugEnabled()) {
log.debug("t_id={} -> expired reference. pending count={}", traceId, count);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this committed with this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed. That seems completely unrelated and should not be in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is unrelated to the pr. I made this change to troubleshoot some build failures, but the build passed following this change. It seems like a useful and very minor change so I left it in.

@richardstartin
Copy link
Contributor

@tylerbenson this PR is called "Add Muzzle reference creation for interfaces" yet a change to PendingTrace has been brought in with it after review? Please change the name of the PR and its description to better describe the change.

Copy link
Contributor

@dougqh dougqh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unrelated change to PendingTrace needs to be removed. Or needs justification.

@tylerbenson
Copy link
Contributor Author

For reference you can see the history of me running the test multiple times to try to figure out what was wrong here: https://app.circleci.com/pipelines/github/DataDog/dd-trace-java?branch=tyler%2Fmuzzle-super

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

Successfully merging this pull request may close these issues.

4 participants