-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Qute - Ignore classes defined in the unnamed package in BeanArchives.index
#26531
Qute - Ignore classes defined in the unnamed package in BeanArchives.index
#26531
Conversation
This comment has been minimized.
This comment has been minimized.
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 don't think this is a good solution. Note that the index wrapper can be used concurrently.
I wonder if we should get rid of the warning instead, and use e.g. the debug
level...
@manovotn WDYT?
@mkouba hm, I think the warning in general has its value. |
That's great idea, (though here it's just |
What about introducing whitelist for selected classes in java.lang that are likely to be used this way (String, wrapper, ...)? I know my original solution is clumsy, but it's pretty easy to work around concurrency as only non-immutable thing there is log level, so adding copy constructor (creating a new IndexWrapper instance) would fix that issue... or am I wrong? |
I'll let @mkouba decide, I am just tossing ideas around :-) |
Bad practice and discouraged but still legal...
I don't think we can try the prefixed version first because it's legal e.g. to have a class I'd prefer to ignore the classes with the default package inside the |
The two approaches seem similar in a way since you try to avoid indexing no-package classes. |
f931228
to
053891c
Compare
BeanArchives.index
BeanArchives.index
BeanArchives.index
f152744
to
97571f9
Compare
Martin is currently out of the office, I'll review this today. |
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.
@michalvavrik added two comments, if you don't have time, I can update the PR as well, just let me know.
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java
Outdated
Show resolved
Hide resolved
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java
Outdated
Show resolved
Hide resolved
97571f9
to
d4af0f9
Compare
Thank you for the review |
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.
LGTM
Thanks for the PR @michalvavrik!
I know the subject of this PR mentions Qute, but the change here basically means that classes in the unnamed package can't ever be beans, if I understand the code change correctly? I wonder how that works with JBang scripting, which by convention uses the unnamed package (judging from https://quarkus.io/guides/scripting). |
Hmm, I have no idea nor did I know JBang uses unnamed package. |
Yes, we don't require use of package before you actually need it. Why is it we would not allow use of default packaged beans in Qute? |
I'd like to reiterate -- this PR, albeit mentioning Qute in the subject, actually changes a core piece of ArC. This has a potential to affect much more than just Qute, but I'll also confess right away that I didn't really investigate what the impact actually is. EDIT: okay, just looking at the usages of the changed code and this seems pretty safe. Sorry for the false alarm! (Though I'm not exactly sure how the "additional classes" in ArC's |
@Ladicek If memory serves, those were deps from 3rd party JARs that you didn't initially index or marked for indexation in any way. |
Originally the |
OK, thanks! In that case, with this PR, bean types coming from unindexed 3rd party library can't be in the unnamed package, right? :-) Or something like that. Probably not a big deal, but it's a little strange. |
I believe that it wouldn't work anyway... and a 3rd party library with classes in the unnamed package is IMO really bad idea. |
So default package is ok if it's in the jar the main class is in |
Yes, it should be fine if it's in the application sources root, i.e. |
fixes: #26524
When
TypeInfos.create
is looking for a parameter declaration type, it checks a couple of options and fallbacks to a prefixjava.lang
. The Qute reference guide contains an example of parameter declaration using only{@String foo}
withoutjava.lang
, thus when user follows the example, he should not be warned. That is fixed by ignoring classes in the unnamed package.