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

Bug 365283

Summary: Quickfix to unneccessary code / non-static class property
Product: [Eclipse Project] JDT Reporter: Peter <p.rader>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, jarthana, manoj.palat, stephan.herrmann
Version: 3.8   
Target Milestone: 4.4 M7   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Peter CLA 2011-12-01 04:17:26 EST
Build Identifier: 

If an class contains nonstatic subclasses, the subclass can only instanticated  from classinstances only (i.e. factory-creational-pattern GoF). Often those subclasses requires params from the class.

Sometimes users pass those values to the subclass via constructor-parameter, instead of pass those values directly to the subclassfield. 

Reproducible: Always

Steps to Reproduce:
public class TeaFactory{
  String factoryFlavour="Earl Grey";
  public class Teabag{
    public final String flavour;
    Teabag(String factoryFlavour){
      this.flavour = factoryFlavour;
    }
  }
  public TeabagNEW{
    public final String flavour = factoryFlavour;
  }
  public Teabag produceTeabag(){
    return new Teabag(factoryFlavour);
  }
}
Comment 1 Ayushman Jain CLA 2011-12-01 10:20:35 EST
Can you please give a valid code snippet? The above snippet is invalid because of "public TeabagNEW{".
Also, please clearly mention what error are you asking a quick fix for.
Comment 2 Peter CLA 2014-04-10 04:36:35 EDT
No, sorry.
Comment 3 Manoj N Palat CLA 2014-04-29 02:41:07 EDT
Verified as invalid for Eclipse Luna 4.4 M7 Build id: I20140428-2000