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
[java] AssertionError: Method should be accessible #4885
Comments
Third exception:
|
So, I think this is around this problem:
This fails with no such method... Unfortunately, I couldn't yet reproduce the problem.... |
@Meijuh would you mind sharing the output of I have a suspicion as to what may be triggering this, but would love to confirm. I believe this is down to a JVM bug, where some versions choke on scenarios similar to ours… In short,
The exact same thing happens to all other literal types, such as I've seen some reports on JDK where similar scenarios caused failures consistent with this stacktrace. They were mostly reported on older JVMs, but that doesn't mean Java 11 releases existing at that time were not affected. If this is true:
|
openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (Red_Hat-11.0.22.0.7-1) (build 11.0.22+7)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.22.0.7-1) (build 11.0.22+7, mixed mode, sharing) I'm quite sure I was using this version when I reported this issue, but now when I'm trying to reproduce the issue, I can't... I will report whenever the problem pops up again. |
It could be a JVM issue, yes. 11.0.22 is the current version. Searching the bug database, I only found old problems regarding this constellation, e.g. https://bugs.openjdk.org/browse/JDK-7087658. We unfortunately don't log the causing exception. I'll create a PR to fix the logging of the IllegalAccessException, so that we have the full stacktrace, in case this happens again. Then maybe we can see, what the underlying issue might be - if any. Is this a bigger project, long running PMD analysis? I'm asking, because as far as I read, some bugs are only appearing when the hotspot compiler comes in and has a bug, so that this problem would never be reproducible with a simple test case. Gradle uses a gradle daemon process, which gives the opportunity for the JVM to do all kinds of optimizations, and maybe only then this problem shows after a while. And it disappears when the JVM is started fresh. Let's keep this issue open and see, if this problem happens again. |
This is a test case for pmd#4885, but doesn't reproduce the problem.
reproduced on azul zulu 11.0.19 |
I'm closing this now as the problem is not reproducible. It might have been fixed already in the latest JDK versions. |
I still have this even with azul zulu 11.0.23 |
@sabberworm Thanks for the info. |
Back when I wrote in, I wasn’t yet using PMD 7.1.0 but now I’ve upgraded and I’m seeing the issue sporadically still (alas, not reproducibly). I am using gradle with the quality plugin and that is running PMD. Stack Trace
Also, it always happens on a different token. Sometimes a string literal, other times a number literal. |
@sabberworm thanks. Have you tried a different JRE other than Zulu? |
@sabberworm The error message in the stack trace indicates, that this was still using PMD 7.0.0. Please post a new stacktrace with PMD 7.1.0, when this happens again. |
We should really do that for 7.2.0 |
@adangel Ah yes, you’re right I did still use the old version. I had a manual reference to the dependency, so just changing the version in the quality plugin didn’t actually update PMD, my bad. I tried a few times but couldn’t trigger the problem with 7.1.0. Will report back when I do. |
Affects PMD Version:
7.0.0
Description:
Errors about unreachable methods are intermittently (only 50% of the times) produced.
Exception Context:
[1:Rule applied on node=!debug only! [StringLiteral:9:29]"retracted"]
at net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere(AssertionUtil.java:219)
Exception Context:
[1:Rule applied on node=!debug only! [NumericLiteral:11:21]0]
Exception Context:
[1:Rule applied on node=!debug only! [StringLiteral:15:31]"no classes should use field injection"]
Exception Stacktrace:
Code Sample demonstrating the issue:
I'm not a 100% sure, but these lines of code seem to be involved in producing the errors.
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
./gradlew clean build --stacktrace
Running PMD through: Gradle
JDK 11
The text was updated successfully, but these errors were encountered: