public FieldInfo build() { return new FieldInfo(className, fieldName, fieldSignature, fieldSourceSignature, accessFlags, fieldAnnotations, true); } }
@Override public boolean isFinal() { return checkFlag(Const.ACC_FINAL); }
@Override public @CheckForNull AnnotatedObject getContainingScope() { try { return Global.getAnalysisCache().getClassAnalysis(XClass.class, getClassDescriptor()); } catch (CheckedAnalysisException e) { return null; } } }
int hash = FieldOrMethodDescriptor.getNameSigHashCode(name, signature); for (FieldInfo fInfo : xFields) { if (fInfo.getNameSigHashCode() == hash && fInfo.getName().equals(name) && fInfo.getSignature().equals(signature) && fInfo.isStatic() == isStatic) { return fInfo;
@Override public boolean isReferenceType() { return getSignature().startsWith("L") || getSignature().startsWith("["); }
@Override public void addFieldAnnotation(String cName, String mName, String mSig, boolean isStatic, NullnessAnnotation annotation) { if (DEBUG) { System.out.println("addFieldAnnotation: annotate " + cName + "." + mName + " with " + annotation); } XField xfield = XFactory.createXField(cName, mName, mSig, isStatic); if (!(xfield instanceof FieldInfo)) { if (DEBUG) { System.out.println(" Field not found! " + cName + "." + mName + ":" + mSig + " " + isStatic + " " + annotation); } return; } // Get JSR-305 nullness annotation type ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation); // Create an AnnotationValue AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType); // Destructively add the annotation to the FieldInfo object ((FieldInfo) xfield).addAnnotation(annotationValue); }
int hash = FieldOrMethodDescriptor.getNameSigHashCode(name, signature); for (FieldInfo fInfo : xFields) { if (fInfo.getNameSigHashCode() == hash && fInfo.getName().equals(name) && fInfo.getSignature().equals(signature) && fInfo.isStatic() == isStatic) { return fInfo;
public int getNumParams() { return new SignatureParser(getSignature()).getNumParameters(); }
@Override public void addFieldAnnotation(String cName, String mName, String mSig, boolean isStatic, NullnessAnnotation annotation) { if (DEBUG) { System.out.println("addFieldAnnotation: annotate " + cName + "." + mName + " with " + annotation); } XField xfield = XFactory.createXField(cName, mName, mSig, isStatic); if (!(xfield instanceof FieldInfo)) { if (DEBUG) { System.out.println(" Field not found! " + cName + "." + mName + ":" + mSig + " " + isStatic + " " + annotation); } return; } // Get JSR-305 nullness annotation type ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation); // Create an AnnotationValue AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType); // Destructively add the annotation to the FieldInfo object ((FieldInfo) xfield).addAnnotation(annotationValue); }
@Override public boolean isProtected() { return checkFlag(Const.ACC_PROTECTED); }
@Override public @DottedClassName String getPackageName() { return getClassDescriptor().getPackageName(); }
@Override public boolean isReferenceType() { return getSignature().startsWith("L") || getSignature().startsWith("["); }
/** * Create a FieldInfo object to represent an unresolved field. * <em>Don't call this directly - use XFactory instead.</em> * * @param className * name of class containing the field * @param name * name of field * @param signature * field signature * @param isStatic * true if field is static, false otherwise * @return FieldInfo object representing the unresolved field */ public static FieldInfo createUnresolvedFieldInfo(String className, String name, String signature, boolean isStatic) { className = ClassName.toSlashedClassName(className); return new FieldInfo(className, name, signature, null, // without seeing // the definition // we don't know // if it has a // generic type isStatic ? Const.ACC_STATIC : 0, new HashMap<ClassDescriptor, AnnotationValue>(), false); }
@Override public boolean isDeprecated() { return checkFlag(Opcodes.ACC_DEPRECATED); }
@Override public @DottedClassName String getClassName() { return getClassDescriptor().toDottedClassName(); }
public int getNumParams() { return new SignatureParser(getSignature()).getNumParameters(); }
public FieldInfo build() { return new FieldInfo(className, fieldName, fieldSignature, fieldSourceSignature, accessFlags, fieldAnnotations, true); } }
@Override public boolean isPrivate() { return checkFlag(Const.ACC_PRIVATE); }
@Override public @CheckForNull AnnotatedObject getContainingScope() { try { return Global.getAnalysisCache().getClassAnalysis(XClass.class, getClassDescriptor()); } catch (CheckedAnalysisException e) { return null; } } }
/** * Create a FieldInfo object to represent an unresolved field. * <em>Don't call this directly - use XFactory instead.</em> * * @param className * name of class containing the field * @param name * name of field * @param signature * field signature * @param isStatic * true if field is static, false otherwise * @return FieldInfo object representing the unresolved field */ public static FieldInfo createUnresolvedFieldInfo(String className, String name, String signature, boolean isStatic) { className = ClassName.toSlashedClassName(className); return new FieldInfo(className, name, signature, null, // without seeing // the definition // we don't know // if it has a // generic type isStatic ? Constants.ACC_STATIC : 0, new HashMap<ClassDescriptor, AnnotationValue>(), false); }