static TypeName getTypeName(String fieldType) { ImmutableByteArray fieldTypeArray = ImmutableByteArray.make(fieldType); TypeName T = null; if (fieldTypeArray.get(fieldTypeArray.length() - 1) == ';') { T = TypeName.findOrCreate(fieldTypeArray, 0, fieldTypeArray.length() - 1); } else { T = TypeName.findOrCreate(fieldTypeArray); } return T; }
public static ImmutableByteArray concat(byte b, ImmutableByteArray b1) { if (b1 == null) { throw new IllegalArgumentException("b1 is null"); } byte[] arr = new byte[b1.length() + 1]; arr[0] = b; System.arraycopy(b1.b, 0, arr, 1, b1.b.length); return new ImmutableByteArray(arr); }
public static TypeName findOrCreate(String name) throws IllegalArgumentException { ImmutableByteArray b = ImmutableByteArray.make(name); return findOrCreate(b); }
throw new IllegalArgumentException("b is null"); if (b.length() <= 2) { throw new IllegalArgumentException("invalid descriptor: " + b); if (b.get(0) != '(') { throw new IllegalArgumentException("invalid descriptor: " + b); while (b.get(i++) != ')') if (b.length() < i + 1) { throw new IllegalArgumentException("invalid descriptor: " + b); switch (b.get(i)) { case TypeReference.VoidTypeCode: return TypeReference.Void.getName(); return TypeReference.Char.getName(); case TypeReference.OtherPrimitiveTypeCode: if (b.get(b.length() - 1) == ';') { return l.lookupPrimitiveType(new String(b.substring(i + 1, b.length() - i - 2))); } else { return l.lookupPrimitiveType(new String(b.substring(i + 1, b.length() - i - 1))); if (b.get(b.length() - 1) == ';') { return TypeName.findOrCreate(b, i, b.length() - i - 1); } else { return TypeName.findOrCreate(b, i, b.length() - i);
/** * @param s a String like Ljava/lang/Object * @return the corresponding TypeName * @throws IllegalArgumentException if s is null */ public static TypeName string2TypeName(String s) throws IllegalArgumentException { if (s == null) { throw new IllegalArgumentException("s is null"); } byte[] val = s.getBytes(); return findOrCreate(new ImmutableByteArray(val)); }
public static TypeName findOrCreate(ImmutableByteArray name) throws IllegalArgumentException { if (name == null) { throw new IllegalArgumentException("name is null"); } return findOrCreate(name, 0, name.length()); }
/** * @return true iff the class returned by parseForClass is primitive * @throws IllegalArgumentException if name is null */ public static boolean classIsPrimitive(ImmutableByteArray name, int start, int length) throws IllegalArgumentException { if (name == null) { throw new IllegalArgumentException("name is null"); } try { while (length > 0 && isTypeCodeChar(name, start)) { start++; length--; } if (start >= name.b.length) { throw new IllegalArgumentException("ill-formed type name: " + name); } return name.b[start] != 'L'; } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException(name.toString(), e); } }
public static final TypeName[] parseForParameterNames(Language l, String descriptor) throws IllegalArgumentException { return parseForParameterNames(l, ImmutableByteArray.make(descriptor)); }
throw new IllegalArgumentException("b is null"); if (b.length() <= 2) { throw new IllegalArgumentException("invalid descriptor: " + b); if (b.get(0) != '(') { throw new IllegalArgumentException("invalid descriptor: " + b); while (b.get(i++) != ')') if (b.length() < i + 1) { throw new IllegalArgumentException("invalid descriptor: " + b); switch (b.get(i)) { case TypeReference.VoidTypeCode: return TypeReference.Void.getName(); return TypeReference.Char.getName(); case TypeReference.OtherPrimitiveTypeCode: if (b.get(b.length() - 1) == ';') { return l.lookupPrimitiveType(new String(b.substring(i + 1, b.length() - i - 2))); } else { return l.lookupPrimitiveType(new String(b.substring(i + 1, b.length() - i - 1))); if (b.get(b.length() - 1) == ';') { return TypeName.findOrCreate(b, i, b.length() - i - 1); } else { return TypeName.findOrCreate(b, i, b.length() - i);
/** * @param s a String like Ljava/lang/Object * @return the corresponding TypeName * @throws IllegalArgumentException if s is null */ public static TypeName string2TypeName(String s) throws IllegalArgumentException { if (s == null) { throw new IllegalArgumentException("s is null"); } byte[] val = s.getBytes(); return findOrCreate(new ImmutableByteArray(val)); }
/** * Given that name[start:start+length] is a Type name in JVM format, parse it for the package * * @return an ImmutableByteArray that represents the package, or null if it's the unnamed package * @throws IllegalArgumentException if name is null */ public static ImmutableByteArray parseForPackage(ImmutableByteArray name) { if (name == null) { throw new IllegalArgumentException("name is null"); } return parseForPackage(name, 0, name.length()); }
/** * @return true iff the class returned by parseForClass is primitive * @throws IllegalArgumentException if name is null */ public static boolean classIsPrimitive(ImmutableByteArray name, int start, int length) throws IllegalArgumentException { if (name == null) { throw new IllegalArgumentException("name is null"); } try { while (length > 0 && isTypeCodeChar(name, start)) { start++; length--; } if (start >= name.b.length) { throw new IllegalArgumentException("ill-formed type name: " + name); } return name.b[start] != 'L'; } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException(name.toString(), e); } }
static TypeName getTypeName(String fieldType) { ImmutableByteArray fieldTypeArray = ImmutableByteArray.make(fieldType); TypeName T = null; if (fieldTypeArray.get(fieldTypeArray.length() - 1) == ';') { T = TypeName.findOrCreate(fieldTypeArray, 0, fieldTypeArray.length() - 1); } else { T = TypeName.findOrCreate(fieldTypeArray); } return T; }
public static final TypeName parseForReturnTypeName(String desc) throws IllegalArgumentException { return parseForReturnTypeName(Language.JAVA, ImmutableByteArray.make(desc)); }
throw new IllegalArgumentException("b is null"); if (b.length() <= 2) { throw new IllegalArgumentException("invalid descriptor: " + b); if (b.get(0) != '(') { throw new IllegalArgumentException("invalid descriptor: " + b); switch (b.get(i++)) { case TypeReference.VoidTypeCode: sigs.add(TypeReference.VoidName); case TypeReference.OtherPrimitiveTypeCode: { int off = i - 1; while (b.get(i++) != ';') sigs.add(l.lookupPrimitiveType(new String(b.substring(off + 1, i - off - 2)))); while (b.get(i++) != ';') byte c = b.get(i++); if (c == TypeReference.ClassTypeCode || c == TypeReference.OtherPrimitiveTypeCode) { while (b.get(i++) != ';')
public static ImmutableByteArray concat(byte b, ImmutableByteArray b1) { if (b1 == null) { throw new IllegalArgumentException("b1 is null"); } byte[] arr = new byte[b1.length() + 1]; arr[0] = b; System.arraycopy(b1.b, 0, arr, 1, b1.b.length); return new ImmutableByteArray(arr); }
protected void addFieldToList(List<FieldImpl> L, Atom name, ImmutableByteArray fieldType, int accessFlags, Collection<Annotation> annotations, Collection<TypeAnnotation> typeAnnotations, TypeSignature sig) { TypeName T = null; if (fieldType.get(fieldType.length() - 1) == ';') { T = TypeName.findOrCreate(fieldType, 0, fieldType.length() - 1); } else { T = TypeName.findOrCreate(fieldType); } TypeReference type = TypeReference.findOrCreate(getClassLoader().getReference(), T); FieldReference fr = FieldReference.findOrCreate(getReference(), name, type); FieldImpl f = new FieldImpl(this, fr, accessFlags, annotations, typeAnnotations, sig); L.add(f); }