Community
Participate
Working Groups
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.
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.
Ok to close?
Thanks for the response. You can close it.
Closed since its a bug with javac not eclipse