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

Compiler error - assignment of short to a final int in constructor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.3
    • tools
    • None
    • sparc
    • solaris_2.5



      Name: sg39081 Date: 10/22/97


      class InitBug
      {
          // Initializing value must be a final int
          final int DEFAULT = -1;

          short Short;
          Long variable_of_any_type; // String, int, long, short, Integer, Long,
      etc... all work

          InitBug()
          {
              Short = DEFAULT;

              // As long as Short is not the last variable initialized, the error
      occurs
              // The error occurs before the variable initialization below is
      type-checked
              variable_of_any_type = 5;
          }
      }


      sun.tools.java.CompilerError: addReference InitBug this
              at sun.tools.java.ClassDefinition.addReference(ClassDefinition.java)
              at sun.tools.java.ClassDefinition.getReference(ClassDefinition.java)
              at sun.tools.tree.Context.noteReference(Context.java)
              at sun.tools.tree.Context.makeReference(Context.java)
              at sun.tools.tree.ThisExpression.checkValue(ThisExpression.java)
              at sun.tools.tree.Expression.checkAmbigName(Expression.java)
              at sun.tools.tree.FieldExpression.checkCommon(FieldExpression.java)
              at sun.tools.tree.FieldExpression.checkValue(FieldExpression.java)
              at
      sun.tools.tree.IdentifierExpression.checkValue(IdentifierExpression.java)
              at sun.tools.tree.AssignExpression.checkValue(AssignExpression.java)
              at
      sun.tools.tree.BinaryAssignExpression.check(BinaryAssignExpression.java)
              at sun.tools.tree.ExpressionStatement.check(ExpressionStatement.java)
              at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
              at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
              at sun.tools.tree.Statement.checkMethod(Statement.java)
              at sun.tools.javac.SourceField.check(SourceField.java)
              at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
              at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
              at sun.tools.javac.SourceClass.check(SourceClass.java)
              at sun.tools.javac.Main.compile(Main.java)
              at sun.tools.javac.Main.main(Main.java)
      error: An error has occurred in the compiler; please file a bug report
      (http://java.sun.com/cgi-bin/bugreport.cgi).
      1 error

      ======================================================================

            tturnidgsunw Todd Turnidge (Inactive)
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: