Last active
June 28, 2016 15:04
-
-
Save edefazio/d069b76be72ba39f68411fc6e99408c9 to your computer and use it in GitHub Desktop.
VARCODE Self-Tailoring Java Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ex.varcode; | |
/*{-*/ | |
import io.varcode.tailor.java.JavaCase; | |
/*-}*/ | |
public class /*{+className*/_1/*+}*/ | |
{ | |
public /*{+className*/_1/*+}*/() | |
{ | |
System.out.println( /*{+message*/"Hello!"/*+}*/ ); | |
} | |
/*{-*/ | |
public static void main( String[] args ) | |
{ | |
new _1(); // prints "Hello!" | |
JavaCase theCase = JavaCase.of( | |
_1.class, | |
"className", "TailorMsg", | |
"message", "Tailored!" ); | |
//tailors java code, compile & create an instance | |
Object tailored = theCase.instance(); // "Tailored!" | |
System.out.println( | |
tailored.getClass().getName() ); // "ex.varcode.TailoredMsg" | |
} | |
/*-}*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment