JDK-6234077 : No error for public class in wrong file
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0u1
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-02-28
  • Updated: 2010-04-03
  • Resolved: 2005-03-04
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.
JDK 6
6 b27Fixed
Related Reports
Relates :  
Description
The file Test1.java is incorrectly accepted by javac:

$ cat -n Test1.java
     1  @SuppressWarnings("dep-ann")
     2  /** @deprecated */
     3  public class Foo {}
$ cat -n Test2.java
     1  package foo;
     2  @SuppressWarnings("dep-ann")
     3  /** @deprecated */
     4  public class Foo {}
$ javac Test1.java
$ javac Test2.java
Test2.java:4: class Foo is public, should be declared in a file named Foo.java
public class Foo {}
       ^
1 error
$

###@###.### 2005-2-28 23:40:26 GMT

Comments
SUGGESTED FIX It's a one character fix: Change flags = Flags.DEPRECATED; to flags |= Flags.DEPRECATED; ###@###.### 2005-03-02 00:13:44 GMT
28-02-2005

EVALUATION This is a bug. The compiler should not accept the program. ###@###.### 2005-2-28 23:40:27 GMT Problem is independent of the type of annotation (e.g. change @SuppressWarnings to @Deprecated to get same result.) It *is* specifically related to the /** @deprecated */ javadoc comment. Change the comment so that it is not @deprecated, and the problem goes away. ###@###.### 2005-03-01 23:07:10 GMT Problem is in Parser, and occurs when /** @deprecated */ follows a modifier. In that case, it updates the modifier flags incorrectly, in this case zapping the public bit. Since the class is no longer marked public, the filename test is no longer applied. ###@###.### 2005-03-02 00:13:44 GMT
28-02-2005