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

Compiler throws exception on invalid inheritance

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • tools
    • x86
    • windows_2000



      Name: skT45625 Date: 07/13/2000


      \jdk1.3\bin\java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


      Compile the following (yes, I know it's not legal) code:

      class foo extends String[]
      {
      }

      Yields the following message:
      An exception has occurred in the compiler (1.3.0). Please file a bug at the Java
      Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi). Include your
      program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
      at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:746)
      at com.sun.tools.javac.v8.tree.Tree$Apply.visit(Tree.java:785)
      at com.sun.tools.javac.v8.comp.Flow.analyze(Flow.java:321)
      at com.sun.tools.javac.v8.comp.Flow.analyzeExpr(Flow.java:339)
      at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:719)
      at com.sun.tools.javac.v8.tree.Tree$Exec.visit(Tree.java:699)
      at com.sun.tools.javac.v8.comp.Flow.analyze(Flow.java:321)
      at com.sun.tools.javac.v8.comp.Flow.analyzeStat(Flow.java:394)
      at com.sun.tools.javac.v8.comp.Flow.analyzeStats(Flow.java:413)
      at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:520)
      at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:492)
      at com.sun.tools.javac.v8.comp.Flow.analyze(Flow.java:321)
      at com.sun.tools.javac.v8.comp.Flow.analyzeStat(Flow.java:394)
      at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:488)
      at com.sun.tools.javac.v8.tree.Tree$MethodDef.visit(Tree.java:441)
      at com.sun.tools.javac.v8.comp.Flow.analyze(Flow.java:321)
      at com.sun.tools.javac.v8.comp.Flow.analyzeDef(Flow.java:379)
      at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:456)
      at com.sun.tools.javac.v8.tree.Tree$ClassDef.visit(Tree.java:402)
      at com.sun.tools.javac.v8.comp.Flow.analyze(Flow.java:321)
      at com.sun.tools.javac.v8.comp.Flow.analyzeDef(Flow.java:379)
      at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:380)
      at com.sun.tools.javac.v8.Main.compile(Main.java:247)
      at com.sun.tools.javac.Main.main(Main.java:16)

      Instead of this exception, I would expect a message like I get from jdk1.2.2:
      foo.java:3: Can't subclass final classes: class java.lang.String
      public class foo extends String[]
                               ^
      foo.java:3: '{' expected.
      public class foo extends String[]
                                     ^
      2 errors
      (Review ID: 107184)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: