444 p.pln(); |
444 p.pln(); |
445 |
445 |
446 if (emitPermissionCheck) { |
446 if (emitPermissionCheck) { |
447 |
447 |
448 // produce the following generated code for example |
448 // produce the following generated code for example |
|
449 // |
|
450 // private transient boolean _instantiated = false; |
|
451 // |
449 // private static Void checkPermission() { |
452 // private static Void checkPermission() { |
450 // SecurityManager sm = System.getSecurityManager(); |
453 // SecurityManager sm = System.getSecurityManager(); |
451 // if (sm != null) { |
454 // if (sm != null) { |
452 // sm.checkPermission(new SerializablePermission( |
455 // sm.checkPermission(new SerializablePermission( |
453 // "enableSubclassImplementation")); // testing |
456 // "enableSubclassImplementation")); // testing |
458 // private _XXXXX_Stub(Void ignore) { |
461 // private _XXXXX_Stub(Void ignore) { |
459 // } |
462 // } |
460 // |
463 // |
461 // public _XXXXX_Stub() { |
464 // public _XXXXX_Stub() { |
462 // this(checkPermission()); |
465 // this(checkPermission()); |
|
466 // _instantiated = true; |
|
467 // } |
|
468 // |
|
469 // private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { |
|
470 // checkPermission(); |
|
471 // s.defaultReadObject(); |
|
472 // _instantiated = true; |
463 // } |
473 // } |
464 // |
474 // |
465 // where XXXXX is the name of the remote interface |
475 // where XXXXX is the name of the remote interface |
466 |
476 |
467 p.pln(); |
477 p.pln(); |
|
478 p.plnI("private transient boolean _instantiated = false;"); |
|
479 p.pln(); |
|
480 p.pO(); |
468 p.plnI("private static Void checkPermission() {"); |
481 p.plnI("private static Void checkPermission() {"); |
469 p.plnI("SecurityManager sm = System.getSecurityManager();"); |
482 p.plnI("SecurityManager sm = System.getSecurityManager();"); |
470 p.pln("if (sm != null) {"); |
483 p.pln("if (sm != null) {"); |
471 p.pI(); |
484 p.pI(); |
472 p.plnI("sm.checkPermission(new SerializablePermission("); |
485 p.plnI("sm.checkPermission(new SerializablePermission("); |
479 p.pOln("}"); |
492 p.pOln("}"); |
480 p.pln(); |
493 p.pln(); |
481 p.pO(); |
494 p.pO(); |
482 |
495 |
483 p.pI(); |
496 p.pI(); |
484 p.pln("private " + currentClass + "(Void ignore) { }"); |
497 p.plnI("private " + currentClass + "(Void ignore) { }"); |
485 p.pln(); |
498 p.pln(); |
486 |
499 p.pO(); |
487 p.plnI("public " + currentClass + "() { "); |
500 |
|
501 p.plnI("public " + currentClass + "() {"); |
488 p.pln("this(checkPermission());"); |
502 p.pln("this(checkPermission());"); |
|
503 p.pln("_instantiated = true;"); |
489 p.pOln("}"); |
504 p.pOln("}"); |
490 p.pln(); |
505 p.pln(); |
|
506 p.plnI("private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {"); |
|
507 p.plnI("checkPermission();"); |
|
508 p.pO(); |
|
509 p.pln("s.defaultReadObject();"); |
|
510 p.pln("_instantiated = true;"); |
|
511 p.pOln("}"); |
|
512 p.pln(); |
|
513 //p.pO(); |
491 } |
514 } |
492 |
515 |
493 if (!emitPermissionCheck) { |
516 if (!emitPermissionCheck) { |
494 p.pI(); |
517 p.pI(); |
495 } |
518 } |
892 |
915 |
893 Type paramTypes[] = method.getArguments(); |
916 Type paramTypes[] = method.getArguments(); |
894 String paramNames[] = method.getArgumentNames(); |
917 String paramNames[] = method.getArgumentNames(); |
895 Type returnType = method.getReturnType(); |
918 Type returnType = method.getReturnType(); |
896 ValueType[] exceptions = getStubExceptions(method,false); |
919 ValueType[] exceptions = getStubExceptions(method,false); |
|
920 boolean hasIOException = false; |
897 |
921 |
898 addNamesInUse(method); |
922 addNamesInUse(method); |
899 addNameInUse("_type_ids"); |
923 addNameInUse("_type_ids"); |
900 |
924 |
901 String objName = testUtil(getName(returnType), returnType); |
925 String objName = testUtil(getName(returnType), returnType); |
919 } |
943 } |
920 |
944 |
921 p.plnI(" {"); |
945 p.plnI(" {"); |
922 |
946 |
923 // Now create the method body... |
947 // Now create the method body... |
|
948 if (emitPermissionCheck) { |
|
949 p.pln("if ((System.getSecurityManager() != null) && (!_instantiated)) {"); |
|
950 p.plnI(" throw new java.io.IOError(new java.io.IOException(\"InvalidObject \"));"); |
|
951 p.pOln("}"); |
|
952 p.pln(); |
|
953 } |
|
954 |
924 |
955 |
925 if (localStubs) { |
956 if (localStubs) { |
926 writeLocalStubMethodBody(p,method,theType); |
957 writeLocalStubMethodBody(p,method,theType); |
927 } else { |
958 } else { |
928 writeNonLocalStubMethodBody(p,method,theType); |
959 writeNonLocalStubMethodBody(p,method,theType); |