eclipse-aspectj / aspectj

Other
303 stars 86 forks source link

NPE in AjBuildConfig.computeCheckedClasspath #169

Closed slachiewicz closed 2 years ago

slachiewicz commented 2 years ago

I'm working to upgrade aspectj to latest version in https://github.com/codehaus-plexus/plexus-compiler Unfortunately, starting from version 1.9.8 i got NPE like bellow

[ERROR] org.codehaus.plexus.compiler.ajc.AspectJCompilerTest.testCompilingSources  Time elapsed: 0.516 s  <<< ERROR!
java.lang.NullPointerException: Cannot read the array length because "array" is null
        at java.base/java.util.Arrays.stream(Arrays.java:5428)
        at org.aspectj.ajdt.internal.core.builder.AjBuildConfig.computeCheckedClasspath(AjBuildConfig.java:937)
        at org.aspectj.ajdt.internal.core.builder.AjBuildConfig.getCheckedClasspaths(AjBuildConfig.java:274)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.getLibraryAccess(AjBuildManager.java:946)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1047)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:275)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:188)
        at org.codehaus.plexus.compiler.ajc.AspectJCompiler.compileInProcess(AspectJCompiler.java:474)
        at org.codehaus.plexus.compiler.ajc.AspectJCompiler.performCompile(AspectJCompiler.java:329)

our code below: https://github.com/codehaus-plexus/plexus-compiler/blob/master/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java#L343

kriegaex commented 2 years ago

Hm, the last substantial commit (disregarding the latest linting commit) in that file was my own. I never looked into Plexus Compiler anymore since then, but hopefully one of these days (maybe not before next weekend) I can spare some private time to take a look. Would that be acceptable?

kriegaex commented 2 years ago

I do not know the AJDT API of AspectJ very well, but I debugged around a bit and sent you a PR in order to fix it in Plexus Compiler. The PR piggy-backs directly on top of your Dependabot PR. Merge it in there, then merge the Dependabot issue, and you should be fine. Or maybe you want to merge my PR directly into master, whatever.