本文整理汇总了Java中com.sun.jdi.ReferenceType.signature方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceType.signature方法的具体用法?Java ReferenceType.signature怎么用?Java ReferenceType.signature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.ReferenceType
的用法示例。
在下文中一共展示了ReferenceType.signature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateAssignment
import com.sun.jdi.ReferenceType; //导入方法依赖的package包/类
void validateAssignment(ValueContainer destination)
throws InvalidTypeException, ClassNotLoadedException {
/*
* Do these simpler checks before attempting a query of the destination's
* type which might cause a confusing ClassNotLoadedException if
* the destination is primitive or an array.
*/
/*
* TO DO: Centralize JNI signature knowledge
*/
if (destination.signature().length() == 1) {
throw new InvalidTypeException("Can't assign object value to primitive");
}
if ((destination.signature().charAt(0) == '[') &&
(type().signature().charAt(0) != '[')) {
throw new InvalidTypeException("Can't assign non-array value to an array");
}
if ("void".equals(destination.typeName())) {
throw new InvalidTypeException("Can't assign object value to a void");
}
// Validate assignment
ReferenceType destType = (ReferenceTypeImpl)destination.type();
ReferenceTypeImpl myType = (ReferenceTypeImpl)referenceType();
if (!myType.isAssignableTo(destType)) {
JNITypeParser parser = new JNITypeParser(destType.signature());
String destTypeName = parser.typeName();
throw new InvalidTypeException("Can't assign " +
type().name() +
" to " + destTypeName);
}
}
示例2: getGenericName
import com.sun.jdi.ReferenceType; //导入方法依赖的package包/类
private String getGenericName(ReferenceType type) throws DebugException {
if (type instanceof ArrayType) {
try {
Type componentType;
componentType = ((ArrayType) type).componentType();
if (componentType instanceof ReferenceType) {
return getGenericName((ReferenceType) componentType) + "[]"; //$NON-NLS-1$
}
return type.name();
} catch (ClassNotLoadedException e) {
// we cannot create the generic name using the component type,
// just try to create one with the information
}
}
String signature = type.signature();
StringBuffer res = new StringBuffer(getTypeName(signature));
String genericSignature = type.genericSignature();
if (genericSignature != null) {
String[] typeParameters = Signature.getTypeParameters(genericSignature);
if (typeParameters.length > 0) {
res.append('<').append(Signature.getTypeVariable(typeParameters[0]));
for (int i = 1; i < typeParameters.length; i++) {
res.append(',').append(Signature.getTypeVariable(typeParameters[i]));
}
res.append('>');
}
}
return res.toString();
}