Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Make Quotable a marker interface #302
base: code-reflection
Are you sure you want to change the base?
Make Quotable a marker interface #302
Changes from 2 commits
e552d41
4001413
79ed71a
499531b
f5b541b
487d2f5
a027bb7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 believe this part is not required? E.g. we can only support cases where the instance implements
Quotable2
. (meaning we know that implementation :-) )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
LambdaMetaFactory
needs updating so the FI implementation also implements the internalQuoted2
. I don't know if there are any access control issues with the non-exported interface being defined outside ofjava.base
. If so we might need an internal interface injava.base
whosequoted
method returnsObject
, and is exported to the code module.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.
FI implementation can't access Quotable2 because it's not exported.
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.
Right, so i think we need to create an interface in
java.base
in a package exported tojdk.incubator.code
e.g., create a package injava.base
calledjdk.internal.code
and add:then modify
module-info.java
injava.base
to export packagejdk.internal.code
to modulejdk.incubator.code
.More generally either this or the current approach will fail if the quotable functional interface is explicitly proxied via
Proxy.newProxyInstance
orMethodHandleProxies.asInterfaceInstance
. And, regardless if we haveQuotable::quoted
proxying would fail for instances of the following:I think we have to specify that such proxying results in inaccessible models. Not great a great answer, but not terrible.
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.
There's actually three modules:
java.base
which is where the lambda metafactory isjdk.incubator.code
which is where the code reflection code isI'm not sure if the problem @mabbay is describing has to do with
Quotable2
not being accessible from (1) or (2). Putting the new interface injava.base
will obviously address accessibility from (2). But I think there's still issues with respect to (1) ?E.g.
InnerClassLambdaMetafactory
, at the end of the day, will calldefineClass
on the caller lookup (e.g. the one in (1)). If the class being defined contains a symbolic reference to a non-exported interface, wouldn't that be an issue, regardless of whether the non-exported interface is injava.base
orjdk.incubator.code
?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.
Ah yes, that will likely throw an
IllegalAccessError
. (I seem to recall we ran into this before when trying to add internal marker interfaces to FI implementations?)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.
@mcimadamore The issue I'm describing is that the class defined by LambdaMetaFactory will be in unnamed module and can't access to Quotable2.
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.
Thanks for the clarification - I suspected that. In that case, I think it is probably best to leave this
Quotable2
idea on the side for the time being. Sorry for having mentioned it -- I did not think through the full implications for the metafactory.We can probably try to revisit this at a separate point: the magic method we try to detect works ok, but I see some risk - e.g. if the client provided its own implementation of
Quotable
that also exposed its ownquoted
method. Then the JDK code will try to call that which is why I was reaching for something more robust. But we can separate that concern out of this work.