-
-
Notifications
You must be signed in to change notification settings - Fork 358
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 on CtParameterReferenceImpl.getDeclaration(CtParameterReferenceImpl.java:44) #729
Comments
There may be a problem in the class |
I checked that the problem does not appear using 5.2.0-20160616.235102-85 |
Do you have any test case who highlight your bug? Because I can't reproduce it. I create a file with your snippet code (Foo class), I apply Spoon on it in no classpath mode and I execute a Query on each @Test
public void testDeclarationOfVariableReference() throws Exception {
final Launcher launcher = new Launcher();
launcher.addInputResource("./src/test/resources/noclasspath/Foo2.java");
launcher.getEnvironment().setNoClasspath(true);
launcher.buildModel();
launcher.getModel().getElements(new TypeFilter<CtVariableReference>(CtVariableReference.class) {
@Override
public boolean matches(CtVariableReference element) {
try {
if (element.getDeclaration() instanceof CtLocalVariable) {
}
} catch (NullPointerException e) {
fail("Fail with " + element.getSimpleName() + " declared in " + element.getParent().getSignature());
}
return super.matches(element);
}
});
} But everything works. |
I tried to isolate the problem in a test case but it also works. However, my tool does not work anymore. I will try to find the reason ASAP. |
Ok, the test doesn't work if I change it to: if (element.clone().getDeclaration() instanceof CtLocalVariable) {
} There is a bug in the clone. PR soon to fix it. |
Using the latest 5.2-SNAPSHOT (20160626) version I have a NPE (it was not the case some days ago).
My code is:
I think that the problem is the
clone
method ofCtParameterReferenceImpl
does not consider theexecutable
parameter, so that it can becomenull
in some cases.The code I analyse is (it concerns the local var
e
):The text was updated successfully, but these errors were encountered: