corba/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java
author coffeys
Mon, 08 Apr 2013 23:12:03 +0100
changeset 18304 56149cf29cf9
parent 16136 f5a39cbcd82f
permissions -rw-r--r--
8001032: Restrict object access Summary: Restrict object access; fix reviewed also by Alexander Fomin Reviewed-by: alanb, ahgross
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
18304
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
/*
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
 * Licensed Materials - Property of IBM
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
 * RMI-IIOP v1.0
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
 * Copyright IBM Corp. 1998 1999  All Rights Reserved
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
package com.sun.corba.se.impl.io;
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
import com.sun.org.omg.CORBA.ValueDefPackage.FullValueDescription;
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import com.sun.org.omg.CORBA.OperationDescription;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import com.sun.org.omg.CORBA.AttributeDescription;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import org.omg.CORBA.ValueMember;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
import com.sun.org.omg.CORBA.Initializer;
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import org.omg.CORBA.IDLType;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
import com.sun.org.omg.CORBA._IDLTypeStub;
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import org.omg.CORBA.ORB;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import org.omg.CORBA.TypeCodePackage.*;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
import org.omg.CORBA.TypeCode;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
import org.omg.CORBA.TCKind;
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import java.lang.reflect.*;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import com.sun.corba.se.impl.util.RepositoryId;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import java.util.*;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import javax.rmi.CORBA.Util;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
import javax.rmi.CORBA.ValueHandler;
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
 * Holds utility methods for converting from ObjectStreamClass to
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
 * FullValueDescription and generating typecodes from ObjectStreamClass.
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
 **/
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
public class ValueUtility {
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
    public static final short PRIVATE_MEMBER = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
    public static final short PUBLIC_MEMBER = 1;
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
    private static final String primitiveConstants[] = {
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
        null,       // tk_null         0
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
        null,           // tk_void         1
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
        "S",            // tk_short        2
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
        "I",            // tk_long         3
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
        "S",            // tk_ushort       4
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
        "I",            // tk_ulong        5
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
        "F",            // tk_float        6
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
        "D",            // tk_double       7
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
        "Z",            // tk_boolean      8
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
        "C",            // tk_char         9
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
        "B",            // tk_octet        10
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
        null,           // tk_any          11
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
        null,           // tk_typecode     12
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
        null,           // tk_principal    13
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
        null,           // tk_objref       14
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
        null,           // tk_struct       15
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
        null,           // tk_union        16
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
        null,           // tk_enum         17
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
        null,           // tk_string       18
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
        null,           // tk_sequence     19
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
        null,           // tk_array        20
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
        null,           // tk_alias        21
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
        null,           // tk_except       22
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
        "J",            // tk_longlong     23
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
        "J",            // tk_ulonglong    24
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
        "D",            // tk_longdouble   25
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
        "C",            // tk_wchar        26
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
        null,           // tk_wstring      27
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
        null,       // tk_fixed        28
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
        null,       // tk_value        29
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
        null,       // tk_value_box    30
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
        null,       // tk_native       31
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
        null,       // tk_abstract_interface 32
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
    };
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
16136
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
    96
    static {
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
    97
        sun.corba.SharedSecrets.setJavaCorbaAccess(new sun.corba.JavaCorbaAccess() {
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
    98
            public ValueHandlerImpl newValueHandlerImpl() {
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
    99
                return ValueHandlerImpl.getInstance();
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
   100
            }
18304
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   101
            public Class<?> loadClass(String className) throws ClassNotFoundException {
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   102
                if (Thread.currentThread().getContextClassLoader() != null) {
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   103
                    return Thread.currentThread().getContextClassLoader().
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   104
                        loadClass(className);
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   105
                } else {
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   106
                    return ClassLoader.getSystemClassLoader().loadClass(className);
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   107
                }
56149cf29cf9 8001032: Restrict object access
coffeys
parents: 16136
diff changeset
   108
            }
16136
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
   109
        });
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
   110
    }
f5a39cbcd82f 8000631: Restrict access to class constructor
coffeys
parents: 5555
diff changeset
   111
4
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
    public static String getSignature(ValueMember member)
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
        throws ClassNotFoundException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
        // REVISIT.  Can the type be something that is
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
        // non-primitive yet not a value_box, value, or objref?
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
        // If so, should use ObjectStreamClass or throw
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
        // exception.
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
        if (member.type.kind().value() == TCKind._tk_value_box ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
            member.type.kind().value() == TCKind._tk_value ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
            member.type.kind().value() == TCKind._tk_objref) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
            Class c = RepositoryId.cache.getId(member.id).getClassFromType();
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
            return ObjectStreamClass.getSignature(c);
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
            return primitiveConstants[member.type.kind().value()];
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
    public static FullValueDescription translate(ORB orb, ObjectStreamClass osc, ValueHandler vh){
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
        // Create FullValueDescription
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
        FullValueDescription result = new FullValueDescription();
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
        Class className = osc.forClass();
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
        ValueHandlerImpl vhandler = (com.sun.corba.se.impl.io.ValueHandlerImpl) vh;
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
        String repId = vhandler.createForAnyType(className);
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
        // Set FVD name
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
        result.name = vhandler.getUnqualifiedName(repId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
        if (result.name == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
            result.name = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
        // Set FVD id _REVISIT_ : Manglings
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
        result.id = vhandler.getRMIRepositoryID(className);
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
        if (result.id == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
            result.id = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
        // Set FVD is_abstract
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
        result.is_abstract = ObjectStreamClassCorbaExt.isAbstractInterface(className);
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
        // Set FVD is_custom
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
        result.is_custom = osc.hasWriteObject() || osc.isExternalizable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
        // Set FVD defined_in _REVISIT_ : Manglings
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
        result.defined_in = vhandler.getDefinedInId(repId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
        if (result.defined_in == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
            result.defined_in = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
        // Set FVD version
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
        result.version = vhandler.getSerialVersionUID(repId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
        if (result.version == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
            result.version = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
        // Skip FVD operations - N/A
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
        result.operations = new OperationDescription[0];
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
        // Skip FVD attributed - N/A
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
        result.attributes = new AttributeDescription[0];
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
        // Set FVD members
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
        // Maps classes to repositoryIDs strings. This is used to detect recursive types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
        IdentityKeyValueStack createdIDs = new IdentityKeyValueStack();
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
        // Stores all types created for resolving indirect types at the end.
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
        result.members = translateMembers(orb, osc, vh, createdIDs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
        // Skip FVD initializers - N/A
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
        result.initializers = new Initializer[0];
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
        Class interfaces[] = osc.forClass().getInterfaces();
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
        int abstractCount = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
        // Skip FVD supported_interfaces
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
        result.supported_interfaces =  new String[interfaces.length];
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
        for (int interfaceIndex = 0; interfaceIndex < interfaces.length;
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
             interfaceIndex++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
            result.supported_interfaces[interfaceIndex] =
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
                vhandler.createForAnyType(interfaces[interfaceIndex]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
            if ((!(java.rmi.Remote.class.isAssignableFrom(interfaces[interfaceIndex]))) ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
                (!Modifier.isPublic(interfaces[interfaceIndex].getModifiers())))
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
                abstractCount++;
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
        // Skip FVD abstract_base_values - N/A
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
        result.abstract_base_values = new String[abstractCount];
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
        for (int interfaceIndex = 0; interfaceIndex < interfaces.length;
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
             interfaceIndex++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
            if ((!(java.rmi.Remote.class.isAssignableFrom(interfaces[interfaceIndex]))) ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
                (!Modifier.isPublic(interfaces[interfaceIndex].getModifiers())))
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
                result.abstract_base_values[interfaceIndex] =
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
                    vhandler.createForAnyType(interfaces[interfaceIndex]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
        result.is_truncatable = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
        // Set FVD base_value
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
        Class superClass = osc.forClass().getSuperclass();
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
        if (java.io.Serializable.class.isAssignableFrom(superClass))
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
            result.base_value = vhandler.getRMIRepositoryID(superClass);
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
            result.base_value = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
        // Set FVD type
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
        //result.type = createTypeCodeForClass(orb, osc.forClass());
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
        result.type = orb.get_primitive_tc(TCKind.tk_value); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
        return result;
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
    private static ValueMember[] translateMembers (ORB orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
                                                   ObjectStreamClass osc,
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
                                                   ValueHandler vh,
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
                                                   IdentityKeyValueStack createdIDs)
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
        ValueHandlerImpl vhandler = (com.sun.corba.se.impl.io.ValueHandlerImpl) vh;
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
        ObjectStreamField fields[] = osc.getFields();
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
        int fieldsLength = fields.length;
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
        ValueMember[] members = new ValueMember[fieldsLength];
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
        // Note : fields come out of ObjectStreamClass in correct order for
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
        // writing.  So, we will create the same order in the members array.
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
        for (int i = 0; i < fieldsLength; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
            String valRepId = vhandler.getRMIRepositoryID(fields[i].getClazz());
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
            members[i] = new ValueMember();
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
            members[i].name = fields[i].getName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
            members[i].id = valRepId; // _REVISIT_ : Manglings
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
            members[i].defined_in = vhandler.getDefinedInId(valRepId);// _REVISIT_ : Manglings
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
            members[i].version = "1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
            members[i].type_def = new _IDLTypeStub(); // _REVISIT_ : IDLType implementation missing
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
            if (fields[i].getField() == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
                // When using serialPersistentFields, the class may
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
                // no longer have an actual Field that corresponds
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
                // to one of the items.  The Java to IDL spec
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
                // ptc-00-01-06 1.3.5.6 says that the IDL field
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
                // should be private in this case.
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
                members[i].access = PRIVATE_MEMBER;
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
                int m = fields[i].getField().getModifiers();
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
                if (Modifier.isPublic(m))
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
                    members[i].access = PUBLIC_MEMBER;
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
                else
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
                    members[i].access = PRIVATE_MEMBER;
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
            switch (fields[i].getTypeCode()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
            case 'B':
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
                members[i].type = orb.get_primitive_tc(TCKind.tk_octet); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
            case 'C':
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
                members[i].type
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
                    = orb.get_primitive_tc(vhandler.getJavaCharTCKind()); // 11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
            case 'F':
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
                members[i].type = orb.get_primitive_tc(TCKind.tk_float); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
            case 'D' :
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
                members[i].type = orb.get_primitive_tc(TCKind.tk_double); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
            case 'I':
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
                members[i].type = orb.get_primitive_tc(TCKind.tk_long); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
            case 'J':
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
                members[i].type = orb.get_primitive_tc(TCKind.tk_longlong); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
            case 'S':
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
                members[i].type = orb.get_primitive_tc(TCKind.tk_short); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
            case 'Z':
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
                members[i].type = orb.get_primitive_tc(TCKind.tk_boolean); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
        // case '[':
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
        //      members[i].type = orb.get_primitive_tc(TCKind.tk_value_box); //11638
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
        //      members[i].id = RepositoryId.createForAnyType(fields[i].getType());
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
        //      break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
            default:
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
                members[i].type = createTypeCodeForClassInternal(orb, fields[i].getClazz(), vhandler,
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
                                  createdIDs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
                members[i].id = vhandler.createForAnyType(fields[i].getType());
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
                break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
            } // end switch
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
        } // end for loop
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
        return members;
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
    private static boolean exists(String str, String strs[]){
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
        for (int i = 0; i < strs.length; i++)
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
            if (str.equals(strs[i]))
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
                return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
        return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
    public static boolean isAssignableFrom(String clzRepositoryId, FullValueDescription type,
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
                                           com.sun.org.omg.SendingContext.CodeBase sender){
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
        if (exists(clzRepositoryId, type.supported_interfaces))
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
            return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
        if (clzRepositoryId.equals(type.id))
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
            return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
        if ((type.base_value != null) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
            (!type.base_value.equals(""))) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
            FullValueDescription parent = sender.meta(type.base_value);
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
            return isAssignableFrom(clzRepositoryId, parent, sender);
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
        return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
    public static TypeCode createTypeCodeForClass (ORB orb, java.lang.Class c, ValueHandler vh) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
        // Maps classes to repositoryIDs strings. This is used to detect recursive types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
        IdentityKeyValueStack createdIDs = new IdentityKeyValueStack();
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
        // Stores all types created for resolving indirect types at the end.
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
        TypeCode tc = createTypeCodeForClassInternal(orb, c, vh, createdIDs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
        return tc;
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
    private static TypeCode createTypeCodeForClassInternal (ORB orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
                                                            java.lang.Class c,
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
                                                            ValueHandler vh,
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
                                                            IdentityKeyValueStack createdIDs)
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
        // This wrapper method is the protection against infinite recursion.
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
        TypeCode tc = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
        String id = (String)createdIDs.get(c);
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
        if (id != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
            return orb.create_recursive_tc(id);
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
            id = vh.getRMIRepositoryID(c);
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
            if (id == null) id = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
            // cache the rep id BEFORE creating a new typecode.
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
            // so that recursive tc can look up the rep id.
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
            createdIDs.push(c, id);
02bb8761fcce Initial load
duke
parents:
diff changeset
   355
            tc = createTypeCodeInternal(orb, c, vh, id, createdIDs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   356
            createdIDs.pop();
02bb8761fcce Initial load
duke
parents:
diff changeset
   357
            return tc;
02bb8761fcce Initial load
duke
parents:
diff changeset
   358
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   359
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   360
02bb8761fcce Initial load
duke
parents:
diff changeset
   361
    // Maintains a stack of key-value pairs. Compares elements using == operator.
02bb8761fcce Initial load
duke
parents:
diff changeset
   362
    private static class IdentityKeyValueStack {
02bb8761fcce Initial load
duke
parents:
diff changeset
   363
        private static class KeyValuePair {
02bb8761fcce Initial load
duke
parents:
diff changeset
   364
            Object key;
02bb8761fcce Initial load
duke
parents:
diff changeset
   365
            Object value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   366
            KeyValuePair(Object key, Object value) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   367
                this.key = key;
02bb8761fcce Initial load
duke
parents:
diff changeset
   368
                this.value = value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   369
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   370
            boolean equals(KeyValuePair pair) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   371
                return pair.key == this.key;
02bb8761fcce Initial load
duke
parents:
diff changeset
   372
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   373
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   374
02bb8761fcce Initial load
duke
parents:
diff changeset
   375
        Stack pairs = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   376
02bb8761fcce Initial load
duke
parents:
diff changeset
   377
        Object get(Object key) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   378
            if (pairs == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   379
                return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   380
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   381
            for (Iterator i = pairs.iterator(); i.hasNext();) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   382
                KeyValuePair pair = (KeyValuePair)i.next();
02bb8761fcce Initial load
duke
parents:
diff changeset
   383
                if (pair.key == key) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   384
                    return pair.value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   385
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   386
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   387
            return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   388
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   389
02bb8761fcce Initial load
duke
parents:
diff changeset
   390
        void push(Object key, Object value) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   391
            if (pairs == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   392
                pairs = new Stack();
02bb8761fcce Initial load
duke
parents:
diff changeset
   393
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   394
            pairs.push(new KeyValuePair(key, value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   395
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   396
02bb8761fcce Initial load
duke
parents:
diff changeset
   397
        void pop() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   398
            pairs.pop();
02bb8761fcce Initial load
duke
parents:
diff changeset
   399
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   400
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   401
02bb8761fcce Initial load
duke
parents:
diff changeset
   402
    private static TypeCode createTypeCodeInternal (ORB orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   403
                                                    java.lang.Class c,
02bb8761fcce Initial load
duke
parents:
diff changeset
   404
                                                    ValueHandler vh,
02bb8761fcce Initial load
duke
parents:
diff changeset
   405
                                                    String id,
02bb8761fcce Initial load
duke
parents:
diff changeset
   406
                                                    IdentityKeyValueStack createdIDs)
02bb8761fcce Initial load
duke
parents:
diff changeset
   407
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   408
        if ( c.isArray() ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   409
            // Arrays - may recurse for multi-dimensional arrays
02bb8761fcce Initial load
duke
parents:
diff changeset
   410
            Class componentClass = c.getComponentType();
02bb8761fcce Initial load
duke
parents:
diff changeset
   411
            TypeCode embeddedType;
02bb8761fcce Initial load
duke
parents:
diff changeset
   412
            if ( componentClass.isPrimitive() ){
02bb8761fcce Initial load
duke
parents:
diff changeset
   413
                embeddedType
02bb8761fcce Initial load
duke
parents:
diff changeset
   414
                    = ValueUtility.getPrimitiveTypeCodeForClass(orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   415
                                                                componentClass,
02bb8761fcce Initial load
duke
parents:
diff changeset
   416
                                                                vh);
02bb8761fcce Initial load
duke
parents:
diff changeset
   417
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   418
                embeddedType = createTypeCodeForClassInternal(orb, componentClass, vh,
02bb8761fcce Initial load
duke
parents:
diff changeset
   419
                                                              createdIDs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   420
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   421
            TypeCode t = orb.create_sequence_tc (0, embeddedType);
02bb8761fcce Initial load
duke
parents:
diff changeset
   422
            return orb.create_value_box_tc (id, "Sequence", t);
02bb8761fcce Initial load
duke
parents:
diff changeset
   423
        } else if ( c == java.lang.String.class ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   424
            // Strings
02bb8761fcce Initial load
duke
parents:
diff changeset
   425
            TypeCode t = orb.create_string_tc (0);
02bb8761fcce Initial load
duke
parents:
diff changeset
   426
            return orb.create_value_box_tc (id, "StringValue", t);
02bb8761fcce Initial load
duke
parents:
diff changeset
   427
        } else if (java.rmi.Remote.class.isAssignableFrom(c)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   428
            return orb.get_primitive_tc(TCKind.tk_objref);
02bb8761fcce Initial load
duke
parents:
diff changeset
   429
        } else if (org.omg.CORBA.Object.class.isAssignableFrom(c)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   430
            return orb.get_primitive_tc(TCKind.tk_objref);
02bb8761fcce Initial load
duke
parents:
diff changeset
   431
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   432
02bb8761fcce Initial load
duke
parents:
diff changeset
   433
        // Anything else
02bb8761fcce Initial load
duke
parents:
diff changeset
   434
02bb8761fcce Initial load
duke
parents:
diff changeset
   435
        ObjectStreamClass osc = ObjectStreamClass.lookup(c);
02bb8761fcce Initial load
duke
parents:
diff changeset
   436
02bb8761fcce Initial load
duke
parents:
diff changeset
   437
        if (osc == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   438
            return orb.create_value_box_tc (id, "Value", orb.get_primitive_tc (TCKind.tk_value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   439
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   440
02bb8761fcce Initial load
duke
parents:
diff changeset
   441
        // type modifier
02bb8761fcce Initial load
duke
parents:
diff changeset
   442
        // REVISIT truncatable and abstract?
02bb8761fcce Initial load
duke
parents:
diff changeset
   443
        short modifier = (osc.isCustomMarshaled() ? org.omg.CORBA.VM_CUSTOM.value : org.omg.CORBA.VM_NONE.value);
02bb8761fcce Initial load
duke
parents:
diff changeset
   444
02bb8761fcce Initial load
duke
parents:
diff changeset
   445
        // concrete base
02bb8761fcce Initial load
duke
parents:
diff changeset
   446
        TypeCode base = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   447
        Class superClass = c.getSuperclass();
02bb8761fcce Initial load
duke
parents:
diff changeset
   448
        if (superClass != null && java.io.Serializable.class.isAssignableFrom(superClass)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   449
            base = createTypeCodeForClassInternal(orb, superClass, vh, createdIDs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   450
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   451
02bb8761fcce Initial load
duke
parents:
diff changeset
   452
        // members
02bb8761fcce Initial load
duke
parents:
diff changeset
   453
        ValueMember[] members = translateMembers (orb, osc, vh, createdIDs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   454
02bb8761fcce Initial load
duke
parents:
diff changeset
   455
        return orb.create_value_tc(id, c.getName(), modifier, base, members);
02bb8761fcce Initial load
duke
parents:
diff changeset
   456
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   457
02bb8761fcce Initial load
duke
parents:
diff changeset
   458
    public static TypeCode getPrimitiveTypeCodeForClass (ORB orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   459
                                                         Class c,
02bb8761fcce Initial load
duke
parents:
diff changeset
   460
                                                         ValueHandler vh) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   461
02bb8761fcce Initial load
duke
parents:
diff changeset
   462
        if (c == Integer.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   463
            return orb.get_primitive_tc (TCKind.tk_long);
02bb8761fcce Initial load
duke
parents:
diff changeset
   464
        } else if (c == Byte.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   465
            return orb.get_primitive_tc (TCKind.tk_octet);
02bb8761fcce Initial load
duke
parents:
diff changeset
   466
        } else if (c == Long.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   467
            return orb.get_primitive_tc (TCKind.tk_longlong);
02bb8761fcce Initial load
duke
parents:
diff changeset
   468
        } else if (c == Float.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   469
            return orb.get_primitive_tc (TCKind.tk_float);
02bb8761fcce Initial load
duke
parents:
diff changeset
   470
        } else if (c == Double.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   471
            return orb.get_primitive_tc (TCKind.tk_double);
02bb8761fcce Initial load
duke
parents:
diff changeset
   472
        } else if (c == Short.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   473
            return orb.get_primitive_tc (TCKind.tk_short);
02bb8761fcce Initial load
duke
parents:
diff changeset
   474
        } else if (c == Character.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   475
            return orb.get_primitive_tc (((ValueHandlerImpl)vh).getJavaCharTCKind());
02bb8761fcce Initial load
duke
parents:
diff changeset
   476
        } else if (c == Boolean.TYPE) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   477
            return orb.get_primitive_tc (TCKind.tk_boolean);
02bb8761fcce Initial load
duke
parents:
diff changeset
   478
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   479
            // _REVISIT_ Not sure if this is right.
02bb8761fcce Initial load
duke
parents:
diff changeset
   480
            return orb.get_primitive_tc (TCKind.tk_any);
02bb8761fcce Initial load
duke
parents:
diff changeset
   481
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   482
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   483
}