Bug 10466 - "Cannot reference a field before it is defined" - compiler bug?
Summary: "Cannot reference a field before it is defined" - compiler bug?
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-28 06:46 EST by Philipe Mulet CLA
Modified: 2002-03-01 04:34 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2002-02-28 06:46:27 EST
For the following code

public abstract class BooleanValueNode {

  public final static BooleanValueNode FALSE_NODE = new BooleanValueNode() {
    public BooleanValueNode not() { return TRUE_NODE; } // line 17 in
original code
    public Node and( Node n ) { return FALSE_NODE; }
    public Node or( Node n ) { return n; }
  };

  public final static BooleanValueNode TRUE_NODE = new BooleanValueNode() {
    public BooleanValueNode not() {return FALSE_NODE;}
    public Node and( Node n ) {return n;}
    public Node or( Node n ) {return TRUE_NODE;}
  };

  private BooleanValueNode() {
  }
  public abstract BooleanValueNode not();
  public abstract Node and( Node n );
  public abstract Node or( Node n );
}

I get the following compile time error:

Report for 1 markers:
Marker 1:
  Resource: [...]/BooleanValueNode.java, Line: 17
  Message: Cannot reference a field before it is defined
  Marker type: org.eclipse.jdt.core.problem
  Priority: Normal

I think this is not conforming to the JLS:

http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#1898
8

Jikes compiles the class without problems.

I didn't find a bug report on the eclipse website. Should I post one?

Regards, Ilja
Comment 1 Philipe Mulet CLA 2002-02-28 06:47:25 EST
Reproduced on build 20020226.

Indeed this is a bug, we should not complain when the forward reference is 
nested inside an innerclass.
Comment 2 Philipe Mulet CLA 2002-02-28 07:35:48 EST
The check for not complaining inside innerclasses did only work for instance 
fields.

Fixed