/** * Convert a value of an element to a {@code Constant}. * <p><strong>Warning:</strong> Array or TypeId value is not supported yet. * * @param value an annotation element value. * @return a Constant */ static Constant toConstant(Object value) { Class clazz = value.getClass(); if (clazz.isEnum()) { CstString descriptor = new CstString(TypeId.get(clazz).getName()); CstString name = new CstString(((Enum)value).name()); CstNat cstNat = new CstNat(name, descriptor); return new CstEnumRef(cstNat); } else if (clazz.isArray()) { throw new UnsupportedOperationException("Array is not supported yet"); } else if (value instanceof TypeId) { throw new UnsupportedOperationException("TypeId is not supported yet"); } else { return Constants.getConstant(value); } } }
FieldId(TypeId<D> declaringType, TypeId<V> type, String name) { if (declaringType == null || type == null || name == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.type = type; this.name = name; this.nat = new CstNat(new CstString(name), new CstString(type.name)); this.constant = new CstFieldRef(declaringType.constant, nat); }
MethodId(TypeId<D> declaringType, TypeId<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
private static CstMethodRef makeInvokeMethod(final CstMethodRef callSiteMethod) { // The name is either invoke or invokeExact. The INVOKE_DESCRIPTOR is fixed. CstNat cstNat = new CstNat(callSiteMethod.getNat().getName(), INVOKE_DESCRIPTOR); return new CstMethodRef(CstType.METHOD_HANDLE, cstNat); }
/** * Convert a value of an element to a {@code Constant}. * <p><strong>Warning:</strong> Array or TypeId value is not supported yet. * * @param value an annotation element value. * @return a Constant */ static Constant toConstant(Object value) { Class clazz = value.getClass(); if (clazz.isEnum()) { CstString descriptor = new CstString(TypeId.get(clazz).getName()); CstString name = new CstString(((Enum)value).name()); CstNat cstNat = new CstNat(name, descriptor); return new CstEnumRef(cstNat); } else if (clazz.isArray()) { throw new UnsupportedOperationException("Array is not supported yet"); } else if (value instanceof TypeId) { throw new UnsupportedOperationException("TypeId is not supported yet"); } else { return Constants.getConstant(value); } } }
FieldId(Type<D> declaringType, Type<V> type, String name) { if (declaringType == null || type == null || name == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.type = type; this.name = name; this.nat = new CstNat(new CstString(name), new CstString(type.name)); this.constant = new CstFieldRef(declaringType.constant, nat); }
FieldId(TypeId<D> declaringType, TypeId<V> type, String name) { if (declaringType == null || type == null || name == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.type = type; this.name = name; this.nat = new CstNat(new CstString(name), new CstString(type.name)); this.constant = new CstFieldRef(declaringType.constant, nat); }
FieldId(TypeId<D> declaringType, TypeId<V> type, String name) { if (declaringType == null || type == null || name == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.type = type; this.name = name; this.nat = new CstNat(new CstString(name), new CstString(type.name)); this.constant = new CstFieldRef(declaringType.constant, nat); }
MethodId(Type<D> declaringType, Type<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
MethodId(TypeId<D> declaringType, TypeId<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
MethodId(TypeId<D> declaringType, TypeId<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
CstNat cstNat = new CstNat(cstMethodName, DEFAULT_DESCRIPTOR); return new CstMethodRef(definingClass, cstNat); case "getVolatile": CstNat cstNat = new CstNat(cstMethodName, DEFAULT_DESCRIPTOR); return new CstMethodRef(definingClass, cstNat); case "setVolatile": CstNat cstNat = new CstNat(cstMethodName, VARHANDLE_SET_DESCRIPTOR); return new CstMethodRef(definingClass, cstNat); case "weakCompareAndSetRelease": CstNat cstNat = new CstNat(cstMethodName, VARHANDLE_COMPARE_AND_SET_DESCRIPTOR); return new CstMethodRef(definingClass, cstNat);
newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor()); SsaInsn newInsn2 = newBlock2.getInsns().get(0); CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V")); CstMethodRef newRef = new CstMethodRef(exception, newNat); insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor()); SsaInsn newInsn2 = newBlock2.getInsns().get(0); CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V")); CstMethodRef newRef = new CstMethodRef(exception, newNat); insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor()); SsaInsn newInsn2 = newBlock2.getInsns().get(0); CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V")); CstMethodRef newRef = new CstMethodRef(exception, newNat); insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor()); SsaInsn newInsn2 = newBlock2.getInsns().get(0); CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V")); CstMethodRef newRef = new CstMethodRef(exception, newNat); insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor()); SsaInsn newInsn2 = newBlock2.getInsns().get(0); CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V")); CstMethodRef newRef = new CstMethodRef(exception, newNat); insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor()); SsaInsn newInsn2 = newBlock2.getInsns().get(0); CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V")); CstMethodRef newRef = new CstMethodRef(exception, newNat); insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor()); SsaInsn newInsn2 = newBlock2.getInsns().get(0); CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V")); CstMethodRef newRef = new CstMethodRef(exception, newNat); insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
StdAttributeList attributes = parser.getList(); attributes.setImmutable(); CstNat nat = new CstNat(name, desc); Member member = set(i, accessFlags, nat, attributes);