You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using getEnvironment.report(processor, Level.INFO, element, "Message...") in my processor i get a NullPointerException if the element is implicit.
Source code you are trying to analyze/transform
packagefr.inria.gforge.spoon.analysis;
/** * The Class Testcase2. * * testcase to show NullPointerException */publicclassTestcase2
{
privateclassA
{
}
privateclassBextendsA
{
/** * Instantiates a new b. */publicB()
{
super();
}
}
publicstaticvoidmain(String[] args)
{
Testcase2t = newTestcase2();
t.test();
}
publicStringtest()
{
varb = newB();
returnb.toString();
}
}
Source code for your Spoon processing
packagefr.inria.gforge.spoon.analysis;
importjava.util.List;
importspoon.processing.AbstractProcessor;
importspoon.reflect.code.CtInvocation;
importspoon.reflect.declaration.CtConstructor;
importspoon.reflect.visitor.Query;
importspoon.reflect.visitor.filter.TypeFilter;
importspoon.support.Level;
/** * Processor to show {@link NullPointerException} thrown if element is implicit. * * @author r.b. * */publicclassBugProcessorextendsAbstractProcessor<CtConstructor<?>>
{
/** * implementation walks through all invocations and just prints them * * @see spoon.processing.AbstractProcessor#isToBeProcessed(spoon.reflect.declaration.CtElement) * * @param candidate element to check * @return true if the element should be processed */publicbooleanisToBeProcessed(CtConstructor<?> candidate)
{
booleanprocess = false;
List<CtInvocation<?>> invocations = Query.getElements(candidate, newTypeFilter<>(CtInvocation.class));
invocations.forEach(i -> getEnvironment().report(this, Level.INFO, i, "Message"));
returnprocess;
}
/** * @see spoon.processing.Processor#process(spoon.reflect.declaration.CtElement) * * @param element */@Overridepublicvoidprocess(CtConstructor<?> element)
{
// no functionality here ...
}
}
brandy007
changed the title
Bug: Environment.report(...) throws NullPointerException
[Bug]: Environment.report(...) throws NullPointerException
Nov 4, 2022
Describe the bug
using getEnvironment.report(processor, Level.INFO, element, "Message...") in my processor i get a NullPointerException if the element is implicit.
Source code you are trying to analyze/transform
Source code for your Spoon processing
Actual output
Expected output
Spoon Version
10.2.0
JVM Version
11
What operating system are you using?
win10
The text was updated successfully, but these errors were encountered: