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

fix bug about the generateReturnAndInvocation method of the class AdaptiveClassCodeGenerator #4339

Merged
merged 2 commits into from
Jul 17, 2019
Merged

fix bug about the generateReturnAndInvocation method of the class AdaptiveClassCodeGenerator #4339

merged 2 commits into from
Jul 17, 2019

Conversation

bootstream
Copy link
Contributor

@bootstream bootstream commented Jun 18, 2019

What is the purpose of the change

我发现在调用被代理的方法时,使用的参数名是该方法自身定义的旧的参数名,然而我们在生成代理类的过程中重载该方法时已经将参数名重新定义为arg为首,index为尾的参数名,例如arg0,arg1...。当使用旧的参数名调用被代理方法时,编译会出现错误,因为我们的局部变量之中已经不存在旧的参数名了,所以在调用被代理方法时应该使用新的参数名。
I found that when calling the proxy method, the parameter name used is the old parameter name defined by the method itself. However, when we overload the method in the process of generating the proxy class, we have redefined the parameter name as arg first and index tail, such as arg0, arg1.... When the proxy method is called with the old parameter name, compilation errors occur because the old parameter name does not exist in our local variables, so we should use the new parameter name when calling the proxy method.

Brief changelog

XXXXX

Verifying this change

XXXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@bootstream bootstream changed the title fix bug about the proxy method is called with the old parameter name, compilation errors occur fix bug about the generateReturnAndInvocation method of the class AdaptiveClassCodeGenerator Jun 18, 2019
@bootstream bootstream closed this Jun 18, 2019
@bootstream bootstream reopened this Jun 18, 2019
@codecov-io
Copy link

Codecov Report

Merging #4339 into master will decrease coverage by 0.61%.
The diff coverage is 94.95%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4339      +/-   ##
============================================
- Coverage     62.88%   62.27%   -0.62%     
+ Complexity      505      504       -1     
============================================
  Files           769      790      +21     
  Lines         32995    34844    +1849     
  Branches       5215     5456     +241     
============================================
+ Hits          20748    21698     +950     
- Misses         9845    10639     +794     
- Partials       2402     2507     +105
Impacted Files Coverage Δ Complexity Δ
...o/common/extension/AdaptiveClassCodeGenerator.java 94.95% <94.95%> (+0.08%) 0 <0> (ø) ⬇️
...che/dubbo/remoting/transport/mina/MinaChannel.java 43.42% <0%> (-10.53%) 16% <0%> (-1%)
...e/dubbo/remoting/transport/netty/NettyChannel.java 57.64% <0%> (-4.71%) 20% <0%> (-1%)
.../apache/dubbo/remoting/transport/AbstractPeer.java 67.39% <0%> (ø) 0% <0%> (ø) ⬇️
...a/org/apache/dubbo/common/json/ParseException.java 0% <0%> (ø) 0% <0%> (?)
...o/rpc/protocol/thrift/DubboClassNameGenerator.java 100% <0%> (ø) 0% <0%> (?)
.../java/org/apache/dubbo/common/json/JSONObject.java 17.07% <0%> (ø) 0% <0%> (?)
.../java/org/apache/dubbo/common/json/JSONWriter.java 58.94% <0%> (ø) 0% <0%> (?)
.../apache/dubbo/rpc/protocol/thrift/ThriftUtils.java 91.8% <0%> (ø) 0% <0%> (?)
.../java/org/apache/dubbo/common/json/JSONReader.java 68.42% <0%> (ø) 0% <0%> (?)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 041a6ad...7d0bda4. Read the comment docs.

@bootstream
Copy link
Contributor Author

jdk version: 1.8.0_172 , compilation options : -parameters

Copy link
Member

@beiwei30 beiwei30 left a comment

Choose a reason for hiding this comment

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

I am not convinced.

Would you mind to provide a sample code to help me to understand the scenario?

@beiwei30
Copy link
Member

I think I understand what happens, you use 'javac -parameters' to compile. In this case, we should consider to enhance method signature generation instead, in my opinion.

@beiwei30
Copy link
Member

second thought, I went through the code again, there are lots of code based on 'arg%d' format. I agree your change is minimal. I will consider to merge.

@beiwei30 beiwei30 merged commit d727461 into apache:master Jul 17, 2019
@beiwei30 beiwei30 added this to the 2.7.4 milestone Jul 17, 2019
@tswstarplanet
Copy link
Contributor

Sorry, I think the file committed is a little confused because it delete a file and add an almost same file. It' s difficult to identify the diff

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.

5 participants