Skip to content
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 adding files from an Eclipse plugin #1222

Closed
orichalque opened this issue Mar 13, 2017 · 2 comments
Closed

NullPointerException when adding files from an Eclipse plugin #1222

orichalque opened this issue Mar 13, 2017 · 2 comments
Labels

Comments

@orichalque
Copy link

Hello,

I'm trying to instrument classes from an Eclipse plug-in. I tried first from a simple Maven project and it worked well, but within the Eclipse plug-in environment I get the following stack trace:

Caused by: java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.batch.FileSystem.<init>(FileSystem.java:141)
	at org.eclipse.jdt.internal.compiler.batch.Main.getLibraryAccess(Main.java:3086)
	at spoon.support.compiler.jdt.JDTBatchCompiler.getUnits(JDTBatchCompiler.java:107)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnits(JDTBasedSpoonCompiler.java:410)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:372)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:348)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:119)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:102)
	at spoon.Launcher.buildModel(Launcher.java:700)
	at spoon.Launcher.run(Launcher.java:651)
	at cl2t.instrumentation.instrumenters.SpoonInstrumenter.instrumentTarget(SpoonInstrumenter.java:51)
	at cl2t.Cl2tRunner.lambda$1(Cl2tRunner.java:69)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
	at cl2t.Cl2tRunner.run(Cl2tRunner.java:69)
	at cl2t.handlers.DiscoveryHandler.execute(DiscoveryHandler.java:35)
	at cl2t.handlers.StatementHandler.execute(StatementHandler.java:22)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	... 37 more

What I'm doing is this:

                launcher = new Launcher();
		launcher.setArgs(new String[]{"--output-type", "nooutput"})
		String classFile = InstrumentationUtils.getSrcFile(target);
		File file = new File(classFile);
		System.out.println(file.exists()); //true
		FileSystemFile fsf = new FileSystemFile(file);
		launcher.addInputResource(fsf);
		launcher.addProcessor(new CompileProcessor());
		launcher.run();

When running on debug, I saw that the error comes from the following line in the FileSystem class:

protected FileSystem(Classpath[] paths, String[] initialFileNames, boolean annotationsFromClasspath) {
	final int length = paths.length; //paths = null
        ...

Should I add other command line options or is this the same bug as the 2 other issues #1191 and #1116 ?

Best Regards,

Thibault

@surli surli added the bug label Mar 13, 2017
@surli
Copy link
Collaborator

surli commented Mar 13, 2017

Hi,

is this the same bug as the 2 other issues #1191 and #1116

it really looks like the same bug: did you check by using the last SNAPSHOT version of Spoon?

@orichalque
Copy link
Author

orichalque commented Mar 13, 2017

Hi,
I noticed that I was using the snapshot 1 of Spoon 5.6.0. I tried with the last one, 77, and I can confirm that it works well now.

Thank you very much

@surli surli closed this as completed Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants