Conditional Compilation Though Compile time variable / parameters / fields / functions Annotation

Remi Forax forax at
Mon Apr 15 23:56:34 PDT 2013

On 04/16/2013 08:47 AM, Suminda Dharmasena wrote:
> Hi,
> I think the compiler can eliminate code based on final fields.

only static final field typed with a primitive or a String (true constants)

> I think it makes sense to add an annotation to maker variable / 
> parameters / fields / functions as compile time only. At some point 
> the compiler should be able to determine the code path or value of the 
> marked constructs through static analysis and replace the code as 
> appropriate. Other than parameters once compiled the constructs will 
> not be part of the class file. For determined literals the compiler 
> will replace the function call with an appropriate generated function 
> at the point of calling. If a function is marked as compile type only 
> the return value is determined through static analysis and the 
> function is eliminated from point of calling. If private the function 
> is removed altogether.
> If the code path or call param elimination or return values cannot 
> be statically determined the compiler should generate a warning and 
> ignore the tag.
> Aside from this an annotation for compile time inlining is desirable.
> This will give java an enhanced conditional compilation mechanism.

why do you want enhanced conditional compilation ?

why do you think that such kind of static analysis is possible in Java ?
 From my experience, given the way the classes are dynamically loaded,
it's a really hard task to do such analysis and to keep the actual 
semantics on Java.

> Suminda

Rémi Forax

> --
> Suminda Sirinath Salpitikorala Dharmasena, B.Sc. Comp. & I.S. (Hon.) 
> Lond., P.G.Dip. Ind. Maths. J'Pura, MIEEE, MACM, CEO Sakrīō!▣ 
> */Address/*: 6G • 1st Lane • Pagoda Road • Nugegoda 10250 • Sri Lanka. 
> ▣ */Tele/*: +94-(0)11-5 864614 / 5 875614 / 2 825908 ▣ */Web/*: 
> This email is subjected to the email Terms of Use and Disclaimer: 
> Please read this first.
> --

More information about the compiler-dev mailing list