Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5052968

REGRESSION: Source compatibility problem with java.io.File

    Details

    • Subcomponent:
    • Resolved In Build:
      b56
    • CPU:
      generic, x86
    • OS:
      generic, windows_xp

      Description



      Name: gm110360 Date: 05/25/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b50)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b50, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The class Test overrides the compareTo() methods of File. In B40 and earlier there were 2 seperate methods in File - compareTo(Object) and compareTo(File).

      My code overrides both because it needs to compare my class to things other than File (in particular I have an interface to encompass normal files and jar entries, but that is not shown here)

      Now (as of B50) that File implements Comparable<File> the compareTo(Object) method is a bridge method, and I can't override it.


      REGRESSION. Last worked in version tiger-beta

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac -source 1.4 Test.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The file compiles successfully.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Test.java:6: compareTo(java.lang.Object) in Test cannot override compareTo(java.lang.Object) in java.io.File; attempt to override a bridge method
         public int compareTo(Object o) { return 0; }
                    ^

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.io.File;

      public class Test extends File {
         public Test(String s) { super(s); }
         public int compareTo(File f) { return 0; }
         public int compareTo(Object o) { return 0; }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I wish there was one.

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 275043)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gafter Neal Gafter
                Reporter:
                gmanwanisunw Girish Manwani (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: