Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 471349

Summary: [extract constant] erroneous "not a valid static constant"
Product: [Eclipse Project] JDT Reporter: Zorzella Mising name <zorzella>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: noopur_gupta
Version: 4.5   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Zorzella Mising name CLA 2015-06-29 12:10:02 EDT
Use code snippet below. When trying to extract "bar" + "baz" as a constant, Eclipse says that's not possible because "it is not a valid static constant".

Inlining "foo" makes it work.

==========================================

public class ExtractConstantBug {
  
  void method() {
    String foo = "foo";
    String string = foo + "/" +
        // Select "bar" + "baz" and do Refactor > Extract Constant
        "bar" + "baz";
  }
}
Comment 1 Noopur Gupta CLA 2015-06-30 03:24:49 EDT

*** This bug has been marked as a duplicate of bug 95991 ***