1 package org.enhydra.xml.xmlc.deferredparsing; 2 3 4 5 import org.apache.bcel.Constants; 6 import org.apache.bcel.classfile.JavaClass; 7 import org.apache.bcel.generic.BranchInstruction; 8 import org.apache.bcel.generic.ClassGen; 9 import org.apache.bcel.generic.ConstantPoolGen; 10 import org.apache.bcel.generic.FieldGen; 11 import org.apache.bcel.generic.INSTANCEOF; 12 import org.apache.bcel.generic.InstructionConstants; 13 import org.apache.bcel.generic.InstructionFactory; 14 import org.apache.bcel.generic.InstructionHandle; 15 import org.apache.bcel.generic.InstructionList; 16 import org.apache.bcel.generic.MethodGen; 17 import org.apache.bcel.generic.ObjectType; 18 import org.apache.bcel.generic.PUSH; 19 import org.apache.bcel.generic.Type; 20 21 22 23 public class DynamicMLCreator implements Constants { 24 25 private String className; 26 27 private String sourcePath; 28 29 private InstructionFactory _factory; 30 31 private ConstantPoolGen _cp; 32 33 private ClassGen _cg; 34 35 private String _impl; 36 37 38 39 public DynamicMLCreator(String name, String path) { 40 41 className = name; 42 43 sourcePath = path; 44 45 46 47 String type = (path.endsWith(".html") || path.endsWith(".htm") || path.endsWith(".xhtml") || path.endsWith(".chtml")) ? "html" : "xml"; 48 49 if (type.equals("html")) { 50 51 53 55 57 _impl = "org.enhydra.xml.xmlc.html.HTMLObjectImpl"; 58 59 _cg = new ClassGen(className, 60 61 _impl, 62 63 "<generated>", 64 65 ACC_PUBLIC | ACC_SUPER, 66 67 new String [] { "org.enhydra.xml.xmlc.XMLObject", 68 69 "org.enhydra.xml.xmlc.html.HTMLObject" }); 70 71 } else { 72 73 _impl = "org.enhydra.xml.xmlc.XMLObjectImpl"; 74 75 _cg = new ClassGen(className, 76 77 _impl, 78 79 "<generated>", 80 81 ACC_PUBLIC | ACC_SUPER, 82 83 new String [] { "org.enhydra.xml.xmlc.XMLObject" }); 84 85 } 86 87 88 89 _cp = _cg.getConstantPool(); 90 91 _factory = new InstructionFactory(_cg, _cp); 92 93 } 94 95 96 97 public JavaClass create() { 98 99 createFields(); 100 101 createMethod_0(); 102 103 createMethod_1(); 104 105 createMethod_2(); 106 107 createMethod_3(); 108 109 createMethod_4(); 110 111 createMethod_5(); 112 113 createMethod_6(); 114 115 createMethod_7(); 116 117 createMethod_8(); 118 119 createMethod_9(); 120 121 createMethod_10(); 122 123 125 return _cg.getJavaClass(); 126 127 } 128 129 130 131 private void createFields() { 132 133 FieldGen field; 134 135 136 137 field = new FieldGen(ACC_PUBLIC | ACC_STATIC | ACC_FINAL, new ObjectType("java.lang.Class"), "XMLC_GENERATED_CLASS", _cp); 138 139 _cg.addField(field.getField()); 140 141 142 143 field = new FieldGen(ACC_PUBLIC | ACC_STATIC | ACC_FINAL, Type.STRING, "XMLC_SOURCE_FILE", _cp); 144 145 field.setInitValue(sourcePath); 146 147 _cg.addField(field.getField()); 148 149 150 151 field = new FieldGen(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, new ObjectType("org.enhydra.xml.xmlc.dom.XMLCDomFactory"), "fDOMFactory", _cp); 152 153 _cg.addField(field.getField()); 154 155 156 157 field = new FieldGen(ACC_PRIVATE | ACC_FINAL, new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), "fDocumentLoader", _cp); 158 159 _cg.addField(field.getField()); 160 161 162 163 field = new FieldGen(ACC_PRIVATE | ACC_STATIC, new ObjectType("java.lang.Class"), "class$L" + className.replace('.', '$'), _cp); 164 165 _cg.addField(field.getField()); 166 167 168 169 172 173 } 174 175 176 177 private void createMethod_0() { 178 179 InstructionList il = new InstructionList(); 180 181 MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String [] { }, 182 183 "buildDocument", 184 185 className, 186 187 il, _cp); 188 189 190 191 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 192 193 il.append(_factory.createLoad(Type.OBJECT, 0)); 194 195 il.append(_factory.createInvoke(className, 196 197 "getDocumentLoader", 198 199 new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 200 201 il.append(_factory.createLoad(Type.OBJECT, 0)); 202 203 il.append(_factory.createInvoke("java.lang.Object", "getClass", new ObjectType("java.lang.Class"), Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 204 205 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader", "getDocument", new ObjectType("org.w3c.dom.Document"), new Type[] { new ObjectType("java.lang.Class") }, Constants.INVOKEINTERFACE)); 206 207 il.append(new PUSH(_cp, "text/html")); 208 209 il.append(new PUSH(_cp, "UTF-8")); 210 211 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "setDocument", Type.VOID, new Type[] { new ObjectType("org.w3c.dom.Document"), Type.STRING, Type.STRING }, Constants.INVOKEVIRTUAL)); 212 213 InstructionHandle ih_21 = il.append(_factory.createLoad(Type.OBJECT, 0)); 214 215 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "syncAccessMethods", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 216 217 InstructionHandle ih_25 = il.append(_factory.createReturn(Type.VOID)); 218 219 method.setMaxStack(); 220 221 method.setMaxLocals(); 222 223 _cg.addMethod(method.getMethod()); 224 225 il.dispose(); 226 227 } 228 229 230 231 private void createMethod_1() { 232 233 InstructionList il = new InstructionList(); 234 235 MethodGen method = new MethodGen(ACC_PUBLIC, 236 237 new ObjectType("org.w3c.dom.Node"), 238 239 new Type[] { Type.BOOLEAN }, 240 241 new String [] { "arg0" }, 242 243 "cloneNode", 244 245 className, 246 247 il, _cp); 248 249 250 251 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 252 253 il.append(_factory.createLoad(Type.INT, 1)); 254 255 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "cloneDeepCheck", Type.VOID, new Type[] { Type.BOOLEAN }, Constants.INVOKEVIRTUAL)); 256 257 InstructionHandle ih_5 = il.append(_factory.createNew(className)); 258 259 il.append(InstructionConstants.DUP); 260 261 il.append(_factory.createLoad(Type.OBJECT, 0)); 262 263 il.append(_factory.createInvoke(className, 264 265 "<init>", 266 267 Type.VOID, 268 269 new Type[] { new ObjectType(className) }, 270 271 Constants.INVOKESPECIAL)); 272 273 InstructionHandle ih_13 = il.append(_factory.createReturn(Type.OBJECT)); 274 275 method.setMaxStack(); 276 277 method.setMaxLocals(); 278 279 _cg.addMethod(method.getMethod()); 280 281 il.dispose(); 282 283 } 284 285 286 287 private void createMethod_2() { 288 289 InstructionList il = new InstructionList(); 290 291 MethodGen method = new MethodGen(ACC_PROTECTED | ACC_FINAL, new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.NO_ARGS, new String [] { }, "getDocumentLoader", className, il, _cp); 292 293 294 295 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 296 297 il.append(_factory.createFieldAccess(className, "fDocumentLoader", new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Constants.GETFIELD)); 298 299 InstructionHandle ih_4 = il.append(_factory.createReturn(Type.OBJECT)); 300 301 method.setMaxStack(); 302 303 method.setMaxLocals(); 304 305 _cg.addMethod(method.getMethod()); 306 307 il.dispose(); 308 309 } 310 311 312 313 private void createMethod_3() { 314 315 InstructionList il = new InstructionList(); 316 317 MethodGen method = new MethodGen(ACC_PROTECTED | ACC_FINAL, new ObjectType("org.enhydra.xml.xmlc.dom.XMLCDomFactory"), Type.NO_ARGS, new String [] { }, "getDomFactory", className, il, _cp); 318 319 320 321 InstructionHandle ih_0 = il.append(_factory.createFieldAccess(className, "fDOMFactory", new ObjectType("org.enhydra.xml.xmlc.dom.XMLCDomFactory"), Constants.GETSTATIC)); 322 323 InstructionHandle ih_3 = il.append(_factory.createReturn(Type.OBJECT)); 324 325 method.setMaxStack(); 326 327 method.setMaxLocals(); 328 329 _cg.addMethod(method.getMethod()); 330 331 il.dispose(); 332 333 } 334 335 336 337 private void createMethod_4() { 338 339 InstructionList il = new InstructionList(); 340 341 MethodGen method = new MethodGen(ACC_PROTECTED, Type.VOID, new Type[] { new ObjectType("org.w3c.dom.Node") }, new String [] { "arg0" }, "syncWithDocument", className, il, _cp); 342 343 344 345 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1)); 346 347 il.append(new INSTANCEOF(_cp.addClass(new ObjectType("org.w3c.dom.Element")))); 348 349 BranchInstruction ifeq_4 = _factory.createBranchInstruction(Constants.IFEQ, null); 350 351 il.append(ifeq_4); 352 353 InstructionHandle ih_7 = il.append(_factory.createLoad(Type.OBJECT, 1)); 354 355 il.append(_factory.createCheckCast(new ObjectType("org.w3c.dom.Element"))); 356 357 il.append(new PUSH(_cp, "id")); 358 359 il.append(_factory.createInvoke("org.w3c.dom.Element", "getAttribute", Type.STRING, new Type[] { Type.STRING }, Constants.INVOKEINTERFACE)); 360 361 il.append(_factory.createStore(Type.OBJECT, 2)); 362 363 InstructionHandle ih_19 = il.append(_factory.createLoad(Type.OBJECT, 2)); 364 365 il.append(_factory.createInvoke("java.lang.String", "length", Type.INT, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 366 367 BranchInstruction ifne_23 = _factory.createBranchInstruction(Constants.IFNE, null); 368 369 il.append(ifne_23); 370 371 InstructionHandle ih_26 = il.append(_factory.createLoad(Type.OBJECT, 1)); 372 373 il.append(_factory.createInvoke("org.w3c.dom.Node", "getFirstChild", new ObjectType("org.w3c.dom.Node"), Type.NO_ARGS, Constants.INVOKEINTERFACE)); 374 375 il.append(_factory.createStore(Type.OBJECT, 2)); 376 377 InstructionHandle ih_33; 378 379 BranchInstruction goto_33 = _factory.createBranchInstruction(Constants.GOTO, null); 380 381 ih_33 = il.append(goto_33); 382 383 InstructionHandle ih_36 = il.append(_factory.createLoad(Type.OBJECT, 0)); 384 385 il.append(_factory.createLoad(Type.OBJECT, 2)); 386 387 il.append(_factory.createInvoke(className, "syncWithDocument", Type.VOID, new Type[] { new ObjectType("org.w3c.dom.Node") }, Constants.INVOKEVIRTUAL)); 388 389 InstructionHandle ih_41 = il.append(_factory.createLoad(Type.OBJECT, 2)); 390 391 il.append(_factory.createInvoke("org.w3c.dom.Node", "getNextSibling", new ObjectType("org.w3c.dom.Node"), Type.NO_ARGS, Constants.INVOKEINTERFACE)); 392 393 il.append(_factory.createStore(Type.OBJECT, 2)); 394 395 InstructionHandle ih_48 = il.append(_factory.createLoad(Type.OBJECT, 2)); 396 397 BranchInstruction ifnonnull_49 = _factory.createBranchInstruction(Constants.IFNONNULL, ih_36); 398 399 il.append(ifnonnull_49); 400 401 InstructionHandle ih_52 = il.append(_factory.createReturn(Type.VOID)); 402 403 ifeq_4.setTarget(ih_26); 404 405 ifne_23.setTarget(ih_26); 406 407 goto_33.setTarget(ih_48); 408 409 method.setMaxStack(); 410 411 method.setMaxLocals(); 412 413 _cg.addMethod(method.getMethod()); 414 415 il.dispose(); 416 417 } 418 419 420 421 private void createMethod_5() { 422 423 InstructionList il = new InstructionList(); 424 425 MethodGen method = new MethodGen(ACC_STATIC, new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, new String [] { "arg0" }, "class$", className, il, _cp); 426 427 428 429 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 430 431 il.append(_factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, Constants.INVOKESTATIC)); 432 433 InstructionHandle ih_4 = il.append(_factory.createReturn(Type.OBJECT)); 434 435 InstructionHandle ih_5 = il.append(_factory.createStore(Type.OBJECT, 1)); 436 437 il.append(_factory.createNew("java.lang.NoClassDefFoundError")); 438 439 il.append(InstructionConstants.DUP); 440 441 il.append(_factory.createLoad(Type.OBJECT, 1)); 442 443 il.append(_factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 444 445 il.append(_factory.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKESPECIAL)); 446 447 InstructionHandle ih_17 = il.append(InstructionConstants.ATHROW); 448 449 method.addExceptionHandler(ih_0, ih_4, ih_5, new ObjectType("java.lang.ClassNotFoundException")); 450 451 method.setMaxStack(); 452 453 method.setMaxLocals(); 454 455 _cg.addMethod(method.getMethod()); 456 457 il.dispose(); 458 459 } 460 461 462 463 private void createMethod_6() { 464 465 InstructionList il = new InstructionList(); 466 467 MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String [] { }, "<init>", className, il, _cp); 468 469 470 471 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 472 473 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.deferredparsing.StandardDocumentLoader", "getInstance", new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.NO_ARGS, Constants.INVOKESTATIC)); 474 475 il.append(_factory.createInvoke(className, "<init>", Type.VOID, new Type[] { new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader") }, Constants.INVOKESPECIAL)); 476 477 InstructionHandle ih_7 = il.append(_factory.createLoad(Type.OBJECT, 0)); 478 479 il.append(_factory.createInvoke(className, "buildDocument", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 480 481 InstructionHandle ih_11 = il.append(_factory.createReturn(Type.VOID)); 482 483 method.setMaxStack(); 484 485 method.setMaxLocals(); 486 487 _cg.addMethod(method.getMethod()); 488 489 il.dispose(); 490 491 } 492 493 494 495 private void createMethod_7() { 496 497 InstructionList il = new InstructionList(); 498 499 MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { Type.BOOLEAN }, new String [] { "arg0" }, "<init>", className, il, _cp); 500 501 502 503 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 504 505 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.deferredparsing.StandardDocumentLoader", "getInstance", new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.NO_ARGS, Constants.INVOKESTATIC)); 506 507 il.append(_factory.createLoad(Type.INT, 1)); 508 509 il.append(_factory.createInvoke(className, "<init>", Type.VOID, new Type[] { new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.BOOLEAN }, Constants.INVOKESPECIAL)); 510 511 InstructionHandle ih_8 = il.append(_factory.createReturn(Type.VOID)); 512 513 method.setMaxStack(); 514 515 method.setMaxLocals(); 516 517 _cg.addMethod(method.getMethod()); 518 519 il.dispose(); 520 521 } 522 523 524 525 private void createMethod_8() { 526 527 InstructionList il = new InstructionList(); 528 529 MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { new ObjectType(className) }, new String [] { "arg0" }, "<init>", className, il, _cp); 530 531 532 533 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 534 535 il.append(_factory.createInvoke(_impl, "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); 536 537 InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0)); 538 539 il.append(_factory.createLoad(Type.OBJECT, 1)); 540 541 il.append(_factory.createInvoke(className, "getDocumentLoader", new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 542 543 il.append(_factory.createFieldAccess(className, "fDocumentLoader", new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Constants.PUTFIELD)); 544 545 InstructionHandle ih_12 = il.append(_factory.createLoad(Type.OBJECT, 0)); 546 547 il.append(_factory.createLoad(Type.OBJECT, 1)); 548 549 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "getDocument", new ObjectType("org.w3c.dom.Document"), Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 550 551 il.append(new PUSH(_cp, 1)); 552 553 il.append(_factory.createInvoke("org.w3c.dom.Node", "cloneNode", new ObjectType("org.w3c.dom.Node"), new Type[] { Type.BOOLEAN }, Constants.INVOKEINTERFACE)); 554 555 il.append(_factory.createCheckCast(new ObjectType("org.w3c.dom.Document"))); 556 557 il.append(_factory.createLoad(Type.OBJECT, 1)); 558 559 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "getMIMEType", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 560 561 il.append(_factory.createLoad(Type.OBJECT, 1)); 562 563 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "getEncoding", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 564 565 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "setDocument", Type.VOID, new Type[] { new ObjectType("org.w3c.dom.Document"), Type.STRING, Type.STRING }, Constants.INVOKEVIRTUAL)); 566 567 InstructionHandle ih_37 = il.append(_factory.createLoad(Type.OBJECT, 0)); 568 569 il.append(_factory.createInvoke("org.enhydra.xml.xmlc.XMLObjectImpl", "syncAccessMethods", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 570 571 InstructionHandle ih_41 = il.append(_factory.createReturn(Type.VOID)); 572 573 method.setMaxStack(); 574 575 method.setMaxLocals(); 576 577 _cg.addMethod(method.getMethod()); 578 579 il.dispose(); 580 581 } 582 583 584 585 private void createMethod_9() { 586 587 InstructionList il = new InstructionList(); 588 589 MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.BOOLEAN }, new String [] { "arg0", "arg1" }, "<init>", className, il, _cp); 590 591 592 593 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 594 595 il.append(_factory.createInvoke(_impl, "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); 596 597 InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0)); 598 599 il.append(_factory.createLoad(Type.OBJECT, 1)); 600 601 il.append(_factory.createFieldAccess(className, "fDocumentLoader", new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Constants.PUTFIELD)); 602 603 InstructionHandle ih_9 = il.append(_factory.createLoad(Type.INT, 2)); 604 605 BranchInstruction ifeq_10 = _factory.createBranchInstruction(Constants.IFEQ, null); 606 607 il.append(ifeq_10); 608 609 InstructionHandle ih_13 = il.append(_factory.createLoad(Type.OBJECT, 0)); 610 611 il.append(_factory.createInvoke(className, "buildDocument", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); 612 613 InstructionHandle ih_17 = il.append(_factory.createReturn(Type.VOID)); 614 615 ifeq_10.setTarget(ih_17); 616 617 method.setMaxStack(); 618 619 method.setMaxLocals(); 620 621 _cg.addMethod(method.getMethod()); 622 623 il.dispose(); 624 625 } 626 627 628 629 private void createMethod_10() { 630 631 InstructionList il = new InstructionList(); 632 633 MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader") }, new String [] { "arg0" }, "<init>", className, il, _cp); 634 635 636 637 InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); 638 639 il.append(_factory.createLoad(Type.OBJECT, 1)); 640 641 il.append(new PUSH(_cp, 1)); 642 643 il.append(_factory.createInvoke(className, "<init>", Type.VOID, new Type[] { new ObjectType("org.enhydra.xml.xmlc.deferredparsing.DocumentLoader"), Type.BOOLEAN }, Constants.INVOKESPECIAL)); 644 645 InstructionHandle ih_6 = il.append(_factory.createReturn(Type.VOID)); 646 647 method.setMaxStack(); 648 649 method.setMaxLocals(); 650 651 _cg.addMethod(method.getMethod()); 652 653 il.dispose(); 654 655 } 656 657 658 659 private void createMethod_11() { 660 661 InstructionList il = new InstructionList(); 662 663 MethodGen method = new MethodGen(ACC_STATIC | ACC_FINAL, Type.VOID, Type.NO_ARGS, new String [] { }, "<clinit>", className, il, _cp); 664 665 666 667 InstructionHandle ih_0 = il.append(_factory.createFieldAccess(className, "class$L" + className.replace('.','$'), new ObjectType("java.lang.Class"), Constants.GETSTATIC)); 668 669 BranchInstruction ifnull_3 = _factory.createBranchInstruction(Constants.IFNULL, null); 670 671 il.append(ifnull_3); 672 673 il.append(_factory.createFieldAccess(className, 674 675 "class$L" + className.replace('.','$'), 676 677 new ObjectType("java.lang.Class"), Constants.GETSTATIC)); 678 679 BranchInstruction goto_9 = _factory.createBranchInstruction(Constants.GOTO, null); 680 681 il.append(goto_9); 682 683 InstructionHandle ih_12 = il.append(new PUSH(_cp, className)); 684 685 il.append(_factory.createInvoke(className, "class$", new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, Constants.INVOKESTATIC)); 686 687 il.append(InstructionConstants.DUP); 688 689 il.append(_factory.createFieldAccess(className, 690 691 "class$L" + className.replace('.','$'), 692 693 new ObjectType("java.lang.Class"), Constants.PUTSTATIC)); 694 695 InstructionHandle ih_21 = il.append(_factory.createFieldAccess(className, "XMLC_GENERATED_CLASS", new ObjectType("java.lang.Class"), Constants.PUTSTATIC)); 696 697 InstructionHandle ih_24 = il.append(_factory.createFieldAccess(className, "class$Lorg$enhydra$xml$xmlc$dom$lazydom$LazyHTMLDomFactory", new ObjectType("java.lang.Class"), Constants.GETSTATIC)); 698 699 BranchInstruction ifnull_27 = _factory.createBranchInstruction(Constants.IFNULL, null); 700 701 il.append(ifnull_27); 702 703 il.append(_factory.createFieldAccess(className, "class$Lorg$enhydra$xml$xmlc$dom$lazydom$LazyHTMLDomFactory", new ObjectType("java.lang.Class"), Constants.GETSTATIC)); 704 705 BranchInstruction goto_33 = _factory.createBranchInstruction(Constants.GOTO, null); 706 707 il.append(goto_33); 708 709 InstructionHandle ih_36 = il.append(new PUSH(_cp, "org.enhydra.xml.xmlc.dom.lazydom.LazyHTMLDomFactory")); 710 711 il.append(_factory.createInvoke(className, "class$", new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, Constants.INVOKESTATIC)); 712 713 il.append(InstructionConstants.DUP); 714 715 il.append(_factory.createFieldAccess(className, "class$Lorg$enhydra$xml$xmlc$dom$lazydom$LazyHTMLDomFactory", new ObjectType("java.lang.Class"), Constants.PUTSTATIC)); 716 717 InstructionHandle ih_45 = il.append(_factory.createInvoke("org.enhydra.xml.xmlc.dom.XMLCDomFactoryCache", "getFactory", new ObjectType("org.enhydra.xml.xmlc.dom.XMLCDomFactory"), new Type[] { new ObjectType("java.lang.Class") }, Constants.INVOKESTATIC)); 718 719 il.append(_factory.createFieldAccess(className, "fDOMFactory", new ObjectType("org.enhydra.xml.xmlc.dom.XMLCDomFactory"), Constants.PUTSTATIC)); 720 721 il.append(_factory.createReturn(Type.VOID)); 722 723 ifnull_3.setTarget(ih_12); 724 725 goto_9.setTarget(ih_21); 726 727 ifnull_27.setTarget(ih_36); 728 729 goto_33.setTarget(ih_45); 730 731 method.setMaxStack(); 732 733 method.setMaxLocals(); 734 735 _cg.addMethod(method.getMethod()); 736 737 il.dispose(); 738 739 } 740 741 742 743 } 744 745 | Popular Tags |