Bug 177187 - Package that has another name that folder does not have warning message.
Package that has another name that folder does not have warning message.
Status: VERIFIED FIXED
Product: javafx
Classification: Unclassified
Component: Editor
6.x
PC Windows XP
: P2 (vote)
: 6.x
Assigned To: J Bachorik
issues@javafx
68patch1-verified
: REGRESSION
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-19 04:52 UTC by Alexandr Scherbatiy
Modified: 2010-01-26 03:25 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments
Message in Java editor (19.24 KB, image/png)
2009-11-19 04:57 UTC, Alexandr Scherbatiy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr Scherbatiy 2009-11-19 04:52:37 UTC
Product Version         = NetBeans IDE Dev (Build 200911190201) (#af12b770d49f)
  Operating System        = Windows XP version 5.1 running on x86
  Java; VM; Vendor        = 1.6.0_15; Java HotSpot(TM) Client VM 14.1-b02; Sun Microsystems Inc.


Steps to reproduce:
- Create 'javafxapplication' package
- Create JavaFX file
- Define the package for the file as 'javafxapplicationX'
------------------  Main.fx  ------------------
package javafxapplicationX; 
-----------------------------------------------

The package does not have warning message:
 - Move class to correct folder
 - Change package declaration to javafxapplication
Comment 1 Alexandr Scherbatiy 2009-11-19 04:55:22 UTC
I thing that the issue 174734  Package statement incorrectly underlined 
is wrong.

The same behavior is for Java.
In Java the class can have the different name than folder but the editor marks such statement as error to help users.

The same should be in JavaFX editor.
Or at least the editor should show warning on such package and suggest
 
 - Move class to correct folder
 - Change package declaration to javafxapplication
Comment 2 Alexandr Scherbatiy 2009-11-19 04:57:07 UTC
Created attachment 91328 [details]
Message in Java editor
Comment 3 Alexandr Scherbatiy 2009-11-19 04:59:47 UTC
Regression from issue 174734
Comment 4 J Bachorik 2009-11-19 05:09:51 UTC
This is rather questionable. According to the lang spec (http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.4) there is no rule about placing the java sources to the directory structure mirroring their packaging. So, from this point of view, it seems that Java editor is rather off-track.

Also, the source is very well compilable (in java as well as in javafx) so displaying the error annotation is pretty misleading. The editor should at most give a warning (yellow underline, yellow sign) about the mismatch between the class packaging and its physical location but should not confuse user with false error messages.

I don't think this is a regression - the behavior was wrong before attempting to fix issue #174734 and is slightly less wrong now (but not correct, I admit).
Comment 5 J Bachorik 2009-11-19 05:13:37 UTC
Also, the question is whether we should invent our own warnings or rather display only the warnings generated by the compiler.
Comment 6 Alexandr Scherbatiy 2009-11-19 05:18:00 UTC
In this case the IDE should help users to fix the problem with package name if it has unintentional mistake.
Comment 7 J Bachorik 2009-11-19 05:30:34 UTC
But according to the language specification this is not a problem. A hint would be more appropriate here. Also, there may be users not wanting to have the packages linked with physical location.
Comment 8 Lukas Hasik 2009-11-19 06:03:49 UTC
I agree that the error isn't necessary however it is easy to make a mistake in the name. The IDE should help the developer. There should be at least "warning" (not error) and definitely the hint.
Comment 9 Alexandr Scherbatiy 2009-11-19 06:35:56 UTC
The explanation why the wrong package has been marked as error can be:

- Create a Main javafx file:
--------------------------------------------- 
package javafxapplication;

import javafx.stage.Stage;
Stage {
}
--------------------------------------------- 

- Change package to javafxapplicationX
--------------------------------------------- 
package javafxapplicationX;

import javafx.stage.Stage;
Stage {
}
--------------------------------------------- 

- Run the project 

Main-Class not found javafxapplication.Main

java.lang.ClassNotFoundException: javafxapplication.Main
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.sun.javafx.runtime.Main.main(Main.java:68)


So the running system is unable to find the Main file with the wrong package.
Comment 10 J Bachorik 2009-11-19 07:30:56 UTC
The last described scenario shows problems in the project integration more than problems with editor. If you modify the project properties (Properties/Run) to use javafxappliactionX.Main as the main class and start the project from command line (ant run) everything runs as supposed. However, when you try to run the same project from IDE it starts complaining that it can not find the main class and offers you to choose the non-existing class javafxapplication.Main as the main one.
Comment 11 Alexandr Scherbatiy 2009-11-19 07:36:59 UTC
Let's create an issue that the Properties dialog should search Main class in project and than check the right package from the file.
Comment 12 Alexandr Scherbatiy 2009-11-27 03:47:51 UTC
I still think that it is the regression.

What I do is:

- Create a JavaFX project
- Open a Main file
- Remove all from the main file
- Copy a sample code from a JavaFX Tutorila or doc to the Main file
- Run it 
  I see java.lang.ClassNotFoundException: javafxapplication.Main

Before the issue 174734 was fixed I see an error hint that I can click and it suggested me to add the right package.

Now I do not see any hint.
Comment 13 Alexandr Scherbatiy 2009-12-11 03:52:05 UTC
Regression from the fix of the issue 174734
Comment 14 J Bachorik 2009-12-11 05:24:28 UTC
Changeset: 224b4bb5eda0
Author:    Jaroslav Bachorik <yardus@netbeans.org>
Date:      2009-12-11 13:24
Message:   Issue #177187 - Package that has another name that folder does not have warning message.
Reverting the fix for #174734. It seems that a standard was set in java editor which I should better follow
Comment 15 Alexandr Scherbatiy 2009-12-17 03:51:56 UTC
verified in NetBeans-dev-javafx-main-123-on-091217-full.zip
Comment 16 rbalada 2010-01-21 02:41:45 UTC
The fix has been ported to release68_fixes branch
http://hg.netbeans.org/javafx/rev/f7a942bda44d
Comment 17 Alexandr Scherbatiy 2010-01-26 03:25:50 UTC
Verified in NB 6.8 patch1 2010-01-25_21-27-59


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo