Naked dot - accessing object fields through unqualified "." [C1]

Joseph D. Darcy Joe.Darcy at Sun.COM
Thu May 14 22:24:19 PDT 2009


Reinier Zwitserloot wrote:
> 'Self-assignment is forbidden' would not be backwards compatibile.  
> Yes, such code would most likely be a bug, but its still an issue. It  
> would have to be a warning, at best.
>
> However:
>
> Every single external java compiler I know of will warn you when you  
> self-assign. Eclipse does it. So does netbeans. So does IDEA. So does  
> pmd. So does findbugs.
>
>
> If you internalize the self-assignment warning, where do you stop?  
> There are literally hundreds of 'duh, that must be a bug' warnings you  
> could generate. Not all of them are as obvious, or as non-contentious,  
> as 'self assignment'. So, where do you stop? Do we use the glacial  
> nature of the language changes process to set this up? I say: No. The  
> community has done a fine job of addressing these issues by creating  
> code checkers. So, I'd instead suggest:
>
> Any improvements to java core in this area should focus on improving  
> the ability for external tools to integrate better. For example, a way  
> to extend @SuppressWarnings with additional keywords would be great. A  
> way to let javac auto-find (via the SPI system) 'warning/error'  
> plugins would be another fine idea. Having any kind of plugin system  
> for the official javac to give other tools a go at creating warnings  
> and errors on the AST that javac's parser is building would be good  
>   

Catching up on responding to Coin email, that plugin system exists in 
javac as of JDK 6 in the form of annotation processors, the the 
-processor option etc.  Annotation processing in apt and javac was 
always intended to provide a general meta-programming facility and not 
be specific to annotations.  "Checking" processors occur at the front of 
the processor list, process "*" (all annotations, including the empty 
set), and claim no annotations; any annotation processor that is invoked 
is passed all types, not just the ones with particular annotations.  
Delving into the javac-specific tree API, full program information can 
be reconstructed from within an annotation processor.

-Joe



More information about the coin-dev mailing list