-
Notifications
You must be signed in to change notification settings - Fork 975
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
LUCENE-10335: Deprecate broken helper methods not compatible with module system; add ModuleResourceLoader and add integration test #567
Conversation
…or removal, as broken with modules
I have not yet checked Luke's image loading, as I touched this while reviewing all calls to getResource()/getResourceAsStream(). |
I fixed Luke. I will now check for other places that do getClassLoader().getResource... |
We have some more in Benchmark module and tests of Spatial module. We may need to fix those and move resources to exported packages (not a root folder called "data/"). |
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!
lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java
Show resolved
Hide resolved
I found another problematic one: loadStopwordSet in StopAnalyzerBase. This does not work from inside nor/kuromoji and others. I will deprecated in same way. I would like to make this method only visible from the analyzers-common module, but I am not sure how. |
How can we have failing tests for these problems? We need a test-driven approach to fixing this stuff. |
This is preparatory. We have a branch where it does not work because of this. See the issue for explanation. The problem is that getResourceAsStream() and getResource() are caller-sensitive and check who calls it. If its a classpath app, it works as the checks are ignored. With module system the method returns null if you try to load a resource in another module. I will add a test to the distribution tests to show this. The basic problem is: |
To explain: We need to go away with a public static helper class that calls |
I understand why the method doesnt work for modules: I just don't care. I am only asking about failing tests. |
@rmuir we will have a test-driven approach soon after xmas when Dawid finishes the conversion to module system. But all work that can be done before should be done before, as it will be a messy huge patch. |
For now I can only make sure I don't break the status as is. |
Also, are we sure this stuff isn't bugs in the JDK? Seems like a design flaw in modules. I have the feeling this is going to break the analysis module left and right. I am concerned about things like analyzer factories, stopwordananalyzerbase, the list goes on and on. I cannot "see" the scope of the problem without failing tests LOL. |
That's openjdk internal bullshit and not in the public java docs. we need to push back on openjdk here, this is a bug! |
Sorry, I have to say I am -1 at the moment to "gutting" all the analysis code, without tests, before first even trying to report these bugs to openjdk (it is THEIR FAULT). We should get it fixed upstream. |
I was in the discussion before Java 9 came out. It was a mess and I argued several times, because you were not even able to load class files anymore as resources (now they have an exception for that specific use case in ClassLoader). At the end we came out with this and it is clearly documented in the JLS and the API and you won't change it anymore:
In the analyzers module it is not a problem anymore, only a few issues are there. |
Where is it clearly documented? I don't see any such documentation: BUG. |
Robert, please let me finish this, otherwise I will trash down everything and stop working anymore on module system. If you want modules (and looks like you want) let us do our work and be calm. Thanks. I will work more and commit this a bit later. These changes are not risky at all and IMHO I fixed a lot of other stuff around. |
My problem is that the justification for fixing this stuff is that, "this code is buggy, it calls a CallerSensitive method". CallerSensitive isn't even publicly documented. This is OpenJDK internal stuff. OpenJDK BUGS! Uwe, I don't meant to discourage you from working on modules. It isn't a personal attack. I am angry about the OpenJDK behavior here and honestly believe this stuff is a bug. |
Hi, see the bold text and especially the italic one: (https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html#getResourceAsStream(java.lang.String)):
|
Thanks Uwe. I suppose "caller" there is enough to justify their shitty CallerSensitive shenanigans. This really sucks though, they screwed up. Please proceed, sorry for noise. |
I was angry about that 4 or 5 years ago already. By the way the exception for "class" files was my work at that time. |
I am thinking about a small solution to still use |
But how will we fix analyzer factories (ClasspathResourceLoader) ? This seems like the biggest issue. |
…oomji and nori dictionary loader
… prepend "/" to resource path
Hi @mocobeta, In general a simple hotfix rule for The main difference between ClassLoader and Class ist: For Class you can load non-open module-local resources, while ClassLoader ALWAYS needs open packages, also for callers from own module. The reason for that is simple: A ClassLoader can be shared between different modules, so the getResource() methods there have no idea from which module you want to get resources, so they block everything which is not open. So we should really forbid usage of |
An alternative is But not for the Kuromoji/Nori code, as this would limit to only current module so breaking backwards. |
@uschindler Thank you. I looked through the changes. |
Hi,
That's really bad news! I send you my deepest condolences! Take your time! Most of this PR is mechanical work, so the only things to "review" are the API changes. I am sure, Dawid will also have a look. Happy New Year, |
Thank you, Uwe. I am grateful for your kind concern. |
I'm sorry to hear this @mocobeta |
@rmuir Thank you, for your concern. |
I am very sorry for your loss, @mocobeta, please accept my condolences. |
@dweiss Thank you, I appreciate your concern. |
Hi @dweiss: I will merge in the changes to your branch, as this is a bit more complicated (I also need to revert some changes on your branch) |
No, please don't - I'll do it later. |
Oh sorry, I fixed it already. You can revert if you like, but looks well now. |
No worries, thanks Uwe. |
Hm, now on main this causes an ECJ warning.... But it does not fail build. That's ok for now. |
I will check how to fix this. Its a valid warning because the package has no class files. But that's wanted here for testing purposes. |
I fixed the warning in main by a fake "package-info.java" |
I'm sorry for the sudden notice - I was not sure how to properly inform such things in English - but we have finished the funeral and important memorial services, and I'm back to day-to-day life (I will have to deal with the various paperwork for the next months, though). |
See: https://issues.apache.org/jira/browse/LUCENE-10335