Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java compiler API a shit

Name: Anonymous 2019-01-03 11:35

assume that for some reason your're are writing a compiler plugin for javac, and your're are interested in body of a loop. here are the APIs for them:

https://docs.oracle.com/javase/8/docs/jdk/api/javac/tree/com/sun/source/tree/EnhancedForLoopTree.html
https://docs.oracle.com/javase/8/docs/jdk/api/javac/tree/com/sun/source/tree/DoWhileLoopTree.html
https://docs.oracle.com/javase/8/docs/jdk/api/javac/tree/com/sun/source/tree/ForLoopTree.html
https://docs.oracle.com/javase/8/docs/jdk/api/javac/tree/com/sun/source/tree/WhileLoopTree.html

notice something? they all have getStatement() methods for getting loop body, but for some godforsaken reason there's no interface or superclass defining those methods https://docs.oracle.com/javase/8/docs/jdk/api/javac/tree/com/sun/source/tree/StatementTree.html doesn't have them). so despite the fact that those methods have same names and do same shit, you must write shit like:


switch(statementTree.getKind()){
case FOR_LOOP:
ForLoopTree hax = (ForLoopTree)statementTree;
myAnus(hax.getStatement());
break;
case ENHANCED_FOR_LOOP:
EnhancedForLoopTree hax1 = (EnhancedForLoopTree)statementTree;
myAnus(hax1.getStatement());
break;
//... same shit ad nauseam }


the alternative is using reflection but that's arguably even worse.

fucking oracle retards, OOP was supposed to prevent exactly this kind of bullshit. how hard would it be to define a AbstractLoopTree?

Name: Anonymous 2019-01-03 15:06

>>4
'automatic variable' is a term that exists. 'enahnced for loop' is just bullshit
>>3
IIRC compiler API has been introduced by Oracle

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List