Assertions in static blocks ?

Ulf Zibis Ulf.Zibis at
Sat Mar 6 03:44:43 PST 2010

Am 06.03.2010 00:33, schrieb Benedict Elliott Smith:
> It's not /generally/ possible to determine if a class initializer will 
> ever be run.
> It would be possible to determine that, if a class were declared with 
> default (package) level protection and was never referenced by another 
> class in the package, that the class was not used (/so long as the 
> program did not violate the protection via reflection)/; but this is 
> the best that could be achieved (there is an argument to be made for 
> javac to complain in this case, as it will in the case of unused 
> private classes, however I am not certain it is necessary), however I 
> do not think this is what you are suggesting.
> It would be possible, if the class were declared with default 
> protection, and no class in the package referenced anything within it 
> other than constant fields, to determine that the initialiser was 
> never executed, I suppose.

My class *is* package private, but I can't see how it should help. ... 
and currently it doesn't help to make the static initializer running.

> I'm not a developer of javac but I'm not convinced that it is a 
> sufficiently useful boundary case to warrant the burden of every 
> execution of javac in the world calculating it. Probably 
> the increased global power usage as a result of this would raise the 
> sea level another micrometer or two for very little benefit in my mind!

I like to think about power usage. That's the reason I'm working on 
EUC_TW charset making it faster and consuming less memory.
Checking practically never reached static blocks seems to be nothing 
than working on a system using EUC_TW charset.


-------------- next part --------------
An HTML attachment was scrubbed...

More information about the compiler-dev mailing list