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

java.lang.Object can't be redefined without crashing javac

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      hopper
    • CPU:
      generic
    • OS:
      generic, solaris_2.5.1
    • Verification:
      Verified

      Description

      There are two parts to this bug. Both of them are the compiler dying
      in unhelpful ways when someone tries to define java.lang.Object for
      themselves. Believe it or not, people try to do this (in order to
      give new functionality to all objects...)

      Part 1:

      package java.lang;

      public class Object implements Cloneable
      {
          public void wait()
          {
              System.out.println("Wait!");
          }
      }

      causes:

      sun.tools.java.CompilerError: collectInheritedMethods()
              at sun.tools.java.ClassDefinition.collectInheritedMethods(ClassDefinition.java:1167)
              at sun.tools.java.BinaryClass.basicCheck(BinaryClass.java:60)
              at sun.tools.java.ClassDeclaration.getClassDefinition(ClassDeclaration.java:122)
              at sun.tools.java.ClassDefinition.collectOneClass(ClassDefinition.java:968)
              at sun.tools.java.ClassDefinition.collectInheritedMethods(ClassDefinition.java:1214)
              at sun.tools.java.ClassDefinition.getInheritableMethods(ClassDefinition.java:1236)
              at sun.tools.java.ClassDefinition.collectOneClass(ClassDefinition.java:969)
              at sun.tools.java.ClassDefinition.collectInheritedMethods(ClassDefinition.java:1205)
              at sun.tools.java.BinaryClass.basicCheck(BinaryClass.java:60)
              at sun.tools.java.ClassDeclaration.getClassDefinition(ClassDeclaration.java:122)
              at sun.tools.javac.SourceClass.checkSupers(SourceClass.java:629)
              at sun.tools.javac.SourceClass.basicCheck(SourceClass.java:860)
              at sun.tools.java.ClassDeclaration.getClassDefinition(ClassDeclaration.java:122)
              at sun.tools.javac.Main.compile(Main.java:345)
              at sun.tools.javac.Main.main(Main.java:571)
      error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
      1 error

      Part 2:

      package java.lang;
       
      public class Object // no implements this time
      {
          public void wait()
          {
              System.out.println("Wait!");
          }
      }

      The first time this is compiled, life is good. The second time the
      binary .class gets picked up and causes the VM to say:

      Can't build argument array

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gafter Neal Gafter
              Reporter:
              dstoutamsunw David Stoutamire (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: