private IllegalArgumentException invalidConversion (TypeDesc from, TypeDesc to) { throw new IllegalArgumentException ("Invalid conversion: " + from.getFullName() + " to " + to.getFullName()); }
if (type == null || type.toClass() != clazz) { if (clazz.isArray()) { type = forClass(clazz.getComponentType()).toArrayType(); } else if (clazz.isPrimitive()) { if (clazz == int.class) { type = intern(new ObjectType(generateDescriptor(name), name)); if (type.toClass() != clazz) { type = new ObjectType(type.getDescriptor(), clazz.getName()); ((ObjectType) type).setClass(clazz);
public ConstantClassInfo(ConstantUTFInfo nameConstant) { super(TAG_CLASS); String name = nameConstant.getValue(); if (!name.endsWith(";") && !name.startsWith("[")) { mType = TypeDesc.forClass(name); } else { mType = TypeDesc.forDescriptor(name); } mNameConstant = nameConstant; }
/** * Returns an annotation descriptor that has no parameters. */ public static String makePlainDescriptor(Class<? extends Annotation> annotationType) { return "" + TAG_ANNOTATION + TypeDesc.forClass(annotationType).getDescriptor(); }
public TypeDesc getRootComponentType() { TypeDesc type = mComponent; while (type.isArray()) { type = type.getComponentType(); } return type; }
ArrayType(String desc, TypeDesc component) { super(desc, component.getRootName()); mComponent = component; mFullName = component.getFullName().concat("[]"); }
if (fromType.isPrimitive()) { toType = fromType.toObjectType(); } else { return; TypeDesc fromPrimitiveType = fromType.toPrimitiveType(); if (fromPrimitiveType == null) { if (!toType.isPrimitive()) { Class fromClass = fromType.toClass(); if (fromClass != null) { Class toClass = toType.toClass(); if (toClass != null && toClass.isAssignableFrom(fromClass)) { return; int fromTypeCode = fromPrimitiveType.getTypeCode(); if (toType.toClass() == Number.class) { switch (fromTypeCode) { case TypeDesc.INT_CODE: case TypeDesc.FLOAT_CODE: case TypeDesc.DOUBLE_CODE: if (fromType.isPrimitive()) { toType = fromType.toObjectType(); } else { return; TypeDesc toPrimitiveType = toType.toPrimitiveType(); if (toPrimitiveType == null) {
private void print(TypeDesc type) { if (type == null || type == TypeDesc.VOID) { print("null"); return; } if (type.isPrimitive()) { print("TypeDesc.".concat(type.getFullName().toUpperCase())); return; } else if (type == TypeDesc.OBJECT) { print("TypeDesc.OBJECT"); return; } else if (type == TypeDesc.STRING) { print("TypeDesc.STRING"); return; } TypeDesc componentType = type.getComponentType(); if (componentType != null) { print(componentType); print(".toArrayType()"); } else { print("TypeDesc.forClass(\""); print(escape(type.getRootName())); print("\")"); } }
private String getClassName(TypeDesc classDesc) throws IllegalArgumentException { if (classDesc.isPrimitive()) { throw new IllegalArgumentException("Primitive type not allowed"); } if (classDesc.isArray()) { throw new IllegalArgumentException("Array type not allowed"); } return classDesc.getRootName(); }
public ConstantClassInfo(ConstantPool cp, TypeDesc type) { super(TAG_CLASS); String desc; if (type.isArray()) { desc = type.getDescriptor(); } else { desc = type.getRootName().replace('.', '/'); } mType = type; mNameConstant = cp.addConstantUTF(desc); }
throw invalidName(name); if (index2 >= 0) { if (index2 + 1 != name.length() || index1 + 1 != index2) { throw invalidName(name); type = forClass(name.substring(0, index1)).toArrayType(); } catch (IllegalArgumentException e) { throw invalidName(name); throw invalidName(name); } else { setType: { String desc = generateDescriptor(name); if (name.indexOf('/') < 0) { type = new ObjectType(desc, name); type = new ObjectType(desc, name.replace('/', '.')); type = intern(type);
/** * Used to describe an array class. */ public ConstantClassInfo(ConstantPool cp, String className, int dim) { super(TAG_CLASS); TypeDesc type = TypeDesc.forClass(className); String desc; if (dim > 0) { while (--dim >= 0) { type = type.toArrayType(); } desc = type.getDescriptor(); } else { desc = className.replace('.', '/'); } mType = type; mNameConstant = cp.addConstantUTF(desc); }
private static void addValueHashCodeCallTo(CodeBuilder b, TypeDesc valueType) { if (valueType.isArray()) { if (!valueType.getComponentType().isPrimitive()) { b.invokeStatic("java.util.Arrays", "deepHashCode", TypeDesc.INT, new TypeDesc[] {TypeDesc.forClass(Object[].class)}); } else { b.invokeStatic("java.util.Arrays", "hashCode", TypeDesc.INT, new TypeDesc[] {valueType}); } } else { b.invokeVirtual(TypeDesc.OBJECT, "hashCode", TypeDesc.INT, null); } }
/** * Returns this in Java method signature syntax. * * @param name method name * @param varargs request that the last argument, if it is an array, to * be formatted in varargs syntax. */ public String toMethodSignature(String name, boolean varargs) { StringBuffer buf = new StringBuffer(); buf.append(mRetType.getFullName()); buf.append(' '); buf.append(name); buf.append('('); TypeDesc[] params = mParams; for (int i=0; i<params.length; i++) { if (i > 0) { buf.append(", "); } TypeDesc param = params[i]; if (varargs && param.isArray() && i == (params.length - 1)) { buf.append(param.getComponentType().getFullName()); buf.append("..."); } else { buf.append(param.getFullName()); } } return buf.append(')').toString(); }
public void loadConstant(TypeDesc type) throws IllegalStateException { if (type == null) { loadNull(); return; } if (type.isPrimitive()) { if (mTarget < 0x00010001) { throw new IllegalStateException ("Loading constant primitive classes not supported below target version 1.1"); } loadStaticField(type.toObjectType(), "TYPE", TypeDesc.forClass(Class.class)); } else { if (mTarget < 0x00010005) { throw new IllegalStateException ("Loading constant object classes not supported below target version 1.5"); } ConstantInfo info = mCp.addConstantClass(type); mInstructions.new LoadConstantInstruction(1, TypeDesc.forClass(Class.class), info); } }
TypeDesc objectArrayType = TypeDesc.OBJECT.toArrayType(); TypeDesc[] params = {objectArrayType}; MethodInfo mi = cf.addConstructor(Modifiers.PUBLIC, params); mListType = TypeDesc.forClass(List.class); mStringType = TypeDesc.STRING; mObjectType = TypeDesc.OBJECT; mIntArrayType = TypeDesc.INT.toArrayType(); TypeDesc charArrayType = TypeDesc.CHAR.toArrayType(); params = new TypeDesc[]{charArrayType, mIntType, mListType}; mi = cf.addMethod(Modifiers.PUBLIC, "fillMatchResults", null, params);
return parseTypeDesc().toArrayType(); return TypeDesc.forClass(Class.class); throw error("Invalid enumeration"); TypeDesc type = TypeDesc.forClass(mStr.substring(mPos, dot)); mPos = dot + 1; return type; TypeDesc type = TypeDesc.forDescriptor(mStr.substring(mPos, endPos)); mPos = endPos;
private static int returnSize(TypeDesc ret) { if (ret == null || ret == TypeDesc.VOID) { return 0; } if (ret.isDoubleWord()) { return 2; } return 1; }
if (type.isPrimitive()) { name = "TypeDesc.".concat(type.getRootName().toUpperCase()); mTypeDescNames.put(type, name); return name; buf.append(" = "); TypeDesc componentType = type.getComponentType(); if (componentType != null) { buf.append(getTypeDescName(componentType)); buf.append("TypeDesc.forClass("); buf.append('"'); buf.append(type.getRootName()); buf.append('"');
if (paramVar.getType().isDoubleWord()) { type = ((ConstantClassInfo)ci).getType().toArrayType(); assembler.newObject(type); } else { String className = field.getParentClass().getType().getFullName(); if (mEnclosingClassName.equals(className)) { className = null; className = method.getParentClass().getType().getFullName(); nameAndType = method.getNameAndType(); } else if (opcode == Opcode.INVOKEDYNAMIC) { className = method.getParentClass().getType().getFullName(); nameAndType = method.getNameAndType(); System.out.println(nameAndType); className = method.getParentClass().getType().getFullName(); if (mEnclosingClassName.equals(className)) { className = null; assembler.newObject(type.toArrayType()); break;