-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8274617: constructor and parameter annotations are not copied to the anonymous class constructor #6548
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
8274617: constructor and parameter annotations are not copied to the anonymous class constructor #6548
Conversation
…anonymous class constructor
👋 Welcome back vromero! A progress list of the required criteria for merging this PR into |
@vicente-romero-oracle The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
/csr |
@vicente-romero-oracle this pull request will not be integrated until the CSR request JDK-8277679 for issue JDK-8274617 has been approved. |
@@ -1337,9 +1337,17 @@ public Type constructorType() { | |||
|
|||
@Override | |||
public MethodSymbol constructorSymbol() { | |||
// we should do this only once | |||
boolean copyConstAnnos = constructorSymbol == null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: can we avoid repeating this method completely if constructorSymbol != null
? Seems a bit weird to not copy the annotation again (which I understand), but redo all the rest again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep good point
public class Test { | ||
@VisibleCtrAnnotation | ||
@InvisibleCtrAnnotation | ||
public Test(String firstParam, @VisibleParamAnnotation String secondParam, @InvisibleParamAnnotation String thirdParam) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about type annotations of the parameter types? Should these be copied? (And tested?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep I should add a test for type annotations, good point
@@ -95,6 +95,7 @@ public void compileAll() throws Exception { | |||
"java.base/jdk.internal.javac", | |||
"java.base/jdk.internal.jmod", | |||
"java.base/jdk.internal.misc", | |||
"java.base/jdk.internal.vm.annotation", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit suspicious to me - why the new entry? Do we know why it was necessary? (I would expect that any change here would be caused by a change in dependencies among modules, but I don't seem to see that change.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh I'm not sure why this new dependency appeared there is no new import, I will do some research
* given parameter | ||
*/ | ||
if (!param.getRawTypeAttributes().isEmpty()) { | ||
params.append(make.VarDef(param, make.Ident(param.type.tsym), null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I would only use this branch, whether or not there is a type annotation. (Would be much better tested, among other things.)
|
||
private List<JCTypeParameter> typeParams(List<Type> typarams) { | ||
ListBuffer<JCTypeParameter> tparams = new ListBuffer<>(); | ||
final AtomicInteger paramIndex = new AtomicInteger(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AtomicInteger is a big weird (it is the first time it is used in javac, believe). I wonder if using some alternative (like an array) would not fit better.
Can these annotations be detected properly by reflection at runtime (when, say, compiled with |
sorry I'm not sure I'm following you, the |
Hmm, since both annotation and method signature attributes' recorded signature/annotations don't exactly correspond to the parameters in the descriptor, I thought they probably would share the same mechanism of determining the exact parameter mapping. Reflection uses This indeed doesn't matter as the extra local variables passed are in the end of parameter list, which doesn't impact the current way annotations are written to class files and read at runtime. Sorry for digressing here. |
@vicente-romero-oracle This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@vicente-romero-oracle This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Please review this PR which is about propagating constructor and parameter annotations to the anonymous class constructor. Currently we are propagating them to bridge methods which are synthetic. Propagating them to the anonymous class constructor seems sensible given that they are mandated by the spec. Please review also the related CSR,
TIA
Progress
Integration blocker
Issues
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6548/head:pull/6548
$ git checkout pull/6548
Update a local copy of the PR:
$ git checkout pull/6548
$ git pull https://git.openjdk.java.net/jdk pull/6548/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6548
View PR using the GUI difftool:
$ git pr show -t 6548
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6548.diff