Fri, 14 Jun 2013 16:31:55 +0100
8011157: Improve CORBA portablility
Summary: fix also reviewed by Alexander Fomin
Reviewed-by: alanb, coffeys, skoivu
1.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Tue Jun 18 20:52:10 2013 -0700 1.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Fri Jun 14 16:31:55 2013 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -55,7 +55,7 @@ 1.11 /** 1.12 * @author Harold Carr 1.13 */ 1.14 -public class SelectorImpl 1.15 +class SelectorImpl 1.16 extends 1.17 Thread 1.18 implements
2.1 --- a/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Tue Jun 18 20:52:10 2013 -0700 2.2 +++ b/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Fri Jun 14 16:31:55 2013 +0100 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -34,6 +34,9 @@ 2.11 2.12 import java.io.File; 2.13 import java.io.IOException; 2.14 +import java.io.SerializablePermission; 2.15 +import java.security.AccessController; 2.16 +import java.security.PrivilegedAction; 2.17 import java.util.Vector; 2.18 import java.util.Hashtable; 2.19 import java.util.Enumeration; 2.20 @@ -49,6 +52,7 @@ 2.21 import com.sun.corba.se.impl.util.PackagePrefixChecker; 2.22 import sun.rmi.rmic.Main; 2.23 2.24 + 2.25 /** 2.26 * An IIOP stub/tie generator for rmic. 2.27 * 2.28 @@ -78,6 +82,7 @@ 2.29 protected boolean castArray = false; 2.30 protected Hashtable transactionalObjects = new Hashtable() ; 2.31 protected boolean POATie = false ; 2.32 + protected boolean emitPermissionCheck = false; 2.33 2.34 /** 2.35 * Default constructor for Main to use. 2.36 @@ -193,6 +198,9 @@ 2.37 } else if (argv[i].equals("-standardPackage")) { 2.38 standardPackage = true; 2.39 argv[i] = null; 2.40 + } else if (argv[i].equals("-emitPermissionCheck")) { 2.41 + emitPermissionCheck = true; 2.42 + argv[i] = null; 2.43 } else if (arg.equals("-xstubbase")) { 2.44 argv[i] = null; 2.45 if (++i < argv.length && argv[i] != null && !argv[i].startsWith("-")) { 2.46 @@ -390,9 +398,22 @@ 2.47 2.48 writePackageAndImports(p); 2.49 2.50 +// generate 2.51 +// import java.security.AccessController; 2.52 +// import java.security.PrivilegedAction; 2.53 +// import java.io.SerializablePermission; 2.54 + if (emitPermissionCheck) { 2.55 + p.pln("import java.security.AccessController;"); 2.56 + p.pln("import java.security.PrivilegedAction;"); 2.57 + p.pln("import java.io.SerializablePermission;"); 2.58 + p.pln(); 2.59 + p.pln(); 2.60 + } 2.61 + 2.62 // Declare the stub class; implement all remote interfaces. 2.63 2.64 p.p("public class " + currentClass); 2.65 + 2.66 p.p(" extends " + getName(stubBaseClass)); 2.67 p.p(" implements "); 2.68 if (remoteInterfaces.length > 0) { 2.69 @@ -422,6 +443,57 @@ 2.70 writeIds( p, theType, false ); 2.71 p.pln(); 2.72 2.73 + if (emitPermissionCheck) { 2.74 + 2.75 + // produce the following generated code for example 2.76 + // private static Void checkPermission() { 2.77 + // SecurityManager sm = System.getSecurityManager(); 2.78 + // if (sm != null) { 2.79 + // sm.checkPermission(new SerializablePermission( 2.80 + // "enableSubclassImplementation")); // testing 2.81 + // } 2.82 + // return null; 2.83 + // } 2.84 + // 2.85 + // private _XXXXX_Stub(Void ignore) { 2.86 + // } 2.87 + // 2.88 + // public _XXXXX_Stub() { 2.89 + // this(checkPermission()); 2.90 + // } 2.91 + // 2.92 + // where XXXXX is the name of the remote interface 2.93 + 2.94 + p.pln(); 2.95 + p.plnI("private static Void checkPermission() {"); 2.96 + p.plnI("SecurityManager sm = System.getSecurityManager();"); 2.97 + p.pln("if (sm != null) {"); 2.98 + p.pI(); 2.99 + p.plnI("sm.checkPermission(new SerializablePermission("); 2.100 + p.plnI("\"enableSubclassImplementation\"));"); 2.101 + p.pO(); 2.102 + p.pO(); 2.103 + p.pOln("}"); 2.104 + p.pln("return null;"); 2.105 + p.pO(); 2.106 + p.pOln("}"); 2.107 + p.pln(); 2.108 + p.pO(); 2.109 + 2.110 + p.pI(); 2.111 + p.pln("private " + currentClass + "(Void ignore) { }"); 2.112 + p.pln(); 2.113 + 2.114 + p.plnI("public " + currentClass + "() { "); 2.115 + p.pln("this(checkPermission());"); 2.116 + p.pOln("}"); 2.117 + p.pln(); 2.118 + } 2.119 + 2.120 + if (!emitPermissionCheck) { 2.121 + p.pI(); 2.122 + } 2.123 + 2.124 // Write the _ids() method... 2.125 2.126 p.plnI("public String[] _ids() { "); 2.127 @@ -815,7 +887,6 @@ 2.128 CompoundType theType) throws IOException { 2.129 2.130 // Wtite the method declaration and opening brace... 2.131 - 2.132 String methodName = method.getName(); 2.133 String methodIDLName = method.getIDLName(); 2.134