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
AJC throws NPE when number of classpath entries is over the limit #125
Comments
The fix here seems relatively straightforward I suspect. The Java Module support added in Java9 probably added new routes that are attempting to access the zipFile object. We should look at those routes and check if they are guarded by a call to |
I have done quick local fix, adding // AspectJ Extension
try {
ensureOpen();
}
catch (IOException e) {
throw new RuntimeException(e);
}
// End AspectJ Extension ... rather than catching the error and logging it or returning Update: Andy, shouldn't this be a set rather than a list? private static List openArchives = new ArrayList(); There seems to be the danger of duplicated entries there, especially if private void ensureOpen() throws IOException {
if (zipFile != null) return; // If its not null, the zip is already open
if (openArchives.size()>=maxOpenArchives) {
closeSomeArchives(openArchives.size()/10); // Close 10% of those open
}
zipFile = new ZipFile(file);
openArchives.add(this);
} If |
@raimondas67, I deployed an AspectJ See #95 (comment) for an example project showing how to upgrade to the latest AspectJ version when using dev.aspectj:aspectj-maven-plugin:1.13.1. Just make sure to set the As for your second problem from the mailing list, I think you still have not created an issue for it. Can you help us to reproduce it? |
after fixing something related to eclipse-aspectj#125 there Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
ClasspathJar.openArchives needs more safeguards when accessing possibly closed zip files (actually classpath JARs), making sure the get re-opened by calling ClasspathJar.ensureOpen(). Relates to eclipse-aspectj/aspectj#125. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name> Change-Id: If20bae3d6169559de97febc529465196367524b9
This test fails when run against AspectJ 1.9.8 with JDT Core 1.9.8.RC3. It passes when using the latest JDT Core 1.9.9-SNAPSHOT. It sets system property 'org.aspectj.weaver.openarchives=20', provoking open classpath JAR file exhaustion when compiling a simple class with AJC, i.e. JARs are being forcibly closed and automatically re-opened, as soon as they are needed. Before the JDT Core bugfix, this test causes: java.lang.NullPointerException at ....compiler.batch.ClasspathJmod.getModulesDeclaringPackage With the bugfix incorporated into AspectJ Tools, the problem is gone. Note: New test dependency 'io.github.bmuskalla:scoped-system-properties' helps to test compilation with the temporarily changed global system property in isolation, saving the environment in a thread-local variable and later cleanly restoring the original values again. If we ever switch to parallel test execution, this would otherwise influence other tests and potentially cause weird side effects. Better safe than sorry. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
This should make Bugs198Tests.testGitHub_125 green, fixing problem eclipse-aspectj#125 in AspectJ. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
@aclement, I inspected the existing logic and think it is safe to continue using the list instead of a set, mainly because it is more predictable and chronological which classpath JARs get closed on cache exhaustion (first in, first out). We would have to use a sorted set or map with a sortable timestamp or so as the key, which would entail more changes than I want to implement now. But I think I was pretty thorough with where to put the safeguards, my checks also encompassing subclasses. I think that for now we are OK, at least no worse than before. If @raimondas67 also re-tests successfully, I think the two PRs for JDT Core and AspectJ are ready to be reviewed and merged, whenever you have cycles to look into them. |
…#125 This commit is not meant to be merged into the main branch, but used to trigger the complete test suite with the lowest possible limit for the open JAR file AspectJ introduced in JDT Core. As some changes in eclipse-aspectj/eclipse.jdt.core#19 change behaviour (throwing exceptions where before they were just logged and dummy results returned), we want to find out if this breaks any existing tests when provoking cache exhaustion, i.e. closing and re-opening of JARs. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
For the record: In addition to the regression test I added, which always runs with |
Hi,
Classpath related NPE exception is fixed with this 1.9.9-SNAPSHOT release, however, I’m still getting the same AJC compiler error
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.14.0:compile (default) on project xxx-app: AJC compiler errors:
[ERROR] error at (no source information available)
[ERROR] C:\Users\....aj:0::0 Type java.lang.Object is indirectly referenced from required .class files but cannot be resolved since the declaring package java.lang exported from module java.base conflicts with a package accessible from module <unnamed>
thus 1.9.4 has to be used.
Regards
From: Alexander Kriegisch
Sent: Wednesday, February 23, 2022 5:04 PM
To: eclipse/org.aspectj
Cc: raimondas67 ; Mention
Subject: Re: [eclipse/org.aspectj] AJC throws NPE when number of classpath entries is over the limit (Issue #125)
@aclement, I inspected the existing logic and think it is safe to continue using the list instead of a set, mainly because it is more predictable and chronological which classpath JARs get closed on cache exhaustion (first in, first out). We would have to use a sorted set or map with a sortable timestamp or so as the key, which would entail more changes than I want to implement now. But I think I was pretty thorough with where to put the safeguards, my checks also encompassing subclasses. I think that for now we are OK, at least no worse than before. If @raimondas67 also re-tests successfully, I think the two PRs for JDT Core and AspectJ are ready to be reviewed and merged, whenever you have cycles to look into them.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@raimondas67, please try not to use full quotes. You could also edit the issue description, using code blocks for better formatting.
Thanks for the feedback, good news. 🙂
Yes, of course. I did not fix it, having too little information to reproduce it. I never thought that the two issues were related anyway, which is why I already asked you twice to create an extra issue with more information for the second issue. Thanks in advance. |
Fix classpath JAR close & re-open problem in AJC
The text was updated successfully, but these errors were encountered: