The COM_Class_Type attribute marks a class as a Java-Callable Wrapper (JCW) or a Java-Callable Data Wrapper (JCDW). For JCWs, the CLSIDIndex field specifies the CLSID of the associated COM component. For JCDWs, the packing field defines the alignment requirement of the associated native structure.
Attribute Level | Generated By Directives |
Class | @com.struct @dll.struct @com.class |
COM_Class_Type_attribute { u2 attribute_name_index; u4 attribute_length; u2 Flags; u2 Classtype; union { u2 CLSIDIndex; { u1 packing; u1 reserved1; } jcdw; } }
The C structure MCClassType, declared in comattr.h, defines the layout of this attribute for use in C/C++ programs.
If the class type is MCCTCT_JCW, the access flags for the class must be a subset of ACC_PUBLIC, ACC_FINAL, or ACC_ABSTRACT.
If the class type is MCCTCT_JCDW, the access flags for the class must be a subset of ACC_PUBLIC or ACC_FINAL (required). The class's superclass must be java.lang.Object or a JCDW class.
If the class type is MCCTCT_JCDW, all fields defined by the class must have a COM_MapsTo attribute.
attribute_name_index
This value must be a valid index into the constant pool table. The constant pool entry at that index must be the CONSTANT_Utf8_info structure representing the string "COM_Class_Type".
attribute_length
This value indicates the length of this attribute, excluding the initial six bytes, and must be six.
Flags
CCTF_NODYNAMICIFCCASTS
This bit is used only for JCWs. If on, instances of this class can be legally cast only to interfaces explicitly implemented by either the instance's class or one of its ancestors. If off, instances of this class can be cast at runtime to any interface containing a methodpool item, provided that the underlying COM object returns a valid interface for the IID of the interface.
CCTF_CHARSIZEMASK
For JCWs, these bits must be zero. For JCDWs, these bits indicate ansi (CCTF_CHARSIZEANSI), unicode (CCTF_CHARSIZEUNICODE), or dual (CCTF_CHARSIZEDUAL) string and character array types.
ClassType
The only legal values are MCCTCT_JCW and MCCTCT_JCDW. The class type is determined as follows:
CLSIDIndex
If ClassType is not MCCTCT_JCW, CLSIDIndex must be 0xffff.
If the ClassType is MCCTCT_JCW and the CLSIDIndex is not 0xffff, CLSIDIndex must indicate a valid index into the GuidPool. The GUID corresponding to this index will be used as the CLSID of the COM object to load when an instance of this class is created using the "new" operator.
packing
When used in the context of the @com.struct directive, this value indicates the value of the pack= parameter in the directive, which may be set to 1, 2, 4 or 8. For backward compatibility, a value of 0xFF defaults to 4. This parameter indicates the packing alignment for structure members of this class (see "Padding and Alignment of Structure Members" in the MSDN Library for more information). For Java/COM, packing defaults to 8.
reserved1
When used in the context of the @com.struct directive, this value is reserved and must be set to 0xFF.