feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
368
jdkSrc/jdk8/sun/corba/Bridge.java
Normal file
368
jdkSrc/jdk8/sun/corba/Bridge.java
Normal file
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2010, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.corba;
|
||||
|
||||
import java.lang.reflect.Field ;
|
||||
import java.lang.reflect.Method ;
|
||||
import java.lang.reflect.Constructor ;
|
||||
import java.lang.reflect.InvocationTargetException ;
|
||||
|
||||
import java.io.ObjectInputStream ;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.Permission;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.misc.Unsafe ;
|
||||
import sun.reflect.ReflectionFactory ;
|
||||
|
||||
/** This class provides the methods for fundamental JVM operations
|
||||
* needed in the ORB that are not part of the public Java API. This includes:
|
||||
* <ul>
|
||||
* <li>throwException, which can throw undeclared checked exceptions.
|
||||
* This is needed to handle throwing arbitrary exceptions across a standardized OMG interface that (incorrectly) does not specify appropriate exceptions.</li>
|
||||
* <li>putXXX/getXXX methods that allow unchecked access to fields of objects.
|
||||
* This is used for setting uninitialzed non-static final fields (which is
|
||||
* impossible with reflection) and for speed.</li>
|
||||
* <li>objectFieldOffset to obtain the field offsets for use in the putXXX/getXXX methods</li>
|
||||
* <li>newConstructorForSerialization to get the special constructor required for a
|
||||
* Serializable class</li>
|
||||
* <li>latestUserDefinedLoader to get the latest user defined class loader from
|
||||
* the call stack as required by the RMI-IIOP specification (really from the
|
||||
* JDK 1.1 days)</li>
|
||||
* </ul>
|
||||
* The code that calls Bridge.get() must have the following Permissions:
|
||||
* <ul>
|
||||
* <li>RuntimePermission "reflectionFactoryAccess"</li>
|
||||
* <li>BridgePermission "getBridge"</li>
|
||||
* <li>ReflectPermission "suppressAccessChecks"</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* All of these permissions are required to obtain and correctly initialize
|
||||
* the instance of Bridge. No security checks are performed on calls
|
||||
* made to Bridge instance methods, so access to the Bridge instance
|
||||
* must be protected.
|
||||
* <p>
|
||||
* This class is a singleton (per ClassLoader of course). Access to the
|
||||
* instance is obtained through the Bridge.get() method.
|
||||
*/
|
||||
public final class Bridge
|
||||
{
|
||||
private static final Class[] NO_ARGS = new Class[] {};
|
||||
private static final Permission getBridgePermission =
|
||||
new BridgePermission( "getBridge" ) ;
|
||||
private static Bridge bridge = null ;
|
||||
|
||||
// latestUserDefinedLoader() is a private static method
|
||||
// in ObjectInputStream in JDK 1.3 through 1.5.
|
||||
// We use reflection in a doPrivileged block to get a
|
||||
// Method reference and make it accessible.
|
||||
private final Method latestUserDefinedLoaderMethod ;
|
||||
private final Unsafe unsafe ;
|
||||
private final ReflectionFactory reflectionFactory ;
|
||||
|
||||
private Method getLatestUserDefinedLoaderMethod()
|
||||
{
|
||||
return (Method) AccessController.doPrivileged(
|
||||
new PrivilegedAction()
|
||||
{
|
||||
public Object run()
|
||||
{
|
||||
Method result = null;
|
||||
|
||||
try {
|
||||
Class io = ObjectInputStream.class;
|
||||
result = io.getDeclaredMethod(
|
||||
"latestUserDefinedLoader", NO_ARGS);
|
||||
result.setAccessible(true);
|
||||
} catch (NoSuchMethodException nsme) {
|
||||
Error err = new Error( "java.io.ObjectInputStream" +
|
||||
" latestUserDefinedLoader " + nsme );
|
||||
err.initCause(nsme) ;
|
||||
throw err ;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private Unsafe getUnsafe() {
|
||||
Field fld = (Field)AccessController.doPrivileged(
|
||||
new PrivilegedAction()
|
||||
{
|
||||
public Object run()
|
||||
{
|
||||
Field fld = null ;
|
||||
|
||||
try {
|
||||
Class unsafeClass = sun.misc.Unsafe.class ;
|
||||
fld = unsafeClass.getDeclaredField( "theUnsafe" ) ;
|
||||
fld.setAccessible( true ) ;
|
||||
return fld ;
|
||||
} catch (NoSuchFieldException exc) {
|
||||
Error err = new Error( "Could not access Unsafe" ) ;
|
||||
err.initCause( exc ) ;
|
||||
throw err ;
|
||||
}
|
||||
}
|
||||
}
|
||||
) ;
|
||||
|
||||
Unsafe unsafe = null;
|
||||
|
||||
try {
|
||||
unsafe = (Unsafe)(fld.get( null )) ;
|
||||
} catch (Throwable t) {
|
||||
Error err = new Error( "Could not access Unsafe" ) ;
|
||||
err.initCause( t ) ;
|
||||
throw err ;
|
||||
}
|
||||
|
||||
return unsafe ;
|
||||
}
|
||||
|
||||
|
||||
private Bridge()
|
||||
{
|
||||
latestUserDefinedLoaderMethod = getLatestUserDefinedLoaderMethod();
|
||||
unsafe = getUnsafe() ;
|
||||
reflectionFactory = (ReflectionFactory)AccessController.doPrivileged(
|
||||
new ReflectionFactory.GetReflectionFactoryAction());
|
||||
}
|
||||
|
||||
/** Fetch the Bridge singleton. This requires the following
|
||||
* permissions:
|
||||
* <ul>
|
||||
* <li>RuntimePermission "reflectionFactoryAccess"</li>
|
||||
* <li>BridgePermission "getBridge"</li>
|
||||
* <li>ReflectPermission "suppressAccessChecks"</li>
|
||||
* </ul>
|
||||
* @return The singleton instance of the Bridge class
|
||||
* @throws SecurityException if the caller does not have the
|
||||
* required permissions and the caller has a non-null security manager.
|
||||
*/
|
||||
public static final synchronized Bridge get()
|
||||
{
|
||||
SecurityManager sman = System.getSecurityManager() ;
|
||||
if (sman != null)
|
||||
sman.checkPermission( getBridgePermission ) ;
|
||||
|
||||
if (bridge == null) {
|
||||
bridge = new Bridge() ;
|
||||
}
|
||||
|
||||
return bridge ;
|
||||
}
|
||||
|
||||
/** Obtain the latest user defined ClassLoader from the call stack.
|
||||
* This is required by the RMI-IIOP specification.
|
||||
*/
|
||||
public final ClassLoader getLatestUserDefinedLoader()
|
||||
{
|
||||
try {
|
||||
// Invoke the ObjectInputStream.latestUserDefinedLoader method
|
||||
return (ClassLoader)latestUserDefinedLoaderMethod.invoke(null,
|
||||
(Object[])NO_ARGS);
|
||||
} catch (InvocationTargetException ite) {
|
||||
Error err = new Error(
|
||||
"sun.corba.Bridge.latestUserDefinedLoader: " + ite ) ;
|
||||
err.initCause( ite ) ;
|
||||
throw err ;
|
||||
} catch (IllegalAccessException iae) {
|
||||
Error err = new Error(
|
||||
"sun.corba.Bridge.latestUserDefinedLoader: " + iae ) ;
|
||||
err.initCause( iae ) ;
|
||||
throw err ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a field element within the given
|
||||
* object <code>o</code> at the given offset.
|
||||
* The result is undefined unless the offset was obtained from
|
||||
* {@link #objectFieldOffset} on the {@link java.lang.reflect.Field}
|
||||
* of some Java field and the object referred to by <code>o</code>
|
||||
* is of a class compatible with that field's class.
|
||||
* @param o Java heap object in which the field from which the offset
|
||||
* was obtained resides
|
||||
* @param offset indication of where the field resides in a Java heap
|
||||
* object
|
||||
* @return the value fetched from the indicated Java field
|
||||
* @throws RuntimeException No defined exceptions are thrown, not even
|
||||
* {@link NullPointerException}
|
||||
*/
|
||||
public final int getInt(Object o, long offset)
|
||||
{
|
||||
return unsafe.getInt( o, offset ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a value into a given Java field.
|
||||
* <p>
|
||||
* The first two parameters are interpreted exactly as with
|
||||
* {@link #getInt(Object, long)} to refer to a specific
|
||||
* Java field. The given value is stored into that field.
|
||||
* <p>
|
||||
* The field must be of the same type as the method
|
||||
* parameter <code>x</code>.
|
||||
*
|
||||
* @param o Java heap object in which the field resides, if any, else
|
||||
* null
|
||||
* @param offset indication of where the field resides in a Java heap
|
||||
* object.
|
||||
* @param x the value to store into the indicated Java field
|
||||
* @throws RuntimeException No defined exceptions are thrown, not even
|
||||
* {@link NullPointerException}
|
||||
*/
|
||||
public final void putInt(Object o, long offset, int x)
|
||||
{
|
||||
unsafe.putInt( o, offset, x ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getInt(Object, long)
|
||||
*/
|
||||
public final Object getObject(Object o, long offset)
|
||||
{
|
||||
return unsafe.getObject( o, offset ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #putInt(Object, long, int)
|
||||
*/
|
||||
public final void putObject(Object o, long offset, Object x)
|
||||
{
|
||||
unsafe.putObject( o, offset, x ) ;
|
||||
}
|
||||
|
||||
/** @see #getInt(Object, long) */
|
||||
public final boolean getBoolean(Object o, long offset)
|
||||
{
|
||||
return unsafe.getBoolean( o, offset ) ;
|
||||
}
|
||||
/** @see #putInt(Object, long, int) */
|
||||
public final void putBoolean(Object o, long offset, boolean x)
|
||||
{
|
||||
unsafe.putBoolean( o, offset, x ) ;
|
||||
}
|
||||
/** @see #getInt(Object, long) */
|
||||
public final byte getByte(Object o, long offset)
|
||||
{
|
||||
return unsafe.getByte( o, offset ) ;
|
||||
}
|
||||
/** @see #putInt(Object, long, int) */
|
||||
public final void putByte(Object o, long offset, byte x)
|
||||
{
|
||||
unsafe.putByte( o, offset, x ) ;
|
||||
}
|
||||
/** @see #getInt(Object, long) */
|
||||
public final short getShort(Object o, long offset)
|
||||
{
|
||||
return unsafe.getShort( o, offset ) ;
|
||||
}
|
||||
/** @see #putInt(Object, long, int) */
|
||||
public final void putShort(Object o, long offset, short x)
|
||||
{
|
||||
unsafe.putShort( o, offset, x ) ;
|
||||
}
|
||||
/** @see #getInt(Object, long) */
|
||||
public final char getChar(Object o, long offset)
|
||||
{
|
||||
return unsafe.getChar( o, offset ) ;
|
||||
}
|
||||
/** @see #putInt(Object, long, int) */
|
||||
public final void putChar(Object o, long offset, char x)
|
||||
{
|
||||
unsafe.putChar( o, offset, x ) ;
|
||||
}
|
||||
/** @see #getInt(Object, long) */
|
||||
public final long getLong(Object o, long offset)
|
||||
{
|
||||
return unsafe.getLong( o, offset ) ;
|
||||
}
|
||||
/** @see #putInt(Object, long, int) */
|
||||
public final void putLong(Object o, long offset, long x)
|
||||
{
|
||||
unsafe.putLong( o, offset, x ) ;
|
||||
}
|
||||
/** @see #getInt(Object, long) */
|
||||
public final float getFloat(Object o, long offset)
|
||||
{
|
||||
return unsafe.getFloat( o, offset ) ;
|
||||
}
|
||||
/** @see #putInt(Object, long, int) */
|
||||
public final void putFloat(Object o, long offset, float x)
|
||||
{
|
||||
unsafe.putFloat( o, offset, x ) ;
|
||||
}
|
||||
/** @see #getInt(Object, long) */
|
||||
public final double getDouble(Object o, long offset)
|
||||
{
|
||||
return unsafe.getDouble( o, offset ) ;
|
||||
}
|
||||
/** @see #putInt(Object, long, int) */
|
||||
public final void putDouble(Object o, long offset, double x)
|
||||
{
|
||||
unsafe.putDouble( o, offset, x ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constant differs from all results that will ever be returned from
|
||||
* {@link #objectFieldOffset}.
|
||||
*/
|
||||
public static final long INVALID_FIELD_OFFSET = -1;
|
||||
|
||||
/**
|
||||
* Returns the offset of a non-static field.
|
||||
*/
|
||||
public final long objectFieldOffset(Field f)
|
||||
{
|
||||
return unsafe.objectFieldOffset( f ) ;
|
||||
}
|
||||
|
||||
/** Throw the exception.
|
||||
* The exception may be an undeclared checked exception.
|
||||
*/
|
||||
public final void throwException(Throwable ee)
|
||||
{
|
||||
unsafe.throwException( ee ) ;
|
||||
}
|
||||
|
||||
/** Obtain a constructor for Class cl using constructor cons which
|
||||
* may be the constructor defined in a superclass of cl. This is
|
||||
* used to create a constructor for Serializable classes that
|
||||
* constructs an instance of the Serializable class using the
|
||||
* no args constructor of the first non-Serializable superclass
|
||||
* of the Serializable class.
|
||||
*/
|
||||
public final Constructor newConstructorForSerialization( Class cl,
|
||||
Constructor cons )
|
||||
{
|
||||
return reflectionFactory.newConstructorForSerialization( cl, cons ) ;
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/sun/corba/BridgePermission.java
Normal file
63
jdkSrc/jdk8/sun/corba/BridgePermission.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.corba;
|
||||
|
||||
import java.security.BasicPermission ;
|
||||
|
||||
/** Permission class used to protect access to the sun.corba.Bridge
|
||||
* object. The only name valid here is "getBridge". The
|
||||
* BridgePermission("getBridge") permission must be held by the
|
||||
* caller of sun.corba.Bridge.get().
|
||||
*/
|
||||
public final class BridgePermission extends BasicPermission
|
||||
{
|
||||
/**
|
||||
* Creates a new BridgePermission with the specified name.
|
||||
* The name is the symbolic name of the BridgePermission.
|
||||
* The only valid name here is "getBridge".
|
||||
*
|
||||
* @param name the name of the BridgePermission.
|
||||
*/
|
||||
public BridgePermission(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new BridgePermission object with the specified name.
|
||||
* The name is the symbolic name of the BridgePermission, and the
|
||||
* actions String is currently unused and should be null.
|
||||
* The only valid name here is "getBridge".
|
||||
*
|
||||
* @param name the name of the BridgePermission.
|
||||
* @param actions should be null.
|
||||
*/
|
||||
|
||||
public BridgePermission(String name, String actions)
|
||||
{
|
||||
super(name, actions);
|
||||
}
|
||||
}
|
||||
153
jdkSrc/jdk8/sun/corba/EncapsInputStreamFactory.java
Normal file
153
jdkSrc/jdk8/sun/corba/EncapsInputStreamFactory.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.corba;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
|
||||
import com.sun.corba.se.impl.encoding.EncapsInputStream;
|
||||
import com.sun.corba.se.impl.encoding.TypeCodeInputStream;
|
||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
|
||||
import com.sun.corba.se.pept.protocol.MessageMediator;
|
||||
import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
|
||||
import com.sun.corba.se.spi.orb.ORB;
|
||||
import com.sun.org.omg.SendingContext.CodeBase;
|
||||
|
||||
public class EncapsInputStreamFactory {
|
||||
|
||||
public static EncapsInputStream newEncapsInputStream(
|
||||
final org.omg.CORBA.ORB orb, final byte[] buf, final int size,
|
||||
final boolean littleEndian, final GIOPVersion version) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<EncapsInputStream>() {
|
||||
@Override
|
||||
public EncapsInputStream run() {
|
||||
return new EncapsInputStream(orb, buf, size,
|
||||
littleEndian, version);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsInputStream newEncapsInputStream(
|
||||
final org.omg.CORBA.ORB orb, final ByteBuffer byteBuffer,
|
||||
final int size, final boolean littleEndian,
|
||||
final GIOPVersion version) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<EncapsInputStream>() {
|
||||
@Override
|
||||
public EncapsInputStream run() {
|
||||
return new EncapsInputStream(orb, byteBuffer, size,
|
||||
littleEndian, version);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsInputStream newEncapsInputStream(
|
||||
final org.omg.CORBA.ORB orb, final byte[] data, final int size) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<EncapsInputStream>() {
|
||||
@Override
|
||||
public EncapsInputStream run() {
|
||||
return new EncapsInputStream(orb, data, size);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsInputStream newEncapsInputStream(
|
||||
final EncapsInputStream eis) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<EncapsInputStream>() {
|
||||
@Override
|
||||
public EncapsInputStream run() {
|
||||
return new EncapsInputStream(eis);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsInputStream newEncapsInputStream(
|
||||
final org.omg.CORBA.ORB orb, final byte[] data, final int size,
|
||||
final GIOPVersion version) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<EncapsInputStream>() {
|
||||
@Override
|
||||
public EncapsInputStream run() {
|
||||
return new EncapsInputStream(orb, data, size, version);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsInputStream newEncapsInputStream(
|
||||
final org.omg.CORBA.ORB orb, final byte[] data, final int size,
|
||||
final GIOPVersion version, final CodeBase codeBase) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<EncapsInputStream>() {
|
||||
@Override
|
||||
public EncapsInputStream run() {
|
||||
return new EncapsInputStream(orb, data, size, version,
|
||||
codeBase);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static TypeCodeInputStream newTypeCodeInputStream(
|
||||
final org.omg.CORBA.ORB orb, final byte[] buf, final int size,
|
||||
final boolean littleEndian, final GIOPVersion version) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<TypeCodeInputStream>() {
|
||||
@Override
|
||||
public TypeCodeInputStream run() {
|
||||
return new TypeCodeInputStream(orb, buf, size,
|
||||
littleEndian, version);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static TypeCodeInputStream newTypeCodeInputStream(
|
||||
final org.omg.CORBA.ORB orb, final ByteBuffer byteBuffer,
|
||||
final int size, final boolean littleEndian,
|
||||
final GIOPVersion version) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<TypeCodeInputStream>() {
|
||||
@Override
|
||||
public TypeCodeInputStream run() {
|
||||
return new TypeCodeInputStream(orb, byteBuffer, size,
|
||||
littleEndian, version);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static TypeCodeInputStream newTypeCodeInputStream(
|
||||
final org.omg.CORBA.ORB orb, final byte[] data, final int size) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<TypeCodeInputStream>() {
|
||||
@Override
|
||||
public TypeCodeInputStream run() {
|
||||
return new TypeCodeInputStream(orb, data, size);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
33
jdkSrc/jdk8/sun/corba/JavaCorbaAccess.java
Normal file
33
jdkSrc/jdk8/sun/corba/JavaCorbaAccess.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.corba;
|
||||
|
||||
import com.sun.corba.se.impl.io.ValueHandlerImpl;
|
||||
|
||||
public interface JavaCorbaAccess {
|
||||
public ValueHandlerImpl newValueHandlerImpl();
|
||||
public Class<?> loadClass(String className) throws ClassNotFoundException;
|
||||
}
|
||||
149
jdkSrc/jdk8/sun/corba/OutputStreamFactory.java
Normal file
149
jdkSrc/jdk8/sun/corba/OutputStreamFactory.java
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.corba;
|
||||
|
||||
import com.sun.corba.se.impl.corba.AnyImpl;
|
||||
import com.sun.corba.se.impl.encoding.BufferManagerWrite;
|
||||
import com.sun.corba.se.impl.encoding.CDROutputObject;
|
||||
import com.sun.corba.se.impl.encoding.EncapsOutputStream;
|
||||
import com.sun.corba.se.impl.encoding.TypeCodeOutputStream;
|
||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
|
||||
|
||||
import com.sun.corba.se.pept.protocol.MessageMediator;
|
||||
|
||||
import com.sun.corba.se.spi.orb.ORB;
|
||||
import com.sun.corba.se.spi.transport.CorbaConnection;
|
||||
import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
|
||||
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
public final class OutputStreamFactory {
|
||||
|
||||
private OutputStreamFactory() {
|
||||
}
|
||||
|
||||
public static TypeCodeOutputStream newTypeCodeOutputStream(
|
||||
final ORB orb) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<TypeCodeOutputStream>() {
|
||||
@Override
|
||||
public TypeCodeOutputStream run() {
|
||||
return new TypeCodeOutputStream(orb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static TypeCodeOutputStream newTypeCodeOutputStream(
|
||||
final ORB orb, final boolean littleEndian) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<TypeCodeOutputStream>() {
|
||||
@Override
|
||||
public TypeCodeOutputStream run() {
|
||||
return new TypeCodeOutputStream(orb, littleEndian);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsOutputStream newEncapsOutputStream(
|
||||
final ORB orb) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<EncapsOutputStream>() {
|
||||
@Override
|
||||
public EncapsOutputStream run() {
|
||||
return new EncapsOutputStream(
|
||||
(com.sun.corba.se.spi.orb.ORB)orb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsOutputStream newEncapsOutputStream(
|
||||
final ORB orb, final GIOPVersion giopVersion) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<EncapsOutputStream>() {
|
||||
@Override
|
||||
public EncapsOutputStream run() {
|
||||
return new EncapsOutputStream(
|
||||
(com.sun.corba.se.spi.orb.ORB)orb, giopVersion);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static EncapsOutputStream newEncapsOutputStream(
|
||||
final ORB orb, final boolean isLittleEndian) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<EncapsOutputStream>() {
|
||||
@Override
|
||||
public EncapsOutputStream run() {
|
||||
return new EncapsOutputStream(
|
||||
(com.sun.corba.se.spi.orb.ORB)orb, isLittleEndian);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static CDROutputObject newCDROutputObject(
|
||||
final ORB orb, final MessageMediator messageMediator,
|
||||
final Message header, final byte streamFormatVersion) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<CDROutputObject>() {
|
||||
@Override
|
||||
public CDROutputObject run() {
|
||||
return new CDROutputObject(orb, messageMediator,
|
||||
header, streamFormatVersion);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static CDROutputObject newCDROutputObject(
|
||||
final ORB orb, final MessageMediator messageMediator,
|
||||
final Message header, final byte streamFormatVersion,
|
||||
final int strategy) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<CDROutputObject>() {
|
||||
@Override
|
||||
public CDROutputObject run() {
|
||||
return new CDROutputObject(orb, messageMediator,
|
||||
header, streamFormatVersion, strategy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static CDROutputObject newCDROutputObject(
|
||||
final ORB orb, final CorbaMessageMediator mediator,
|
||||
final GIOPVersion giopVersion, final CorbaConnection connection,
|
||||
final Message header, final byte streamFormatVersion) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<CDROutputObject>() {
|
||||
@Override
|
||||
public CDROutputObject run() {
|
||||
return new CDROutputObject(orb, mediator,
|
||||
giopVersion, connection, header, streamFormatVersion);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
85
jdkSrc/jdk8/sun/corba/SharedSecrets.java
Normal file
85
jdkSrc/jdk8/sun/corba/SharedSecrets.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.corba;
|
||||
|
||||
import com.sun.corba.se.impl.io.ValueUtility;
|
||||
import sun.misc.JavaOISAccess;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/** A repository of "shared secrets", which are a mechanism for
|
||||
calling implementation-private methods in another package without
|
||||
using reflection. A package-private class implements a public
|
||||
interface and provides the ability to call package-private methods
|
||||
within that package; the object implementing that interface is
|
||||
provided through a third package to which access is restricted.
|
||||
This framework avoids the primary disadvantage of using reflection
|
||||
for this purpose, namely the loss of compile-time checking. */
|
||||
|
||||
// SharedSecrets cloned in corba repo to avoid build issues
|
||||
public class SharedSecrets {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static JavaCorbaAccess javaCorbaAccess;
|
||||
private static final Method getJavaOISAccessMethod;
|
||||
private static JavaOISAccess javaOISAccess;
|
||||
|
||||
// Initialize getJavaOISAccessMethod using reflection.
|
||||
static {
|
||||
try {
|
||||
Class sharedSecret = Class.forName("sun.misc.SharedSecrets");
|
||||
getJavaOISAccessMethod =
|
||||
sharedSecret.getMethod("getJavaOISAccess");
|
||||
} catch (Exception e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static JavaOISAccess getJavaOISAccess() {
|
||||
if (javaOISAccess == null) {
|
||||
try {
|
||||
javaOISAccess =
|
||||
(JavaOISAccess) getJavaOISAccessMethod.invoke(null);
|
||||
} catch (Exception e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
return javaOISAccess;
|
||||
}
|
||||
|
||||
public static JavaCorbaAccess getJavaCorbaAccess() {
|
||||
if (javaCorbaAccess == null) {
|
||||
// Ensure ValueUtility is initialized; we know that that class
|
||||
// provides the shared secret
|
||||
unsafe.ensureClassInitialized(ValueUtility.class);
|
||||
}
|
||||
return javaCorbaAccess;
|
||||
}
|
||||
|
||||
public static void setJavaCorbaAccess(JavaCorbaAccess access) {
|
||||
javaCorbaAccess = access;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user