| Summary: | Invalid potential null pointer access in casting variable | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Marco Descher <marco> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana, stephan.herrmann |
| Version: | 4.5.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
This solution also removes the npe warning
1: ISelection selection =
2: HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
3: IStructuredSelection strucSelection = (IStructuredSelection) selection;
4: if (selection instanceof IStructuredSelection) {
5: pat = (Patient) strucSelection.getFirstElement();
6: }
Stephan, can you comment on this please? Thanks! I wrongly got a binary comparison (single &) instead of a full comparison (double &). Fixing this removes the error. So this is NOT INVALID! (In reply to Marco Descher from comment #3) > I wrongly got a binary comparison (single &) instead of a full comparison > (double &). Fixing this removes the error. So this is NOT INVALID! Did you mean NOT VALID? yes :) or NOT NOT INVALID |
The following code gives me an invalid potential null pointer access at line 5: 1: ISelection selection = 2: HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); 3: if (selection != null & selection instanceof IStructuredSelection) { 4: IStructuredSelection strucSelection = (IStructuredSelection) selection; 5: pat = (Patient) strucSelection.getFirstElement(); 6: } if I modify the code like this, the message is gone 1: ISelection selection = 2: HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); 3: IStructuredSelection strucSelection = (IStructuredSelection) selection; 4: if (selection != null & selection instanceof IStructuredSelection) { 5: pat = (Patient) strucSelection.getFirstElement(); 6: }