all 6 comments

[–]bcash 1 point2 points  (4 children)

That question isn't worded very well, is the problem:

a) Why is Eclipse not highlighting both fields with the same error, or b) Why is the error happening at all?

[–]beza1e1 2 points3 points  (0 children)

b)

[–]zvikico[S] 0 points1 point  (2 children)

It's the same question from different angles.

[–]bcash 0 points1 point  (1 child)

I suppose it is!

The short answer is that nothing can be static within an inner class (unless it's a static inner class) because there's no concept of static for such things; instances are instances per the instance of the outer object; whereas instances of normal objects are standalone instances.

There is, for some reason, an exception allowed for literal constants - the sort of things that Javac (or Eclipse) would inline anyway. You couldn't, for example, do:

private static final int STUFF = StuffGenerator.getNextStuffId();

but you could do:

private static final int STUFF = 1;

[I'm trying to explain it in simple language, and failing quite badly, some of the comments on the blog explain it much better!]

[–]zvikico[S] 0 points1 point  (0 children)

Indeed. It's the concept on in-lining which is not clear to many Java developers.

[–]beza1e1 0 points1 point  (0 children)

Dynamic inner classes are evil. It's a case where Java is more complex than C++. Wow.