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 76502

Summary: [Extract Super Class] Necessary constructor not created when extracting form class with super calls
Product: java Reporter: Jiri Prox <jiriprox>
Component: RefactoringAssignee: Jan Pokorsky <jpokorsky>
Status: VERIFIED FIXED    
Severity: blocker    
Priority: P3    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 99968, 103642    
Bug Blocks:    

Description Jiri Prox 2006-05-17 16:43:35 UTC
NB 5.5 beta 200605090801
JDK 1.6.0 b84

Necessary constructors not created when extracting super class from class which
already extends other class and uses super calls in constructors. The newly
created class has only default constructor.

Steps to reproduce:
1) try to extract super class named NewClass from following class (SuperClass
has one constructor with one argument of type String):

public class Main extends SuperClass {   
    public Main(String text) {
        super(text);    
    }        
}

-> super(text) is invalid while NewClass has only default constructor
-> default constructor in NewClass requires default construcotr in SuperClass
but it does not exist

Solution can be to add all required constructor which only propagates their
arguments to former super class by calling super

e.g in out case:
protected NewClass(String text) {
  super(text);
}
Comment 1 Jan Becicka 2006-11-22 10:52:25 UTC
Not implemented in trunk so far.
Comment 2 Jan Pokorsky 2007-04-24 16:14:13 UTC
Checking existing constructors for super(...) and generating adequate
constructors should help.
Comment 3 Jan Pokorsky 2007-05-10 13:07:09 UTC
fixed in

/cvs/refactoring/java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
new revision: 1.5; previous revision: 1.3
Comment 4 Jiri Prox 2007-05-31 15:26:44 UTC
Only part of issue seem to be fixed. The extracted class (named NewClass in this
test case) still have default constructor, with implicit super() call 
Comment 5 Jan Pokorsky 2007-08-30 20:05:14 UTC
It is a generator issue. I will reopen the issue #103642.
Comment 6 Jan Pokorsky 2007-08-31 11:12:17 UTC
Closing. There is nothing what can be done on the refactoring side. The issue #103642 tracks this problem.
Comment 7 Jiri Prox 2007-10-04 13:03:32 UTC
ok -> v.