From ae96f935a2cb24cf785ee38817c46fd42519bc69 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Fri, 14 Jun 2013 15:49:54 +0100 Subject: [PATCH] 8011157: Improve CORBA portablility Fix also reviewed by Alexander Fomin Reviewed-by: alanb, coffeys, skoivu --- jdk/make/com/sun/jmx/Makefile | 2 ++ .../modelmbean/RequiredModelMBean.java | 8 ++++++-- .../management/remote/rmi/RMIConnector.java | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/jdk/make/com/sun/jmx/Makefile b/jdk/make/com/sun/jmx/Makefile index 62435751673..02ef6b07998 100644 --- a/jdk/make/com/sun/jmx/Makefile +++ b/jdk/make/com/sun/jmx/Makefile @@ -130,11 +130,13 @@ $(CLASSDESTDIR)/%_Stub.class: $(CLASSDESTDIR)/%.class $(RMIC) -classpath "$(CLASSDESTDIR)" \ -d $(CLASSDESTDIR) \ -iiop -v1.2 \ + -emitPermissionCheck \ $(subst /,.,$(<:$(CLASSDESTDIR)/%.class=%)) $(RMIC) $(HOTSPOT_INTERPRETER_FLAG) -classpath "$(CLASSDESTDIR)" \ -d $(CLASSDESTDIR) \ -iiop -v1.2 \ -standardPackage \ + -emitPermissionCheck \ $(subst /,.,$(<:$(CLASSDESTDIR)/%.class=%)) @$(java-vm-cleanup) diff --git a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java index 6d28adaf0f7..0afd70f9423 100644 --- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java +++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -298,11 +298,15 @@ public class RequiredModelMBean RequiredModelMBean.class.getName(), "setModelMBeanInfo(ModelMBeanInfo)", "Setting ModelMBeanInfo to " + printModelMBeanInfo(mbi)); + int noOfNotifications = 0; + if (mbi.getNotifications() != null) { + noOfNotifications = mbi.getNotifications().length; + } MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "setModelMBeanInfo(ModelMBeanInfo)", "ModelMBeanInfo notifications has " + - (mbi.getNotifications()).length + " elements"); + noOfNotifications + " elements"); } modelMBeanInfo = (ModelMBeanInfo)mbi.clone(); diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java index 53e6754e6ed..4ddfb8fee38 100644 --- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java +++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,6 +61,7 @@ import java.rmi.server.RemoteRef; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; import java.security.ProtectionDomain; import java.util.Arrays; import java.util.Collections; @@ -128,7 +129,6 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable Map environment) { if (rmiServer == null && address == null) throw new IllegalArgumentException("rmiServer and jmxServiceURL both null"); - initTransients(); this.rmiServer = rmiServer; @@ -2370,13 +2370,21 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable } } - private static RMIConnection shadowIiopStub(Object stub) + private static RMIConnection shadowIiopStub(Object stub) throws InstantiationException, IllegalAccessException { - Object proxyStub = proxyStubClass.newInstance(); + Object proxyStub = null; + try { + proxyStub = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return proxyStubClass.newInstance(); + } + }); + } catch (PrivilegedActionException e) { + throw new InternalError(); + } IIOPHelper.setDelegate(proxyStub, IIOPHelper.getDelegate(stub)); return (RMIConnection) proxyStub; } - private static RMIConnection getConnection(RMIServer server, Object credentials, boolean checkStub)