Mercurial > hg > release > icedtea7-forest-2.1 > corba
changeset 372:50f1d640ea27
8000631: Restrict access to class constructor
Reviewed-by: alanb, ahgross
line wrap: on
line diff
--- a/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk Tue Oct 30 17:15:13 2012 +0000 +++ b/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2012, 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 @@ -29,10 +29,6 @@ com/sun/corba/se/impl/orbutil/DenseIntMapImpl.java \ com/sun/corba/se/impl/orbutil/GetPropertyAction.java \ com/sun/corba/se/impl/orbutil/HexOutputStream.java \ - com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3.java \ - com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3_1.java \ - com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3.java \ - com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3_1.java \ com/sun/corba/se/impl/orbutil/LegacyHookGetFields.java \ com/sun/corba/se/impl/orbutil/LegacyHookPutFields.java \ com/sun/corba/se/impl/orbutil/LogKeywords.java \ @@ -45,19 +41,11 @@ com/sun/corba/se/impl/orbutil/ORBUtility.java \ com/sun/corba/se/impl/orbutil/ORBClassLoader.java \ com/sun/corba/se/impl/orbutil/RepIdDelegator.java \ - com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3.java \ - com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3_1.java \ - com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3.java \ - com/sun/corba/se/impl/orbutil/RepositoryId_1_3.java \ com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java \ com/sun/corba/se/impl/orbutil/RepositoryIdStrings.java \ com/sun/corba/se/impl/orbutil/RepositoryIdUtility.java \ com/sun/corba/se/impl/orbutil/RepositoryIdInterface.java \ - com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3_1.java \ - com/sun/corba/se/impl/orbutil/RepositoryId_1_3_1.java \ com/sun/corba/se/impl/orbutil/StackImpl.java \ - com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3_1.java \ - com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3.java \ com/sun/corba/se/impl/orbutil/closure/Future.java \ com/sun/corba/se/impl/orbutil/closure/Constant.java \ com/sun/corba/se/impl/orbutil/concurrent/Sync.java \
--- a/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -1218,7 +1218,7 @@ // See bug 4391648 for more info about the tcORB in this // case. RepositoryIdStrings repStrs - = RepositoryIdFactory.getRepIdStringsFactory(tcORB); + = RepositoryIdFactory.getRepIdStringsFactory(); // Assertion: c instanceof Serializable? @@ -1251,7 +1251,7 @@ // Anything else // We know that this is a TypeCodeImpl since it is our ORB classTC = (TypeCodeImpl)ValueUtility.createTypeCodeForClass( - tcORB, c, ORBUtility.createValueHandler(tcORB)); + tcORB, c, ORBUtility.createValueHandler()); // Intruct classTC to store its buffer classTC.setCaching(true); // Update the cache
--- a/src/share/classes/com/sun/corba/se/impl/encoding/CDRInputStream_1_0.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/encoding/CDRInputStream_1_0.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -269,8 +269,8 @@ private final void createRepositoryIdHandlers() { - repIdUtil = RepositoryIdFactory.getRepIdUtility(orb); - repIdStrs = RepositoryIdFactory.getRepIdStringsFactory(orb); + repIdUtil = RepositoryIdFactory.getRepIdUtility(); + repIdStrs = RepositoryIdFactory.getRepIdStringsFactory(); } public GIOPVersion getGIOPVersion() { @@ -564,10 +564,7 @@ checkForNegativeLength(len); - if (orb != null && ORBUtility.isLegacyORB((ORB)orb)) - return legacyReadString(len); - else - return internalReadString(len); + return internalReadString(len); } private final String internalReadString(int len) { @@ -588,54 +585,6 @@ return new String(result, 0, getCharConverter().getNumChars()); } - private final String legacyReadString(int len) { - - // - // Workaround for ORBs which send string lengths of - // zero to mean empty string. - // - // - // IMPORTANT: Do not replace 'new String("")' with "", it may result - // in a Serialization bug (See serialization.zerolengthstring) and - // bug id: 4728756 for details - if (len == 0) - return new String(""); - - len--; - char[] c = new char[len]; - - int n = 0; - while (n < len) { - int avail; - int bytes; - int wanted; - - avail = bbwi.buflen - bbwi.position(); - if (avail <= 0) { - grow(1, 1); - avail = bbwi.buflen - bbwi.position(); - } - wanted = len - n; - bytes = (wanted < avail) ? wanted : avail; - // Microbenchmarks are showing a loop of ByteBuffer.get(int) being - // faster than ByteBuffer.get(byte[], int, int). - for (int i=0; i<bytes; i++) { - c[n+i] = (char) (bbwi.byteBuffer.get(bbwi.position()+i) & 0xFF); - } - bbwi.position(bbwi.position() + bytes); - n += bytes; - } - - // - // Skip past terminating null byte - // - if (bbwi.position() + 1 > bbwi.buflen) - alignAndCheck(1, 1); - bbwi.position(bbwi.position() + 1); - - return new String(c); - } - public final String read_string() { return readStringOrIndirection(false); } @@ -1045,7 +994,7 @@ try { if (valueHandler == null) - valueHandler = ORBUtility.createValueHandler(orb); + valueHandler = ORBUtility.createValueHandler(); value = valueHandler.readValue(parent, indirection,
--- a/src/share/classes/com/sun/corba/se/impl/encoding/CDROutputStream_1_0.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/encoding/CDROutputStream_1_0.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -189,18 +189,8 @@ private final void createRepositoryIdHandlers() { - if (orb != null) { - // Get the appropriate versions based on the ORB version. The - // ORB versioning info is only in the core ORB. - repIdUtil - = RepositoryIdFactory.getRepIdUtility(orb); - repIdStrs - = RepositoryIdFactory.getRepIdStringsFactory(orb); - } else { - // Get the latest versions - repIdUtil = RepositoryIdFactory.getRepIdUtility(); - repIdStrs = RepositoryIdFactory.getRepIdStringsFactory(); - } + repIdUtil = RepositoryIdFactory.getRepIdUtility(); + repIdStrs = RepositoryIdFactory.getRepIdStringsFactory(); } public BufferManagerWrite getBufferManager() @@ -705,7 +695,7 @@ private void writeArray(Serializable array, Class clazz) { if (valueHandler == null) - valueHandler = ORBUtility.createValueHandler(orb); //d11638 + valueHandler = ORBUtility.createValueHandler(); //d11638 // Write value_tag int indirection = writeValueTag(mustChunk, true, @@ -768,7 +758,7 @@ private void writeRMIIIOPValueType(Serializable object, Class clazz) { if (valueHandler == null) - valueHandler = ORBUtility.createValueHandler(orb); //d11638 + valueHandler = ORBUtility.createValueHandler(); //d11638 Serializable key = object;
--- a/src/share/classes/com/sun/corba/se/impl/io/FVDCodeBaseImpl.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/io/FVDCodeBaseImpl.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, 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 @@ -86,7 +86,7 @@ // default to using the current ORB version in case the // vhandler is not set if (vhandler == null) { - vhandler = new ValueHandlerImpl(false); + vhandler = ValueHandlerImpl.getInstance(false); } // Util.getCodebase may return null which would @@ -120,7 +120,7 @@ // default to using the current ORB version in case the // vhandler is not set if (vhandler == null) { - vhandler = new ValueHandlerImpl(false); + vhandler = ValueHandlerImpl.getInstance(false); } try{ @@ -161,7 +161,7 @@ // default to using the current ORB version in case the // vhandler is not set if (vhandler == null) { - vhandler = new ValueHandlerImpl(false); + vhandler = ValueHandlerImpl.getInstance(false); } Stack repIds = new Stack();
--- a/src/share/classes/com/sun/corba/se/impl/io/ValueHandlerImpl.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/io/ValueHandlerImpl.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -53,7 +53,7 @@ import com.sun.corba.se.impl.logging.OMGSystemException; import com.sun.corba.se.impl.logging.UtilSystemException; -public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat { +public final class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat { // Property to override our maximum stream format version public static final String FORMAT_VERSION_PROPERTY @@ -150,14 +150,22 @@ writeValueWithVersion(out, value, streamFormatVersion); } - public ValueHandlerImpl(){} + private ValueHandlerImpl(){} - public ValueHandlerImpl(boolean isInputStream) { + private ValueHandlerImpl(boolean isInputStream) { this(); useHashtables = false; this.isInputStream = isInputStream; } + static ValueHandlerImpl getInstance() { + return new ValueHandlerImpl(); + } + + static ValueHandlerImpl getInstance(boolean isInputStream) { + return new ValueHandlerImpl(isInputStream); + } + /** * Writes the value to the stream using java semantics. * @param out The stream to write the value to @@ -458,12 +466,7 @@ return ObjectStreamClass.lookup(value.getClass()).writeReplace(value); } - /** - * Encapsulates writing of Java char arrays so that the 1.3 subclass - * can override it without exposing internals across packages. This - * is a fix for bug 4367783. - */ - protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out, + private void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out, char[] array, int offset, int length) @@ -576,12 +579,7 @@ } } - /** - * Encapsulates reading of Java char arrays so that the 1.3 subclass - * can override it without exposing internals across packages. This - * is a fix for bug 4367783. - */ - protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream in, + private void readCharArray(org.omg.CORBA_2_3.portable.InputStream in, char[] array, int offset, int length) @@ -795,7 +793,7 @@ return RepositoryId.cache.getId(repId).isSequence(); } - protected String getOutputStreamClassName() { + private String getOutputStreamClassName() { return "com.sun.corba.se.impl.io.IIOPOutputStream"; } @@ -843,29 +841,11 @@ private IIOPOutputStream createOutputStreamBuiltInNoPriv( final String name ) throws IOException { - return - name.equals( - IIOPOutputStream - .class.getName() - ) ? - new IIOPOutputStream() : - - name.equals( - com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3 - .class.getName() - ) ? - new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3() : - - name.equals( - com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1 - .class.getName() - ) ? - new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1() : - - null; + return name.equals(IIOPOutputStream.class.getName()) ? + new IIOPOutputStream() : null; } - protected String getInputStreamClassName() { + private String getInputStreamClassName() { return "com.sun.corba.se.impl.io.IIOPInputStream"; } @@ -913,26 +893,8 @@ private IIOPInputStream createInputStreamBuiltInNoPriv( final String name ) throws IOException { - return - name.equals( - IIOPInputStream - .class.getName() - ) ? - new IIOPInputStream() : - - name.equals( - com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3 - .class.getName() - ) ? - new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3() : - - name.equals( - com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1 - .class.getName() - ) ? - new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1() : - - null; + return name.equals(IIOPInputStream.class.getName()) ? + new IIOPInputStream() : null; } /** @@ -958,12 +920,7 @@ } - /** - * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this. - * The correct behavior is for a Java char to map to a CORBA wchar, - * but our older code mapped it to a CORBA char. - */ - protected TCKind getJavaCharTCKind() { + TCKind getJavaCharTCKind() { return TCKind.tk_wchar; } }
--- a/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, 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 @@ -93,6 +93,14 @@ null, // tk_abstract_interface 32 }; + static { + sun.corba.SharedSecrets.setJavaCorbaAccess(new sun.corba.JavaCorbaAccess() { + public ValueHandlerImpl newValueHandlerImpl() { + return ValueHandlerImpl.getInstance(); + } + }); + } + public static String getSignature(ValueMember member) throws ClassNotFoundException {
--- a/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java Tue Feb 05 08:39:53 2013 +0000 @@ -112,6 +112,9 @@ import com.sun.corba.se.impl.orbutil.ORBClassLoader; import com.sun.corba.se.impl.logging.UtilSystemException; import com.sun.corba.se.spi.logging.CORBALogDomains; +import sun.corba.SharedSecrets; +import sun.corba.JavaCorbaAccess; + /** * Provides utility methods that can be used by stubs and ties to @@ -125,7 +128,8 @@ // Maps targets to ties. private static IdentityHashtable exportedServants = new IdentityHashtable(); - private static ValueHandlerImpl valueHandlerSingleton = new ValueHandlerImpl(); + private static final ValueHandlerImpl valueHandlerSingleton = + SharedSecrets.getJavaCorbaAccess().newValueHandlerImpl(); private UtilSystemException utilWrapper = UtilSystemException.get( CORBALogDomains.RPC_ENCODING);
--- a/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Tue Feb 05 08:39:53 2013 +0000 @@ -860,7 +860,7 @@ // backward compatability 4365188 CodeBase cb; - ValueHandler vh = ORBUtility.createValueHandler(this); + ValueHandler vh = ORBUtility.createValueHandler(); cb = (CodeBase)vh.getRunTimeCodeBase(); return ORBUtility.connectAndGetIOR( this, cb ) ;
--- a/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -160,45 +160,13 @@ } /** - * Creates the correct ValueHandler for the given ORB, - * querying ORBVersion information. If the ORB or - * ORBVersion is null, gets the ValueHandler from - * Util.createValueHandler. + * Return default ValueHandler */ - public static ValueHandler createValueHandler(ORB orb) { - - if (orb == null) - return Util.createValueHandler(); - - ORBVersion version = orb.getORBVersion(); - - if (version == null) - return Util.createValueHandler(); - - if (version.equals(ORBVersionFactory.getOLD())) - return new ValueHandlerImpl_1_3(); - if (version.equals(ORBVersionFactory.getNEW())) - return new ValueHandlerImpl_1_3_1(); - + public static ValueHandler createValueHandler() { return Util.createValueHandler(); } /** - * Returns true if the given ORB could accurately be determined to be a - * Kestrel or earlier ORB. Note: If passed the ORBSingleton, this will return - * false. - */ - public static boolean isLegacyORB(ORB orb) - { - try { - ORBVersion currentORB = orb.getORBVersion(); - return currentORB.equals( ORBVersionFactory.getOLD() ) ; - } catch (SecurityException se) { - return false; - } - } - - /** * Returns true if it was accurately determined that the remote ORB is * a foreign (non-JavaSoft) ORB. Note: If passed the ORBSingleton, this * will return false.
--- a/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java Tue Oct 30 17:15:13 2012 +0000 +++ b/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java Tue Feb 05 08:39:53 2013 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -30,12 +30,6 @@ public abstract class RepositoryIdFactory { - private static final RepIdDelegator_1_3 legacyDelegator - = new RepIdDelegator_1_3(); - - private static final RepIdDelegator_1_3_1 ladybirdDelegator - = new RepIdDelegator_1_3_1(); - private static final RepIdDelegator currentDelegator = new RepIdDelegator(); @@ -48,29 +42,6 @@ } /** - * Checks the version of the ORB and returns the appropriate - * RepositoryIdStrings instance. - */ - public static RepositoryIdStrings getRepIdStringsFactory(ORB orb) - { - if (orb != null) { - switch (orb.getORBVersion().getORBType()) { - case ORBVersion.NEWER: - case ORBVersion.FOREIGN: - case ORBVersion.JDK1_3_1_01: - return currentDelegator; - case ORBVersion.OLD: - return legacyDelegator; - case ORBVersion.NEW: - return ladybirdDelegator; - default: - return currentDelegator; - } - } else - return currentDelegator; - } - - /** * Returns the latest version RepositoryIdUtility instance */ public static RepositoryIdUtility getRepIdUtility() @@ -78,26 +49,4 @@ return currentDelegator; } - /** - * Checks the version of the ORB and returns the appropriate - * RepositoryIdUtility instance. - */ - public static RepositoryIdUtility getRepIdUtility(ORB orb) - { - if (orb != null) { - switch (orb.getORBVersion().getORBType()) { - case ORBVersion.NEWER: - case ORBVersion.FOREIGN: - case ORBVersion.JDK1_3_1_01: - return currentDelegator; - case ORBVersion.OLD: - return legacyDelegator; - case ORBVersion.NEW: - return ladybirdDelegator; - default: - return currentDelegator; - } - } else - return currentDelegator; - } }