public static IPrimitiveType wrap(PrimitiveType type) { switch (type.primitive()) { case SHORT: return IPrimitiveType.SHORT; case LONG: return IPrimitiveType.LONG; case BYTE: return IPrimitiveType.BYTE; case DOUBLE: return IPrimitiveType.DOUBLE; case BOOLEAN: return IPrimitiveType.BOOLEAN; case CHAR: return IPrimitiveType.CHAR; case FLOAT: return IPrimitiveType.FLOAT; case INT: return IPrimitiveType.INT; } throw new IllegalArgumentException("Invalid Java primitive type! " + type.toString()); }
@Override Type copyType(AnnotationInstance[] newAnnotations) { return new PrimitiveType(primitive, newAnnotations); }
private Type parseJavaType() { Type type = PrimitiveType.decode(signature.charAt(pos)); if (type != null) { pos++; return type; } return parseReferenceType(); }
switch ( ( (PrimitiveType) p ).primitive() ) { case BOOLEAN: return "Z"; //$NON-NLS-1$
@Override public DotName name() { StringBuilder builder = new StringBuilder(); int dimensions = this.dimensions; while (dimensions-- > 0) { builder.append('['); } if (component instanceof PrimitiveType) { builder.append(((PrimitiveType)component).toCode()); } else { // This relies on name() representing the erased type name // For historical 1.x reasons, we follow the Java reflection format // instead of the Java descriptor format. builder.append('L').append(component.name().toString()).append(';'); } return DotName.createSimple(builder.toString()); }
Type type = PrimitiveType.fromOridinal(primitive); AnnotationInstance[] annotations = readAnnotations(stream, null); return annotations.length > 0 ? type.copyType(annotations) : type;
break; case PRIMITIVE: stream.writeByte(type.asPrimitiveType().primitive().ordinal()); break; case VOID:
Type type = PrimitiveType.decode(string.charAt(start)); if (type != null) { return new ArrayType(type, depth); break; default: type = PrimitiveType.decode(string.charAt(start)); if (type == null) { throw new IllegalArgumentException("Component type not supported: " + c); return new ClassType(name); case PRIMITIVE: return PrimitiveType.decode(name.toString()); case VOID: return VoidType.VOID;
private Type parseType(String descriptor, IntegerHolder pos) { int start = pos.i; char c = descriptor.charAt(start); Type type = PrimitiveType.decode(c); if (type != null) { return type; } DotName name; switch (c) { case 'V': return VoidType.VOID; case 'L': { int end = start; while (descriptor.charAt(++end) != ';'); name = names.convertToName(descriptor.substring(start + 1, end), '/'); pos.i = end; return names.intern(new ClassType(name)); } case '[': { int end = start; while (descriptor.charAt(++end) == '['); int depth = end - start; pos.i = end; type = parseType(descriptor, pos); return names.intern(new ArrayType(type, depth)); } default: throw new IllegalArgumentException("Invalid descriptor: " + descriptor + " pos " + start); } }