Community
Participate
Working Groups
"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.
Dave, you are talking about a compiler error message.
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"
Moving to Core then since the message is produced there.
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.
Is this ok? The declared package "test" does not match the expected package ""
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.
Changed PackageInfoTest test001() Released change into HEAD
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