Bug 71002 - eclipse compiler incompatibility with javac
Summary: eclipse compiler incompatibility with javac
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-28 13:44 EDT by Venkat CLA
Modified: 2005-01-11 11:02 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 Venkat CLA 2004-07-28 13:44:11 EDT
We have quite a few legacy classes that were compiled using Javac earlier and we
have been using IntelliJ. I would like to move this project (large number of
files with over 30 developers) to Eclipse. I am running into the error "Cannot
make a static reference to the non-static field" for line "int i = 
Class1.FIELD1;" in the following situation:

package test;

public class CompilerTest {

	public Class1 Class1;
	
	public static void main(String[] args) {
		int i =  Class1.FIELD1;
	}
}

class Class1 {
	static int FIELD1;
}

Basically "Class1" is both a non a static variable as well as a class. The codes
were once generated from a business fields repository and some programmers
forgot to follow the proper naming convension leading to this situation. I have
a large number of files with the above situation and the variable name Class1
name is used in all over the place and can't easily change it.

I would like to make a request to Eclispe team to make the above error
configurable so that we can ignore for our project.
Comment 1 Olivier Thomann CLA 2004-07-28 14:47:53 EDT
I believe this was a bug in javac that has been fixed in 1.5.0 stream.
Compiling this code with 1.5.0 b59 reports:

CompilerTest.java:6: non-static variable Class1 cannot be referenced from a
static context
                int i =  Class1.FIELD1;
                         ^
1 error

Compiling with jikes:

Found 1 semantic error compiling "C:/tests_sources/CompilerTest.java":

     6.                 int i =  Class1.FIELD1;
                                 ^----^
*** Semantic Error: The field "Class1" is not static, and cannot be accessed in
this static context.
Comment 2 Olivier Thomann CLA 2004-07-28 16:43:29 EDT
Ok to close?
Comment 3 Venkat CLA 2004-07-29 15:34:39 EDT
Thanks for the response. You can close it.
Comment 4 Kent Johnson CLA 2004-08-03 10:13:27 EDT
Closed since its a bug with javac not eclipse