PRB: Visual J++ 6.0 Code Generator Can Generate Ambiguous Names

SYMPTOMS

When compiling code from the code generator and wizards in a Windows
Foundation Classes (WFC) application, one of the following errors may
occur:

Class 'class' doesn't have a method that matches 'method()' (J0078)
-or-
Class 'class' doesn't have a constructor that matches 'class()' (J0082)
'field' is not a field in class 'class' (J0234)

CAUSE

The following import statements are made by the wizards and designer code
generators:


import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;
These imports can cause name collisions if your application defines classes
in different packages with the same name as those in the WFC packages.

RESOLUTION

If you must import a package that has class names that conflict with the
above import statements, you must make sure all of your code uses the fully
qualified class names. If you define a class in the default package that
conflicts with the above import statements, you must also make sure all of
your code uses the fully qualified class names. This includes changing code
that was generated by the wizards and Form Designer, for example changing
"new Point(300,300)" to "new com.ms.wfc.ui.Point(300,300)".

STATUS

This behavior is by design.

MORE INFORMATION

In some cases the Form Designer's code generator will generate code that
you will need to fully qualify. If the section of code requiring editing is
gray (read-only), you must first close the Form Designer window before
making your changes to the Java file. Warning: making future changes in the
Form Designer might change your code back to non-fully qualified names.

Steps to Reproduce Behavior

  1. From the File menu, select New Project.
  2. Click the New tab.
  3. Select Applications Folder under Visual J++ Projects.
  4. Select the Windows Application icon.
  5. Click Open.
  6. From the Project menu, select Add Class.
  7. Change the name field to Point.java.
  8. Click Open.
  9. From the Build menu, select Rebuild. You will get the following errors listed in the Task-List:


    Class 'Control' doesn't have a method that matches 'setSize(Point)'
    (J0078)


    Class 'Point' doesn't have a constructor that matches 'Point(int,int)'
    (J0082)
  10. To workaround the errors, double-click one of the above errors and
    change the statement from

          this.setSize (new Point(300,300));
    to:

          this.setSize (new com.ms.wfc.ui.Point(300,300));

REFERENCES

For the latest Knowledge Base articles and other support information on
Visual J++ and the SDK for Java, see the following pages on the
Microsoft Technical Support site:

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Derek
Jamison, Microsoft Corporation.
Propiedades

Id. de artículo: 194770 - Última revisión: 02/14/2017 - Revisión: 1

Microsoft Visual J++ 6.0 Edición estándar

Comentarios