JDK-6198196 : package-info.java: Weird compiler error
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: generic
  • Submitted: 2004-11-20
  • Updated: 2010-12-02
  • Resolved: 2005-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u15-revFixed 6 b40Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Compiling package-info.java gives this error:

E:/ws/hostd/bora/vim/vmodl/vim/host/package-info.java:4: package annotations
should be in file package-info.java
@wsdlName("Host") package vim.host;

The file looks like this:

   @wsdlName("Host") package vim.host;
   import vmodl.*;

Addtional info from submitter:

I was able to reproduce the problem on WindowsXP using your files.

My command line was:
         javac C:/home/pcanning/wsdlName.java 
C:/home/pcanning/package-info.java
It is important that the slashes be forward slashes not backward slashes.
If I do
         javac C:\home\pcanning\wsdlName.java 
C:\home\pcanning\package-info.java
or
         javac wsdlName.java package-info.java
I don't get the error.

--- package-info.java ---
@wsdlName("Host") package vim.host;
import vmodl.*;

--- wsdlName.java ---
package vmodl;
public @interface wsdlName { String value(); }



Comments
WORK AROUND Use cygwin or don't use forward slashes on Windows. ###@###.### 2004-11-25 02:16:06 GMT
25-11-2004

SUGGESTED FIX Index: src/share/classes/com/sun/tools/javac/comp/Enter.java ============================================================ @@ -369,28 +368,23 @@ */ private static boolean classNameMatchesFileName(ClassSymbol c, Env<AttrContext> env) { - // XXX 06/09/99 iris - // Using a Name for filename is a small abuse of the abstraction. String fname = env.toplevel.sourcefile.toString(); String cname = c.name + ".java"; - try { - return - endsWith(fname, cname) - // hack to make things work for Windows 95: - || endsWith(new File(fname).getCanonicalPath(), cname); - } catch (java.io.IOException ex) { - return false; - } + return endsWith(fname, cname); } //where /** Does path name have file name as last component? */ protected static boolean endsWith(String pathname, String filename) { - return - pathname.endsWith(filename) && - (pathname.length() == filename.length() || - pathname.charAt(pathname.length() - filename.length() - 1) == - File.separatorChar); + if (pathname.endsWith(filename)) { + int diff = pathname.length() - filename.length(); + if (diff == 0 || pathname.charAt(diff - 1) == File.separatorChar) + return true; + File path = new File(new File(pathname).getName()); + File file = new File(filename); + return path.equals(file); + } + return false; } /** Complain about a duplicate class. */ ###@###.### 2004-11-25 04:15:43 GMT
25-11-2004

EVALUATION I need a reproducible test case. ###@###.### 2004-11-20 00:43:05 GMT Based on the additional information from the submitter I was able to reproduce the problem on Windows XP. You need to run it from the Windows command prompt, cygwin is too helpful. I cannot create a regression test as I don't have a way to test platform specific behavior. ###@###.### 2004-11-25 02:08:04 GMT SQE (###@###.###) will implement tests for this. ###@###.### 2004-11-29 18:38:15 GMT I turns out that it is easy to write test for platform specific behavior in jtreg, so SQE doesn't need to write a test case. ###@###.### 2005-05-27 23:03:53 GMT
20-11-2004