提交 08423024 编写于 作者: M msheppar

8011157: Improve CORBA portablility

Summary: fix also reviewed by Alexander Fomin
Reviewed-by: alanb, coffeys, skoivu
上级 5dbab501
/* /*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -55,7 +55,7 @@ import com.sun.corba.se.impl.orbutil.ORBUtility; ...@@ -55,7 +55,7 @@ import com.sun.corba.se.impl.orbutil.ORBUtility;
/** /**
* @author Harold Carr * @author Harold Carr
*/ */
public class SelectorImpl class SelectorImpl
extends extends
Thread Thread
implements implements
......
/* /*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -34,6 +34,9 @@ package sun.rmi.rmic.iiop; ...@@ -34,6 +34,9 @@ package sun.rmi.rmic.iiop;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.SerializablePermission;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Vector; import java.util.Vector;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Enumeration; import java.util.Enumeration;
...@@ -49,6 +52,7 @@ import com.sun.corba.se.impl.util.Utility; ...@@ -49,6 +52,7 @@ import com.sun.corba.se.impl.util.Utility;
import com.sun.corba.se.impl.util.PackagePrefixChecker; import com.sun.corba.se.impl.util.PackagePrefixChecker;
import sun.rmi.rmic.Main; import sun.rmi.rmic.Main;
/** /**
* An IIOP stub/tie generator for rmic. * An IIOP stub/tie generator for rmic.
* *
...@@ -78,6 +82,7 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator { ...@@ -78,6 +82,7 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
protected boolean castArray = false; protected boolean castArray = false;
protected Hashtable transactionalObjects = new Hashtable() ; protected Hashtable transactionalObjects = new Hashtable() ;
protected boolean POATie = false ; protected boolean POATie = false ;
protected boolean emitPermissionCheck = false;
/** /**
* Default constructor for Main to use. * Default constructor for Main to use.
...@@ -193,6 +198,9 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator { ...@@ -193,6 +198,9 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
} else if (argv[i].equals("-standardPackage")) { } else if (argv[i].equals("-standardPackage")) {
standardPackage = true; standardPackage = true;
argv[i] = null; argv[i] = null;
} else if (argv[i].equals("-emitPermissionCheck")) {
emitPermissionCheck = true;
argv[i] = null;
} else if (arg.equals("-xstubbase")) { } else if (arg.equals("-xstubbase")) {
argv[i] = null; argv[i] = null;
if (++i < argv.length && argv[i] != null && !argv[i].startsWith("-")) { if (++i < argv.length && argv[i] != null && !argv[i].startsWith("-")) {
...@@ -390,9 +398,22 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator { ...@@ -390,9 +398,22 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
writePackageAndImports(p); writePackageAndImports(p);
// generate
// import java.security.AccessController;
// import java.security.PrivilegedAction;
// import java.io.SerializablePermission;
if (emitPermissionCheck) {
p.pln("import java.security.AccessController;");
p.pln("import java.security.PrivilegedAction;");
p.pln("import java.io.SerializablePermission;");
p.pln();
p.pln();
}
// Declare the stub class; implement all remote interfaces. // Declare the stub class; implement all remote interfaces.
p.p("public class " + currentClass); p.p("public class " + currentClass);
p.p(" extends " + getName(stubBaseClass)); p.p(" extends " + getName(stubBaseClass));
p.p(" implements "); p.p(" implements ");
if (remoteInterfaces.length > 0) { if (remoteInterfaces.length > 0) {
...@@ -422,6 +443,57 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator { ...@@ -422,6 +443,57 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
writeIds( p, theType, false ); writeIds( p, theType, false );
p.pln(); p.pln();
if (emitPermissionCheck) {
// produce the following generated code for example
// private static Void checkPermission() {
// SecurityManager sm = System.getSecurityManager();
// if (sm != null) {
// sm.checkPermission(new SerializablePermission(
// "enableSubclassImplementation")); // testing
// }
// return null;
// }
//
// private _XXXXX_Stub(Void ignore) {
// }
//
// public _XXXXX_Stub() {
// this(checkPermission());
// }
//
// where XXXXX is the name of the remote interface
p.pln();
p.plnI("private static Void checkPermission() {");
p.plnI("SecurityManager sm = System.getSecurityManager();");
p.pln("if (sm != null) {");
p.pI();
p.plnI("sm.checkPermission(new SerializablePermission(");
p.plnI("\"enableSubclassImplementation\"));");
p.pO();
p.pO();
p.pOln("}");
p.pln("return null;");
p.pO();
p.pOln("}");
p.pln();
p.pO();
p.pI();
p.pln("private " + currentClass + "(Void ignore) { }");
p.pln();
p.plnI("public " + currentClass + "() { ");
p.pln("this(checkPermission());");
p.pOln("}");
p.pln();
}
if (!emitPermissionCheck) {
p.pI();
}
// Write the _ids() method... // Write the _ids() method...
p.plnI("public String[] _ids() { "); p.plnI("public String[] _ids() { ");
...@@ -815,7 +887,6 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator { ...@@ -815,7 +887,6 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
CompoundType theType) throws IOException { CompoundType theType) throws IOException {
// Wtite the method declaration and opening brace... // Wtite the method declaration and opening brace...
String methodName = method.getName(); String methodName = method.getName();
String methodIDLName = method.getIDLName(); String methodIDLName = method.getIDLName();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册