-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Solution for access path problem #974
Conversation
No, not that I remember :-) It looks like an excellent idea! |
28a0f95
to
5c9354e
Compare
Is it good idea to have these methods in CtTypeReference API? They are actually used in /**
* Checks visibility based on public, protected, package protected and private modifiers of type
* @param type
* @return true if this can access that type
*/
boolean canAccess(CtTypeReference<?> type);
/**
* Returns this, or top level type of this, if this is an inner type
*/
CtTypeReference<?> getTopLevelType(); What about name like /**
* Computes nearest access path parent from contextType to this type.
*
* Normally the declaring type can be used as access path. For example in this class hierarchy
* <pre>
* class A {
* class B {
* class C {}
* }
* }
* </pre>
*
* The C.getAccessParentFrom(null) will return B, because B can be used to access C, using code like <code>B.C</code><br>
* But when some class (A or B) on the access path is not visible in type X, then we must found an alternative path.
* For example in case like, when A and B are invisible, e.g because of modifier <code>protected</code>:
* <pre>
* class D extends B {
* }
* class X extends D {
* class F extends C
* }
* </pre>
* The C.getAccessParentFrom(X) will return D, because D can be used to access C in scope of X.
*
* @param contextType - the type where the access path should be visible or null if we do not care about visibility
* @return type reference which can be used to access this type in scope of contextType.
*/
CtTypeReference<?> getAccessType(CtTypeReference<?> contextType); |
8c6db30
to
40ab4dc
Compare
Please make a revision. I am finished with that... until you ask for some changes ;-) |
* @param type | ||
* @return true if this can access that type | ||
*/ | ||
boolean canAccess(CtTypeReference<?> type); |
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.
nice method.
* Returns this, or top level type of this, if this is an inner type | ||
*/ | ||
@DerivedProperty | ||
CtTypeReference<?> getTopLevelType(); |
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.
nice method.
It looks good, thanks Pavel. But there is a significant performance cost. On Where is the performance bottleneck? Could you further optimize? |
It must be a misundertanding. MainTest of this PR needs 33s. And MainTest of already merged PR needed 36s. So it is faster, not slower. I see it in Travis console output. Where do you see your numbers? |
In the commit 119bedb I did a performance optimization, which makes it 2 times faster on MS Windows (before MainTest needed 45s and now it taks 24s). I did it as part of this PR, by mistake... I had there infinite loop, which caused that MainTest failed on timeout in Travis. And before I found my infinite loop, I have made commit 119bedb |
I extracted the performance improvement to PR #990 |
13544de
to
2a1570b
Compare
let's first converge on #990 and then rebase, measure and eventually |
2a1570b
to
c4a1d58
Compare
rebased.
similar like others. I see no performance problem. But check it, I do not know what you have seen. |
When we ask for the performance issue there was a huge execution time difference between your branch and the master. |
After short googling, I have not found any java specification about access path yet (so I am really not a guru for that), anyway I understood that:
Please correct me, if I am wrong.
The solution I would like to discuss consists of S1 and S2:
It causes:
nestedType.getDeclaringType()
anddeclaringType.getNestedTypes()
are consistent againI am sure, that you get this idea too. Could you explain me what is the problem? And if computation of access path is problem, then could you show me the case where it is problem?
Thank You! And and have a nice dreams :-)