Incident Report 9079511: Java Language Enhancement: Disallow access to static members via object references

Mahied Maruf contact at mechite.com
Fri Jan 23 18:15:14 UTC 2026


>> Mahied Maruf says:
>> I agree. I do think it's worth issuing warnings _by default_, and
>> turning this into _opt-out_ rather than _opt-in_.

> Brian Goetz says:
> It's easy to have this opinion for any given warning; for every warning, 
> there is _someone_ who thinks it should be turned up (if not all the way 
> to error.)   But these decisions need to be made within a more coherent 
> strategy than "this bug pattern really bugs me".  Otherwise, we set 
> `javac` on a path where its secondary mission is to be a mediocre static 
> analysis engine.  Our preference is to leave that to tools whose 
> _primary_ mission is static analysis -- of which there are many, and 
> they are all going to be much better at it than `javac`, because `javac` 
> has a different primary mission.

This makes sense. I don't doubt either that this has probably already
been discussed.  Just to say that the specific language feature being
dicussed here is minor enough and well-documented (in my opinion) such
the bar needs to be that it genuinely interferes enough with a new
language feature (or something else motivates it) to be changed.

I'm on the side here of no change.  The language generally has a lot
more 'donts' than 'dos' for writing what we would call 'idomatic'
software.  The case of the IDE not being able to properly analyze:

	class Test ...

	Test test = null;
	test.test();

...as not being disallowed, can be attributed to an effort not being
made in being exhaustive with implementing this static analysis.

> Tagir Valeev says:
> At this stage of analysis, we cannot spend time on resolving the
> `test()` call and checking whether it's static or not...

I assume by "spend time" we are implying that it's an expensive check
to make, and I would say that (a) this can be rare enough to forgo the
check, and (b) the language being expensive to analyze is not (should
not be said as being) at flaw of the language.

The static analyzer is generally supposed to be "in good faith"
estimation of what will happen at runtime.

Best regards,
Mahied Maruf <contact at mechite.com>


More information about the amber-dev mailing list