/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
/**
* Section 1.2 of The Java Language to IDL Mapping. Note that
* these are static checks only. Runtime checks, such as those
* described in Section 1.2.3, #3, are not covered.
*/
public final class IDLTypesUtil {
/* rmic -iiop does not correctly implement the clause in 1.3.4.3
* about is<NAME>/get<NAME> conflicts. The spec says that
* is<NAME> is the property and get<NAME> is left alone,
* but rmic does the opposite. We will follow rmic in this,
* but it's easy to change.
*/
public static final boolean FOLLOW_RMIC = true ;
/**
* Validate a class to ensure it conforms to the rules for a
*
*/
{
if( c == null ) {
throw new IllegalArgumentException();
}
if( !c.isInterface() ) {
throw new IDLTypeException(msg);
}
"either directly or indirectly.";
throw new IDLTypeException(msg);
}
// Get all methods, including super-interface methods.
}
// Removed because of bug 4989053
// validateDirectInterfaces(c);
return;
}
{
boolean remoteInterface = true;
try {
} catch(IDLTypeException ite) {
remoteInterface = false;
}
return remoteInterface;
}
/**
* Section 1.2.2 Primitive Types
*/
{
if( c == null ) {
throw new IllegalArgumentException();
}
return c.isPrimitive();
}
/**
* Section 1.2.4
*/
{
if( c == null ) {
throw new IllegalArgumentException();
}
return
(!c.isInterface() &&
}
/**
* Section 1.2.5
*/
{
boolean arrayType = false;
if( c == null ) {
throw new IllegalArgumentException();
}
if( c.isArray() ) {
}
return arrayType;
}
/**
* Section 1.2.6
*/
{
if( c == null ) {
throw new IllegalArgumentException();
}
// Must be a checked exception, not including RemoteException or
// its subclasses.
}
{
if( c == null ) {
throw new IllegalArgumentException();
}
}
{
if( c == null ) {
throw new IllegalArgumentException();
}
return Throwable.class.isAssignableFrom(c) &&
!RuntimeException.class.isAssignableFrom(c) &&
!Error.class.isAssignableFrom(c) ;
}
/**
* Section 1.2.7
*/
{
if( c == null ) {
throw new IllegalArgumentException();
}
return (c.isInterface() &&
}
/**
* Section 1.2.8
*/
{
if( c == null ) {
throw new IllegalArgumentException();
}
return (!c.isInterface() &&
(superClass != null) &&
}
/**
* Return true if given method is legal property accessor as defined in
* Section 1.3.4.3 of Java2IDL spec.
*/
!readHasCorrespondingIsProperty(m, c)) {
}
if (hasCorrespondingReadProperty(m, c, GET_PROPERTY_PREFIX) ||
}
}
!isHasCorrespondingReadProperty(m, c)) {
}
}
// Some final checks that apply to all properties.
if( propertyType != null ) {
if(!validPropertyExceptions(m) ||
propertyType = null;
}
}
return (propertyType != null);
}
private boolean hasCorrespondingReadProperty
{
boolean foundReadProperty = false;
try {
// Look for a valid corresponding Read property
new Class[] {});
writePropertyParameters[0]) );
} catch(Exception e) {
// ignore. this means we didn't find a corresponding get property.
}
return foundReadProperty;
}
Class c)
{
if (FOLLOW_RMIC)
return false ;
boolean foundIsProperty = false;
try {
// Look for a valid corresponding Is property
new Class[] {});
c) ;
} catch(Exception e) {
// ignore. this means we didn't find a corresponding Is property.
}
return foundIsProperty;
}
Class c)
{
if (!FOLLOW_RMIC)
return false ;
boolean foundIsProperty = false;
try {
// Look for a valid corresponding Read property
new Class[] {});
c) ;
} catch(Exception e) {
// ignore. this means we didn't find a corresponding read property.
}
return foundIsProperty;
}
}
// don't set the first letter to lower-case if the
// first two are upper-case
} else {
}
}
return attributeName;
}
/**
* Return IDL Type name for primitive types as defined in
* Section 1.3.3 of Java2IDL spec or null if not a primitive type.
*/
if( c == null ) {
throw new IllegalArgumentException();
}
if( c.isPrimitive() ) {
return new IDLType( c, "void" ) ;
return new IDLType( c, "boolean" ) ;
return new IDLType( c, "wchar" ) ;
return new IDLType( c, "octet" ) ;
return new IDLType( c, "short" ) ;
return new IDLType( c, "long" ) ;
return new IDLType( c, "long_long" ) ;
return new IDLType( c, "float" ) ;
return new IDLType( c, "double" ) ;
}
}
return null;
}
/**
* Return IDL Type name for special case type mappings as defined in
* Table 1-1 of Java2IDL spec or null if given class is not a special
* type.
*/
if( c == null ) {
throw new IllegalArgumentException();
}
"Object" ) ;
"WStringValue" ) ;
"ClassDesc" ) ;
"Serializable" ) ;
"Externalizable" ) ;
"Remote" ) ;
return new IDLType( c, "Object" ) ;
} else {
return null;
}
}
/**
* Implements 1.2.3 #2 and #4
*/
boolean declaresRemoteExceptionOrSuperClass = false;
// Section 1.2.3, #2
if( isRemoteExceptionOrSuperClass(exception) ) {
break;
}
}
if( !declaresRemoteExceptionOrSuperClass ) {
"exception of type java.rmi.RemoteException or one of its " +
"super-classes";
throw new IDLTypeException(msg);
}
// Section 1.2.3, #4
// See also bug 4972402
// For all exceptions E in exceptions,
// (isCheckedException(E) => (isValue(E) || RemoteException.isAssignableFrom( E ) )
{
throw new IDLTypeException(msg);
}
}
return;
}
/**
* Returns true if the method's throw clause conforms to the exception
* restrictions for properties as defined in Section 1.3.4.3 of
* Java2IDL spec. This means that for all exceptions E declared on the
* method, E isChecked => RemoteException.isAssignableFrom( E ).
*/
{
return false ;
}
return true;
}
/**
* Implements Section 1.2.3, #2.
*/
return
}
/**
* Implements Section 1.2.3, #5.
*/
return;
}
// Comparison is based on method names only. First collect
// all methods from current interface, eliminating duplicate
// names.
}
// Now check each method against list of all unique method
// names processed so far.
methodName + " from multiple direct interfaces.";
throw new IDLTypeException(msg);
} else {
}
}
}
return;
}
/**
* Implements 1.2.3 #6
*/
throws IDLTypeException {
try {
return c.getFields();
}
});
throw ite;
}
!isPrimitive(fieldType) ) {
" types and java.lang.String types.";
throw new IDLTypeException(msg);
}
}
return;
}
}