This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 163698

Summary: Create class hint could infer type
Product: java Reporter: _ tboudreau <tboudreau>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description _ tboudreau 2009-04-27 01:45:34 UTC
Say you have 

public enum Foo {
  A,
  B;
  public Bar getBar() {
    switch(this) {
      case A :
        return new A_Bar();
      case B :
        return new B_Bar();
      default :
        throw new AssertionError("" + this);
  }
  interface Bar() {}
  class A_Bar implements Bar {}
}

The line 
return new B_Bar();
will give you a create class hint.

We know the return type of getBar() is Bar.  But the class generated if you accept the hint is
public class B_Bar {
  public B_Bar() {
  }
}

Two things could improve the result:
1.  It could be 
public class B_Bar implements Bar

2.  If Bar is package private, make the generated class and constructor package-private too.
Comment 1 Max Sauer 2009-04-27 10:24:01 UTC
Definitely. Thanks for your ideas.