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 78406 - RE inserts wrong import into source code when add new Exception by property window
Summary: RE inserts wrong import into source code when add new Exception by property w...
Status: RESOLVED DUPLICATE of bug 118542
Alias: None
Product: uml
Classification: Unclassified
Component: Code Generation (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@uml
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-19 23:14 UTC by bugbridge
Modified: 2008-07-08 22:41 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bugbridge 2006-06-19 23:14:53 UTC
Original status: 1-Dispatched; Suggested Status: NEW

Original submitter: sunflower

Description:
Netbeans 5.5 Preview (build 2006.02.08)

Steps to reproduce:

- Create General Java Class Library project
- Add 'library' package into the Library project
- Add 'MyClass' and 'MyType' classes into the 'library' package
- Add 'MyInterface'interface into the 'library' package
- Add 'MyException' exception into the 'library' package


- Create General Java Application project
- Select 'Libraries' node under the Application project
  and add the Library project via popup menu
- Add 'pack' package into the Application project
- Add the following 'TestClass' class into the 'pack' package
  -----------------------------------------------------------------
    package pack;

    import library.*;

    public class TestClass extends MyClass implements MyInterface{

        public TestClass() {
        }

        public MyType operation() throws MyException {
            return null;
        }

    }
  -----------------------------------------------------------------

- Build the Application project
  The the Application project should be successfully  compiled


- Create UML Reverse Engineering project associated with the Application project
- Select 'pack.TestClass' node in the UML Model project tree
  and invoke 'Generate Dependency Diagram'
- Go to created class diagram
- Select 'public MyType operation()' operation on the 'TestClass' element class
- Go to 'operation - Properties' window and push on 'Raised Exceptions' property
  'operation - Raised Exceptions' dialog should appear
- Press 'Add' button on the dialog and add 'Exception' into a name list on the
dialog
- Press 'OK' button on the dialog
- Build the Application project
  The project is not compiled:

  Compiling 1 source file to JavaApplication\build\classes
  JavaApplication\src\pack\TestClass.java:4: '.' expected
  import MyClass;
  JavaApplication\src\pack\TestClass.java:5: '.' expected
  import MyInterface;
  JavaApplication\src\pack\TestClass.java:6: '.' expected
  import MyClass;
  JavaApplication\src\pack\TestClass.java:7: '.' expected
  import MyInterface;
  4 errors
  BUILD FAILED (total time: 0 seconds)

Incorrect  imports are added into the sorce code of the 'TestClass' class:

  -----------------------------------------------------------------


    package pack;

    import library.*;
    import MyClass;
    import MyInterface;
    import MyClass;
    import MyInterface;

    public class TestClass extends MyClass implements MyInterface{

        public TestClass() {
        }

        public MyType operation() throws MyException, Exception {
           return null;
        }

    }


  -----------------------------------------------------------------
Comment 1 Trey Spiva 2006-07-11 00:47:18 UTC
When the user creates a specifies the name of a model element, that does not
exist in the model, we create a data type.  Since the new data type was a side
affect of the user action, we create the data type into the default package.  It
is up to the user to specify the correct location of the data type.  

Now I can see the argument that this is a standard Java class, so we should
recognize the data type and create it in the correct package structure.  However, 
this will not fix non Java types. 

The correctly solution is to have Reference Libraries.  When a user types in a
name that is not in the model, the reference libraries should be checked. 
Comment 2 Peter Lam 2007-03-20 23:24:54 UTC
low use case not currently impacting our installed user base.
Comment 3 Viktor Lapitski 2007-07-14 02:27:05 UTC
putting it for iteam review either as a waiver or to re-categorize 
into enhancement as it is a case of missing feature 
implementation for which i believe is beyond the planned scope of the release
Comment 4 George Vasick 2008-01-15 22:04:54 UTC
Reviewed and approved for waiver by UML -iteam.
Comment 5 Peter Lam 2008-05-23 01:38:49 UTC
verified in NB 6.5 latest build 20080521.
Now the following codes are generated.

package pack;

import library.*;

public class TestClass extends MyClass implements MyInterface {

    public TestClass () {
    }

    public MyType operation () throws MyException, pack.Exception {
        return null;
    }
}


Building it returned the following error.

Compiling 1 source file to C:\Users\peter\Documents\NetBeansProjects\JavaApplication4\build\classes
C:\Users\peter\Documents\NetBeansProjects\JavaApplication4\src\pack\TestClass.java:24: cannot find symbol
symbol  : class Exception
location: package pack
    public MyType operation () throws MyException, pack.Exception {
1 error
BUILD FAILED (total time: 0 seconds)
Comment 6 George Vasick 2008-07-08 00:05:14 UTC
This appears to be a code gen rather than RE problem.
Comment 7 Trey Spiva 2008-07-08 22:41:37 UTC
This is user error.  The user should put the fully qualified name of the class java::lang::Exception or place the datatype into the correct package.  That way 
the code generation will know how to import the type correctly. 

Now a feature like a model library would make it much simpler to use a modeling tool.  However this is already covered in the enhancement Issue 118542.  
So I am going to close this as an duplicate of the Issue 118542.

*** This issue has been marked as a duplicate of 118542 ***