-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
NullPointerException when using Spoon inside an IntelliJ Plugin (works with .jar but not with Maven) #1116
Comments
It looks like a problem with your classpath: can you give for input on the way you use Spoon in your project? |
Maven with IntelliJ ask where to download the files, it has chosen the /lib/ directory by default, but it has no effect (I tried in a folder outside the project, and I got the same exception). As for my use of Spoon, it didn't change between v 5.1.1 and v5.5, also it works if I import the jar with dependencies (v5.4), so I don't think the problem comes from there. In summary we use this code:
The exception is thrown inside the "buildModel" method. |
May be I am wrong, but I experienced similar error when I had 2 different JDK-core...jar files on the class path. One JDK-core comes from spoon and second (wrong one) comes from analyzed project. |
Thanks, I will look closer at it, but the -x arg should say to Spoon to not look on classpath ? |
It does not look on the classpath to retrieve types reference of the source you want to spoon, but it uses the classpath you give for its own dependencies like jdt.core.
From your classpath: if you run your project through intelliJ it automatically computes the classpath given your module/project dependencies. If you want to debug it, you can put a breakpoint at the begin of your program and in the debugger > Evaluate expression and type something like: ((URLClassLoader)ClassLoader.getSystemClassLoader()).getURLs(); You will see all jar loaded by your project when running. |
Do you manage to have more information about your bug? |
I'm not sure to understand why it does not show your local .m2 repository for the libs? Have you checked that your IntelliJ use maven dependencies in your project configuration? |
As I said on a previous post, it seems that IntelliJ does not use a .m2 repository. Instead, when I want to add a maven dependency, it asks me where I want to put the files.
As well as a new line in my IML config file : (This file also contains other orderEntry, "inheritedJdk", "source-folder" for example, I tried to change the order of these lines, but it does the same error) |
Ok I found it weird that IntelliJ does not use .m2 but I never use IntelliJ on windows.
So try maybe to remove extra dependencies in that specific file to see what happens? |
I close this issue for now. Don't hesitate to reopen it if you have more information. |
Actually there was a bug, we finally spot and fix it @mduruisseau :) |
Oh nice ! Thank you ;-) |
Yep! |
Hi !
Context:
We are using Spoon library inside an IntelliJ plugin for many months. Until now, we used version 5.1.1 downloaded from your website ("spoon-core-5.1.1-jar-with-dependencies.jar"). Earlier this week, we updated it on v 5.4, also using the .jar (with dependencies). Till then, no problem.
On the 11th January (v5.5 release), we switched to a maven dependency. Unfortunately, it looks like there is an incompatibility with IntelliJ and the JDT-core jar included by Spoon ?
I also tried Spoon v5.4.0 (from Maven) VS Spoon v5.4.0 (jar-with-dependencies), but it does the same thing: the jar is OK but when using Maven, it throws this exception:
Exception :
Using breakpoints and debugger, I found this :
When you can see the NullPointerException, apparently because "paths" is null.
However, I am not sure that the problem come from this file. Here is the diff between the two version of the FileSystem.class (decompiled by IntelliJ), on the left side, the one from IntelliJ, on the right side, the Spoon one.
I tried several methods to "force use" the .jar from Spoon, without success.
EDIT: Even when deleting the lib from IntelliJ (ecj-4.5.2.jar), the NP Exception is still thrown.
Have you any idea how I could fix that ?
Thanks !
The text was updated successfully, but these errors were encountered: