Created
September 24, 2016 12:28
-
-
Save orekyuu/7d9f223200cd88801812a35ea89b641e to your computer and use it in GitHub Desktop.
FizzBuzz
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
import javax.xml.bind.DatatypeConverter; | |
import java.lang.reflect.Method; | |
class Main { | |
public static void main(String[] args) { | |
ClassLoader classLoader = new ClassLoader() { | |
private static final String src = "CAFEBABE0000003100270A0009001609001700180800190A001A001B08001C08001D0A001A001E07001907001F0100063C696E69743E010003282956010004436F646501000F4C696E654E756D6265725461626C650100124C6F63616C5661726961626C655461626C650100047468697301000A4C46697A7A42757A7A3B01000866697A7A42757A7A010001690100014901000A536F7572636546696C6501000D46697A7A42757A7A2E6A6176610C000A000B0700200C0021002201000846697A7A42757A7A0700230C0024002501000446697A7A01000442757A7A0C002400260100106A6176612F6C616E672F4F626A6563740100106A6176612F6C616E672F53797374656D0100036F75740100154C6A6176612F696F2F5072696E7453747265616D3B0100136A6176612F696F2F5072696E7453747265616D0100077072696E746C6E010015284C6A6176612F6C616E672F537472696E673B2956010004284929560021000800090000000000020001000A000B0001000C0000002F00010001000000052AB70001B100000002000D00000006000100000001000E0000000C000100000005000F0010000000010011000B0001000C000000A7000200020000004F043C1B1064A300491B06709A00141B08709A000EB200021203B60004A7002C1B06709A000EB200021205B60004A7001B1B08709A000EB200021206B60004A7000AB200021BB60007840101A7FFB7B100000002000D0000002A000A000000030008000400140005001F00060025000700300008003600090041000B00480003004E000E000E0000001600020002004C0012001300010000004F000F0010000000010014000000020015"; | |
{ | |
byte[] bytes = DatatypeConverter.parseHexBinary(src); | |
defineClass("FizzBuzz", bytes, 0, bytes.length); | |
} | |
}; | |
try { | |
Class<?> fizzBuzz = classLoader.loadClass("FizzBuzz"); | |
Object instance = fizzBuzz.getConstructor().newInstance(); | |
Method method = fizzBuzz.getDeclaredMethod("fizzBuzz"); | |
method.invoke(instance); | |
} catch (ReflectiveOperationException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment