public void putField(Atom name, TypeReference type) { final FieldReference fdRef = FieldReference.findOrCreate(this.getReference(), name, type); final int accessFlags = ClassConstants.ACC_STATIC | ClassConstants.ACC_PUBLIC; final IField field = new FieldImpl(this, fdRef, accessFlags, null, null); this.fields.put(name, field); }
@Override public FieldReference getReference() { return FieldReference.findOrCreate(getDeclaringClass().getReference(), getName(), getFieldTypeReference()); }
@Override public String toString() { FieldReference fr = getReference(); return fr.toString(); }
public static boolean hasAnnotation(IField field, TypeName type) { if (field instanceof FieldImpl) { FieldImpl f = (FieldImpl) field; Collection<Annotation> annotations = f.getAnnotations(); if (annotations != null) { for (Annotation a : annotations) { if (a.getType().getName().equals(type)) { return true; } } } } return false; } }
private void testFieldAnnotations(String fieldNameStr, TypeReference typeUnderTest, Collection<TypeAnnotation> expectedAnnotations) { IClass classUnderTest = cha.lookupClass(typeUnderTest); harness.assertNotNull(typeUnderTest.toString() + " not found", classUnderTest); harness.assertTrue(classUnderTest + " must be BytecodeClass", classUnderTest instanceof ShrikeClass); ShrikeClass bcClassUnderTest = (ShrikeClass) classUnderTest; final Atom fieldName = Atom.findOrCreateUnicodeAtom(fieldNameStr); FieldImpl field = (FieldImpl) bcClassUnderTest.getField(fieldName); Collection<TypeAnnotation> annotations = field.getTypeAnnotations(); harness.assertEqualCollections(expectedAnnotations, annotations); } }
public static boolean hasAnnotation(IField field, TypeName type) { if (field instanceof FieldImpl) { FieldImpl f = (FieldImpl) field; Collection<Annotation> annotations = f.getAnnotations(); if (annotations != null) { for (Annotation a : annotations) { if (a.getType().getName().equals(type)) { return true; } } } } return false; } }
@Override public FieldReference getReference() { return FieldReference.findOrCreate(getDeclaringClass().getReference(), getName(), getFieldTypeReference()); }
public void putField(Atom name, TypeReference type) { final FieldReference fdRef = FieldReference.findOrCreate(this.getReference(), name, type); final int accessFlags = ClassConstants.ACC_STATIC | ClassConstants.ACC_PUBLIC; final IField field = new FieldImpl(this, fdRef, accessFlags, null, null); this.fields.put(name, field); }
@Override public String toString() { FieldReference fr = getReference(); return fr.toString(); }
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); }
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); }