Bug 568199 - Potential NPE in InlineConstantTests.java
Summary: Potential NPE in InlineConstantTests.java
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.18   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-24 10:29 EDT by Carsten Hammer CLA
Modified: 2022-12-11 10:30 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Hammer CLA 2020-10-24 10:29:29 EDT
This problem has been introduced 15 years ago in the following commit:

commit 193f4a8dc2e375f38a0e0acc652f370a56a2ae84
Author: Tobias Widmer <twidmer> 2006-01-09 12:52:08
Committer: Tobias Widmer <twidmer> 2006-01-09 12:52:08
Parent: f8c31e791ac0c12991bdbe2dad74a48097edcfe0 (109071: [refactoring] Inlining array with initializer gives illegal expression.)
Child: 42569476d7e29ddc971c66153c5d91bddf226ccb (Updated copyright.)
Branches: change/144108/30, change/144108/33, change/144108/36, change/144108/37, change/144108/40, change/144108/46, change/144110/29, change/144110/31, change/144110/33, change/144110/35, change/144113/16, change/144113/18, change/144557/7, change/144558/6, change/144558/7, change/144558/8, change/144558/9, change/144559/9, change/144559/10, change/144559/11, change/144562/14, change/144563/10 and 233 more branches

Addes scripting support to all refactorings except Generalize Type

Since then we have following spotbugs issue in the code:

Bug: Possible null pointer dereference of null in org.eclipse.jdt.ui.tests.refactoring.InlineConstantTests.helper1(String[], int, int, int, int, int, boolean, boolean)

There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception can't ever be executed; deciding that is beyond the ability of SpotBugs. 

Rank: Scary (6), confidence: High
Pattern: NP_NULL_ON_SOME_PATH 
Type: NP, Category: CORRECTNESS (Correctness)

Obviously running the following code

InlineConstantRefactoring ref= new InlineConstantRefactoring(selectionCu, new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL).parse(selectionCu, true), selection.getOffset(), selection.getLength());
if (ref.checkStaticFinalConstantNameSelected().hasFatalError())
	ref= null;
RefactoringStatus preconditionResult= ref.checkInitialConditions(new NullProgressMonitor());

throws a NPE as soon as the if condition is fullfilled.
Comment 1 Eclipse Genie CLA 2022-12-11 10:30:34 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.