Bug 108731 - improved error message
Summary: improved error message
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 minor (vote)
Target Milestone: 3.2 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-02 18:15 EDT by Dave Dyer CLA
Modified: 2005-10-28 14:03 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Dyer CLA 2005-09-02 18:15:47 EDT
"package does not match the expected package"

Please tell me what package was expected!

And no, it's not obvious.  In the current case, I have a
file in a folder named "test" with a package declaration
of "test" and I'm mystified.
Comment 1 Dirk Baeumer CLA 2005-09-06 11:28:21 EDT
Dave, you are talking about a compiler error message.
Comment 2 Dani Megert CLA 2005-09-07 07:34:11 EDT
Normally we write which package is expected:
"Package does not match the expected package x.y.z"

Hover, I assume you run into the case where the CU is in the default package and
has a package declaration and then you get the message outlined in comment 0. A
better message would be:
"Type in default package must not have a package declaration"
Comment 3 Dirk Baeumer CLA 2005-09-07 12:03:59 EDT
Moving to Core then since the message is produced there.
Comment 4 Dave Dyer CLA 2005-09-07 13:04:35 EDT
no, the package in the file was "test" and the folder for the file
was "test", but the expected package was "".  This has got to the
the most common screwup of that kind - the classpath pointed to
the test directory instead of to its parent.   I'm very experienced,
but I still sometimes get into this confusing state, because the
operations that change .classpath are not intuitive.

It would be a great service to replace this terse one-line message
with a detailed explanation, listing the relevant class path,
implied package, and the package actually found.  It would be
even better if there were instructions to fix the problem the
two possible ways, by changing the file and by changing the 
classpath.
Comment 5 Kent Johnson CLA 2005-09-28 16:35:55 EDT
Is this ok?

The declared package "test" does not match the expected package ""
Comment 6 Dave Dyer CLA 2005-09-28 16:50:37 EDT
definitely better.

Consider the position of the poor luser who got this message
in the first place. If he has a certain amount of savvy and
his brain is wired the right way, he'll recognise what to do
based on this information.  On the other hand, there are a bunch
of significant pieces of knowlege that the use needs and may
not have, or may not come immediately to mind.  Perhaps the 
error message shoudn't write paragraphs about packages, classpaths
and file names, but it would be really useful to display a link
to a page that included discussions of those three things.
Comment 7 Kent Johnson CLA 2005-09-29 12:13:56 EDT
Changed PackageInfoTest test001()

Released change into HEAD
Comment 8 Olivier Thomann CLA 2005-10-28 14:03:29 EDT
Now the error is:
The declared package "p1" does not match the expected package "test"
Or:
The declared package "" does not match the expected package "test" for the
default package.

Verified for 3.2 M3 using build I20051025-0800+JDT/Core v_618a