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

Crash when static initializer attempts to assign to blank final variable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.3.0
    • 1.3.0
    • tools
    • rc2
    • generic
    • generic

      import java.net.*;

      public class Main {
          static {
      try {
      url = new URL("http://java.sun.com");
      } catch(MalformedURLException e) {
      throw new Error("internal error");
      }
          }

          // without final, it works !!!!!
          //static URL url;
          final static URL url;
      }
      $ jdk13; javac Main.java
      An exception has occurred in the compiler (1.3.0rc1). 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.InternalError: assertion failed
              at com.sun.tools.javac.v8.util.Util.assert(Util.java:25)
              at com.sun.tools.javac.v8.util.Bits.incl(Bits.java:65)
              at com.sun.tools.javac.v8.comp.Flow.letInit(Flow.java:156)
              at com.sun.tools.javac.v8.comp.Flow.letInit(Flow.java:174)
              at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:767)
              at com.sun.tools.javac.v8.tree.Tree$Assign.visit(Tree.java:848)
              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:626)
              at com.sun.tools.javac.v8.tree.Tree$Try.visit(Tree.java:642)
              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.analyzeDef(Flow.java:379)
              at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:445)
              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)

      iris.garcia@eng 2000-01-27

      The try/catch is not essential to reproducing the bug. Without it,
      the following results are obtained:

      p-1:~bugs> /usr/local/java/jdk1.3/solaris/bin/javac Main.java
      Main.java:5: unreported exception java.net.MalformedURLException; must be caught or declared to be thrown
           url = new URL("http://java.sun.com");
                 ^
      An exception has occurred in the compiler (1.3.0rc1). 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.InternalError: assertion failed
              at com.sun.tools.javac.v8.util.Util.assert(Util.java:25)
              at com.sun.tools.javac.v8.util.Bits.incl(Bits.java:65)
              at com.sun.tools.javac.v8.comp.Flow.letInit(Flow.java:156)
              at com.sun.tools.javac.v8.comp.Flow.letInit(Flow.java:174)
              at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:767)
              at com.sun.tools.javac.v8.tree.Tree$Assign.visit(Tree.java:848)
              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.analyzeDef(Flow.java:379)
              at com.sun.tools.javac.v8.comp.Flow._case(Flow.java:445)
              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)

      william.maddox@Eng 2000-02-11

            wmaddoxsunw William Maddox (Inactive)
            iris Iris Clark
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: