fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.nio.*;
  7. import java.lang.reflect.*;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12.  
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. // your code goes here
  16. MyClass mc = new MyClass();
  17.  
  18. method_info mi_cnst = new method_info(
  19. method_info.ACC_PUBLIC,
  20. mc.addCP(new CONSTANT_Utf8_info("<init>")),
  21. mc.addCP(new CONSTANT_Utf8_info("()V")));
  22. mc.addMethod(mi_cnst);
  23. Code_attribute ca_cnst = new Code_attribute(mc);
  24. mi_cnst.add(ca_cnst);
  25. ca_cnst.addCode(0x2A); // aload_0
  26. ca_cnst.addCode(0xB7); // invokespecial
  27. ca_cnst.addCodeShort(
  28. mc.addCP(new CONSTANT_Methodref_info(
  29. mc, "java/lang/Object",
  30. "<init>", "()V")));
  31. ca_cnst.addCode(0xB1); // return
  32.  
  33. method_info mi_main = new method_info(
  34. method_info.ACC_PUBLIC | method_info.ACC_STATIC,
  35. mc.addCP(new CONSTANT_Utf8_info("main")),
  36. mc.addCP(new CONSTANT_Utf8_info("([Ljava/lang/String;)V")));
  37. mc.addMethod(mi_main);
  38. Code_attribute ca_main = new Code_attribute(mc);
  39. mi_main.add(ca_main);
  40. ca_main.max_stack = 2;
  41. ca_main.addCode(0xB2); // getstatic
  42. ca_main.addCodeShort(
  43. mc.addCP(new CONSTANT_Fieldref_info(
  44. mc, "java/lang/System",
  45. "out", "Ljava/io/PrintStream;")));
  46. ca_main.addCode(0x12); // ldc
  47. ca_main.addCode(
  48. mc.addCP(new CONSTANT_String_info(mc, "Hello World!")));
  49. ca_main.addCode(0xB6); // invokevirtual
  50. ca_main.addCodeShort(
  51. mc.addCP(new CONSTANT_Methodref_info(
  52. mc, "java/io/PrintStream",
  53. "println", "(Ljava/lang/String;)V")));
  54. ca_main.addCode(0xB1); // return
  55.  
  56.  
  57. // バイトコード生成!
  58. byte[] buf = mc.toBytes();
  59.  
  60.  
  61. // 生成したバイトコードを試すとこ!
  62. try {
  63. MyClassLoader loader = new MyClassLoader();
  64. Object hoge = loader.getHoge(buf).newInstance();
  65. Method[] mm = hoge.getClass().getMethods();
  66.  
  67. mm[0].invoke(null, new String[1]);
  68. String[] ss = new String[1];
  69. hoge.getClass().getMethod("main", ss.getClass()).invoke(null, ss);
  70.  
  71. } catch (Throwable e) {
  72. System.out.println("ロード失敗!!");
  73. System.out.println(e.toString());
  74. }
  75.  
  76. System.out.println("--生成したバイトコード--");
  77. for (int i = 0; i < buf.length; i++) {
  78. System.out.printf("%02X ", buf[i]);
  79. if ((i & 0x7) == 0x7) {
  80. System.out.print(" ");
  81. }
  82. if ((i & 0xF) == 0xF) {
  83. System.out.println();
  84. }
  85.  
  86. }
  87.  
  88. System.out.println();
  89. System.out.println("--Constant pool--");
  90. int c = 1;
  91. for (Iterator<cp_info> i = mc.constant_pool.iterator()
  92. ; i.hasNext(); c++) {
  93. System.out.println(c + ":: " + i.next().toString());
  94. }
  95.  
  96. }
  97.  
  98. static class MyClassLoader extends ClassLoader {
  99. MyClassLoader() {}
  100. public Class<?> getHoge(byte[] b) {
  101. // return defineClass(b, 0, b.length);
  102. return defineClass("Hoge", b, 0, b.length);
  103. }
  104. }
  105.  
  106.  
  107. static class MyClass {
  108. public static final int ACC_PUBLIC = 0x01;
  109. public static final int ACC_SUPER = 0x20;
  110.  
  111. byte[] magic;
  112. int minor_version;
  113. int major_version;
  114. ArrayList<cp_info> constant_pool;
  115. int access_flags;
  116. int this_class;
  117. int super_class;
  118. int interfaces_count;
  119. IntBuffer interfaces;
  120. ArrayList<field_info> fields;
  121. ArrayList<method_info> methods;
  122. ArrayList<attribute_info> attributes;
  123. {
  124. magic = new byte[4];
  125. magic[0] = (byte)0xCA;
  126. magic[1] = (byte)0xFE;
  127. magic[2] = (byte)0xBA;
  128. magic[3] = (byte)0xBE;
  129.  
  130. access_flags = ACC_PUBLIC | ACC_SUPER;
  131.  
  132. minor_version = 0;
  133. major_version = 0x31;
  134.  
  135. constant_pool = new ArrayList<cp_info>();
  136. interfaces_count = 0;
  137. interfaces = IntBuffer.allocate(5);
  138. fields = null;
  139. methods = null;
  140. attributes = null;
  141. }
  142.  
  143. MyClass() {
  144. this_class = addCP(
  145. new CONSTANT_Class_info(this, "Hoge"));
  146. super_class = addCP(
  147. new CONSTANT_Class_info(this, "java/lang/Object"));
  148. /*
  149. addAttribute(
  150. new SourceFile_attribute(this, "Hoge.java"));
  151. */
  152. }
  153.  
  154. int addCP(cp_info cp) {
  155. int i = constant_pool.indexOf(cp);
  156. if (i < 0) {
  157. constant_pool.add(cp);
  158. return constant_pool.size();
  159. }
  160. return i + 1;
  161. }
  162.  
  163. void addMethod(method_info mt) {
  164. if (methods == null) {
  165. methods = new ArrayList<method_info>();
  166. }
  167. methods.add(mt);
  168. }
  169.  
  170. void addAttribute(attribute_info ab) {
  171. if (attributes == null) {
  172. attributes = new ArrayList<attribute_info>();
  173. }
  174. attributes.add(ab);
  175. }
  176.  
  177. byte[] toBytes() throws IOException {
  178. DataOutputStream out = null;
  179. try {
  180. buf = new ByteArrayOutputStream();
  181. out = new DataOutputStream(buf);
  182. out.write(magic, 0, magic.length);
  183. out.writeShort(minor_version);
  184. out.writeShort(major_version);
  185. out.writeShort(constant_pool.size() + 1);
  186. for (Iterator<cp_info> i = constant_pool.iterator()
  187. ; i.hasNext(); ) {
  188. i.next().write(out);
  189. }
  190. out.writeShort(access_flags);
  191. out.writeShort(this_class);
  192. out.writeShort(super_class);
  193.  
  194. out.writeShort(interfaces_count);
  195. for (int i = 0; i < interfaces_count; i++) {
  196. out.writeShort(interfaces.get(i));
  197. }
  198.  
  199. if (fields == null) {
  200. out.writeShort(0);
  201. } else {
  202. out.writeShort(fields.size());
  203. for (Iterator<field_info> i = fields.iterator()
  204. ; i.hasNext(); ) {
  205. i.next().write(out);
  206. }
  207. }
  208.  
  209. if (methods == null) {
  210. out.writeShort(0);
  211. } else {
  212. out.writeShort(methods.size());
  213. for (Iterator<method_info> i = methods.iterator()
  214. ; i.hasNext(); ) {
  215. i.next().write(out);
  216. }
  217. }
  218.  
  219. if (attributes == null) {
  220. out.writeShort(0);
  221. } else {
  222. out.writeShort(attributes.size());
  223. for (Iterator<attribute_info> i = attributes.iterator()
  224. ; i.hasNext(); ) {
  225. i.next().write(out);
  226. }
  227. }
  228.  
  229. return buf.toByteArray();
  230. } finally {
  231. if (out != null) out.close();
  232. if (buf != null) buf.close();
  233. }
  234. }
  235. }
  236.  
  237. static interface Icp_info {
  238. byte CONSTANT_Class = 7;
  239. byte CONSTANT_Fieldref = 9;
  240. byte CONSTANT_Methodref = 10;
  241. byte CONSTANT_InterfaceMethodref = 11;
  242. byte CONSTANT_String = 8;
  243. byte CONSTANT_Integer = 3;
  244. byte CONSTANT_Float = 4;
  245. byte CONSTANT_Long = 5;
  246. byte CONSTANT_Double = 6;
  247. byte CONSTANT_NameAndType = 12;
  248. byte CONSTANT_Utf8 = 1;
  249. void write(DataOutputStream out) throws IOException;
  250. }
  251.  
  252. static abstract class cp_info implements Icp_info {
  253. public final byte tag;
  254. protected cp_info(byte tag) { this.tag = tag; }
  255. }
  256.  
  257. static class CONSTANT_Class_info extends cp_info {
  258. public final int name_index;
  259. CONSTANT_Class_info(int i) { super(CONSTANT_Class); name_index = i; }
  260. CONSTANT_Class_info(MyClass mc, String c) {
  261. super(CONSTANT_Class);
  262. name_index = mc.addCP(new CONSTANT_Utf8_info(c));
  263. }
  264. public void write(DataOutputStream out) throws IOException {
  265. out.writeByte(tag);
  266. out.writeShort(name_index);
  267. }
  268. public boolean equals(Object obj) {
  269. if (obj == null) return false; if (this == obj) return true;
  270. if (!(obj instanceof CONSTANT_Class_info)) return false;
  271. CONSTANT_Class_info v = (CONSTANT_Class_info)obj;
  272. return name_index == v.name_index;
  273. }
  274. public String toString() {
  275. return "Class " + name_index;
  276. }
  277. }
  278. static class CONSTANT_ref_info extends cp_info {
  279. public final int class_index;
  280. public final int name_and_type_index;
  281. protected CONSTANT_ref_info(byte tag, int a, int b) { super(tag);
  282. class_index = a; name_and_type_index = b;}
  283. CONSTANT_ref_info(byte t, MyClass mc, String c, String m, String d) {
  284. this(t
  285. , mc.addCP(new CONSTANT_Class_info(mc, c))
  286. , mc.addCP(new CONSTANT_NameAndType_info(mc, m, d)));
  287. }
  288. public void write(DataOutputStream out) throws IOException {
  289. out.writeByte(tag);
  290. out.writeShort(class_index);
  291. out.writeShort(name_and_type_index);
  292. }
  293. public boolean equals(Object obj) {
  294. if (obj == null) return false; if (this == obj) return true;
  295. if (!(obj instanceof CONSTANT_ref_info)) return false;
  296. CONSTANT_ref_info v = (CONSTANT_ref_info)obj;
  297. return (class_index == v.class_index) &&
  298. (name_and_type_index == v.name_and_type_index);
  299. }
  300. public String toString() {
  301. return "c:" + class_index + " nat:" + name_and_type_index;
  302. }
  303. }
  304. static class CONSTANT_Fieldref_info extends CONSTANT_ref_info {
  305. CONSTANT_Fieldref_info(int a, int b) { super(CONSTANT_Fieldref,a,b); }
  306. CONSTANT_Fieldref_info(MyClass mc, String c, String m, String d) {
  307. super(CONSTANT_Fieldref, mc, c, m, d);
  308. }
  309. public String toString() {
  310. return "Field " + super.toString();
  311. }
  312. }
  313. static class CONSTANT_Methodref_info extends CONSTANT_ref_info {
  314. CONSTANT_Methodref_info(int a, int b) { super(CONSTANT_Methodref,a,b); }
  315. CONSTANT_Methodref_info(MyClass mc, String c, String m, String d) {
  316. super(CONSTANT_Methodref, mc, c, m, d);
  317. }
  318. public String toString() {
  319. return "Method " + super.toString();
  320. }
  321. }
  322. static class CONSTANT_InterfaceMethodref_info extends CONSTANT_ref_info {
  323. CONSTANT_InterfaceMethodref_info(int a, int b) { super(CONSTANT_InterfaceMethodref,a,b); }
  324. }
  325. static class CONSTANT_String_info extends cp_info {
  326. public final int string_index;
  327. CONSTANT_String_info(int i) { super(CONSTANT_String); string_index = i; }
  328. CONSTANT_String_info(MyClass mc, String s) {
  329. super(CONSTANT_String);
  330. string_index = mc.addCP(new CONSTANT_Utf8_info(s));
  331. }
  332. public void write(DataOutputStream out) throws IOException {
  333. out.writeByte(tag);
  334. out.writeShort(string_index);
  335. }
  336. public boolean equals(Object obj) {
  337. if (obj == null) return false; if (this == obj) return true;
  338. if (!(obj instanceof CONSTANT_String_info)) return false;
  339. CONSTANT_String_info v = (CONSTANT_String_info)obj;
  340. return string_index == v.string_index;
  341. }
  342. public String toString() {
  343. return "String " + string_index;
  344. }
  345. }
  346. static class CONSTANT_Integer_info extends cp_info {
  347. public final int bytes;
  348. CONSTANT_Integer_info(int v) { super(CONSTANT_Integer); bytes = v; }
  349. public void write(DataOutputStream out) throws IOException {
  350. out.writeByte(tag);
  351. out.writeInt(bytes);
  352. }
  353. public boolean equals(Object obj) {
  354. if (obj == null) return false; if (this == obj) return true;
  355. if (!(obj instanceof CONSTANT_Integer_info)) return false;
  356. CONSTANT_Integer_info v = (CONSTANT_Integer_info)obj;
  357. return bytes == v.bytes;
  358. }
  359. }
  360. static class CONSTANT_Float_info extends cp_info {
  361. public final float bytes;
  362. CONSTANT_Float_info(float v) { super(CONSTANT_Float); bytes = v; }
  363. public void write(DataOutputStream out) throws IOException {
  364. out.writeByte(tag);
  365. out.writeFloat(bytes);
  366. }
  367. public boolean equals(Object obj) {
  368. if (obj == null) return false; if (this == obj) return true;
  369. if (!(obj instanceof CONSTANT_Float_info)) return false;
  370. CONSTANT_Float_info v = (CONSTANT_Float_info)obj;
  371. return bytes == v.bytes;
  372. }
  373. }
  374. static class CONSTANT_Long_info extends cp_info {
  375. public final long bytes;
  376. CONSTANT_Long_info(long v) { super(CONSTANT_Long); bytes = v; }
  377. public void write(DataOutputStream out) throws IOException {
  378. out.writeByte(tag);
  379. out.writeLong(bytes);
  380. }
  381. public boolean equals(Object obj) {
  382. if (obj == null) return false; if (this == obj) return true;
  383. if (!(obj instanceof CONSTANT_Long_info)) return false;
  384. CONSTANT_Long_info v = (CONSTANT_Long_info)obj;
  385. return bytes == v.bytes;
  386. }
  387. }
  388. static class CONSTANT_Double_info extends cp_info {
  389. public final double bytes;
  390. CONSTANT_Double_info(double d) { super(CONSTANT_Double); bytes = d; }
  391. public void write(DataOutputStream out) throws IOException {
  392. out.writeByte(tag);
  393. out.writeDouble(bytes);
  394. }
  395. public boolean equals(Object obj) {
  396. if (obj == null) return false; if (this == obj) return true;
  397. if (!(obj instanceof CONSTANT_Double_info)) return false;
  398. CONSTANT_Double_info v = (CONSTANT_Double_info)obj;
  399. return bytes == v.bytes;
  400. }
  401. }
  402. static class CONSTANT_NameAndType_info extends cp_info {
  403. public int name_index = 0;
  404. public int descriptor_index = 0;
  405. CONSTANT_NameAndType_info(int n, int d) {
  406. super(CONSTANT_NameAndType); name_index = n; descriptor_index=d; }
  407. CONSTANT_NameAndType_info(MyClass mc, String n, String d) {
  408. super(CONSTANT_NameAndType);
  409. name_index = mc.addCP(new CONSTANT_Utf8_info(n));
  410. descriptor_index = mc.addCP(new CONSTANT_Utf8_info(d));
  411. }
  412. public void write(DataOutputStream out) throws IOException {
  413. out.writeByte(tag);
  414. out.writeShort(name_index);
  415. out.writeShort(descriptor_index);
  416. }
  417. public boolean equals(Object obj) {
  418. if (obj == null) return false; if (this == obj) return true;
  419. if (!(obj instanceof CONSTANT_NameAndType_info)) return false;
  420. CONSTANT_NameAndType_info v = (CONSTANT_NameAndType_info)obj;
  421. return (name_index == v.name_index) &&
  422. (descriptor_index == v.descriptor_index);
  423. }
  424. public String toString() {
  425. return "NameAndType n:" + name_index + " d:" + descriptor_index;
  426. }
  427. }
  428. static class CONSTANT_Utf8_info extends cp_info {
  429. public final String bytes;
  430. CONSTANT_Utf8_info(String str) { super(CONSTANT_Utf8); bytes = str; }
  431. public void write(DataOutputStream out) throws IOException {
  432. out.writeByte(tag);
  433. out.writeShort(bytes.length());
  434. byte[] b = bytes.getBytes();
  435. out.write(b, 0, b.length);
  436. }
  437. public boolean equals(Object obj) {
  438. if (obj == null) return false; if (this == obj) return true;
  439. if (!(obj instanceof CONSTANT_Utf8_info)) return false;
  440. CONSTANT_Utf8_info v = (CONSTANT_Utf8_info)obj;
  441. if (bytes == null) return v.bytes == null;
  442. return bytes.equals(v.bytes);
  443. }
  444. public String toString() {
  445. return "\"" + bytes + "\"";
  446. }
  447. }
  448.  
  449. static abstract class attribute_info {
  450. public final int attribute_name_index;
  451. protected attribute_info(int i) { attribute_name_index = i; }
  452. public abstract void write(DataOutputStream out) throws IOException;
  453. }
  454.  
  455. static class exception_info {
  456. public int start_pc = 0;
  457. public int end_pc = 0;
  458. public int handler_pc = 0;
  459. public int catch_type = 0;
  460. public void write(DataOutputStream out) throws IOException {
  461. out.writeShort(start_pc);
  462. out.writeShort(end_pc);
  463. out.writeShort(handler_pc);
  464. out.writeShort(catch_type);
  465. }
  466.  
  467. }
  468.  
  469. static class SourceFile_attribute extends attribute_info {
  470. public final int sourcefile_index;
  471. SourceFile_attribute(MyClass mc, String s) {
  472. super(mc.addCP(new CONSTANT_Utf8_info("SourceFile")));
  473. sourcefile_index = mc.addCP(
  474. new CONSTANT_Utf8_info(s));
  475. }
  476. public void write(DataOutputStream out) throws IOException {
  477. out.writeShort(attribute_name_index);
  478. out.writeInt(2);
  479. out.writeShort(sourcefile_index);
  480. }
  481. }
  482.  
  483.  
  484. static class Code_attribute extends attribute_info {
  485. public int max_stack = 1;
  486. public int max_locals = 1;
  487. public ByteArrayOutputStream code = null;;
  488. public DataOutputStream data = null;
  489. public ArrayList<exception_info> exception_table = null;
  490. public ArrayList<attribute_info> attributes = null;
  491. Code_attribute(MyClass mc) {
  492. super(mc.addCP(new CONSTANT_Utf8_info("Code")));
  493. code = new ByteArrayOutputStream();
  494. data = new DataOutputStream(code);
  495. }
  496. public void addCode(int c) throws IOException {
  497. data.write(c);
  498. }
  499. public void addCodeShort(int c) throws IOException {
  500. data.writeShort(c);
  501. }
  502. public void write(DataOutputStream out) throws IOException {
  503. out.writeShort(attribute_name_index);
  504. DataOutputStream tmp = null;
  505. try {
  506. buf = new ByteArrayOutputStream();
  507. tmp = new DataOutputStream(buf);
  508. tmp.writeShort(max_stack);
  509. tmp.writeShort(max_locals);
  510. tmp.writeInt(code.size());
  511. tmp.write(code.toByteArray(), 0, code.size());
  512. if (exception_table == null) {
  513. tmp.writeShort(0);
  514. } else {
  515. tmp.writeShort(exception_table.size());
  516. for (Iterator<exception_info>
  517. i = exception_table.iterator()
  518. ; i.hasNext(); ) {
  519. i.next().write(tmp);
  520. }
  521. }
  522. if (attributes == null) {
  523. tmp.writeShort(0);
  524. } else {
  525. tmp.writeShort(attributes.size());
  526. for (Iterator<attribute_info>
  527. i = attributes.iterator()
  528. ; i.hasNext(); ) {
  529. i.next().write(tmp);
  530. }
  531. }
  532. byte[] b = buf.toByteArray();
  533. out.writeInt(b.length);
  534. out.write(b, 0, b.length);
  535. } finally {
  536. if (tmp != null) tmp.close();
  537. if (buf != null) buf.close();
  538. }
  539. }
  540. }
  541.  
  542. static abstract class member_info {
  543. public int access_flags;
  544. public int name_index;
  545. public int descriptor_index;
  546. public ArrayList<attribute_info> attributes = null;
  547. protected member_info(int ac, int n, int d) {
  548. access_flags = ac;
  549. name_index = n;
  550. descriptor_index = d;
  551. }
  552. public void add(attribute_info a) {
  553. if (attributes == null) {
  554. attributes = new ArrayList<attribute_info>();
  555. }
  556. attributes.add(a);
  557. }
  558. public void write(DataOutputStream out) throws IOException {
  559. out.writeShort(access_flags);
  560. out.writeShort(name_index);
  561. out.writeShort(descriptor_index);
  562. if (attributes == null) {
  563. out.writeShort(0);
  564. } else {
  565. out.writeShort(attributes.size());
  566. for (Iterator<attribute_info> i = attributes.iterator()
  567. ; i.hasNext(); ) {
  568. i.next().write(out);
  569. }
  570. }
  571. }
  572. }
  573.  
  574. static class field_info extends member_info {
  575. public static final int ACC_PUBLIC = 0x01;
  576. public static final int ACC_PRIVATE = 0x02;
  577. public static final int ACC_PROTECTED = 0x04;
  578. public static final int ACC_STATIC = 0x08;
  579. public static final int ACC_FINAL = 0x10;
  580. field_info(int ac, int n, int d) { super(ac, n, d); }
  581. }
  582.  
  583. static class method_info extends member_info {
  584. public static final int ACC_PUBLIC = 0x01;
  585. public static final int ACC_PRIVATE = 0x02;
  586. public static final int ACC_PROTECTED = 0x04;
  587. public static final int ACC_STATIC = 0x08;
  588. public static final int ACC_FINAL = 0x10;
  589. method_info(int ac, int n, int d) { super(ac,n,d); }
  590. }
  591. }
Success #stdin #stdout 0.13s 380544KB
stdin
Standard input is empty
stdout
Hello World!
Hello World!
--生成したバイトコード--
CA FE BA BE 00 00 00 31  00 1A 01 00 04 48 6F 67  
65 07 00 01 01 00 10 6A  61 76 61 2F 6C 61 6E 67  
2F 4F 62 6A 65 63 74 07  00 03 01 00 06 3C 69 6E  
69 74 3E 01 00 03 28 29  56 01 00 04 43 6F 64 65  
0C 00 05 00 06 0A 00 04  00 08 01 00 04 6D 61 69  
6E 01 00 16 28 5B 4C 6A  61 76 61 2F 6C 61 6E 67  
2F 53 74 72 69 6E 67 3B  29 56 01 00 10 6A 61 76  
61 2F 6C 61 6E 67 2F 53  79 73 74 65 6D 07 00 0C  
01 00 03 6F 75 74 01 00  15 4C 6A 61 76 61 2F 69  
6F 2F 50 72 69 6E 74 53  74 72 65 61 6D 3B 0C 00  
0E 00 0F 09 00 0D 00 10  01 00 0C 48 65 6C 6C 6F  
20 57 6F 72 6C 64 21 08  00 12 01 00 13 6A 61 76  
61 2F 69 6F 2F 50 72 69  6E 74 53 74 72 65 61 6D  
07 00 14 01 00 07 70 72  69 6E 74 6C 6E 01 00 15  
28 4C 6A 61 76 61 2F 6C  61 6E 67 2F 53 74 72 69  
6E 67 3B 29 56 0C 00 16  00 17 0A 00 15 00 18 00  
21 00 02 00 04 00 00 00  00 00 02 00 01 00 05 00  
06 00 01 00 07 00 00 00  11 00 01 00 01 00 00 00  
05 2A B7 00 09 B1 00 00  00 00 00 09 00 0A 00 0B  
00 01 00 07 00 00 00 15  00 02 00 01 00 00 00 09  
B2 00 11 12 13 B6 00 19  B1 00 00 00 00 00 00 
--Constant pool--
1:: "Hoge"
2:: Class 1
3:: "java/lang/Object"
4:: Class 3
5:: "<init>"
6:: "()V"
7:: "Code"
8:: NameAndType n:5 d:6
9:: Method c:4 nat:8
10:: "main"
11:: "([Ljava/lang/String;)V"
12:: "java/lang/System"
13:: Class 12
14:: "out"
15:: "Ljava/io/PrintStream;"
16:: NameAndType n:14 d:15
17:: Field c:13 nat:16
18:: "Hello World!"
19:: String 18
20:: "java/io/PrintStream"
21:: Class 20
22:: "println"
23:: "(Ljava/lang/String;)V"
24:: NameAndType n:22 d:23
25:: Method c:21 nat:24