org.jf.dexlib2.iface.Annotation Java Examples

The following examples show how to use org.jf.dexlib2.iface.Annotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DexBuilder.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass,
                                           @Nonnull String name,
                                           @Nullable List<? extends MethodParameter> parameters,
                                           @Nonnull String returnType,
                                           int accessFlags,
                                           @Nonnull Set<? extends Annotation> annotations,
                                           @Nullable MethodImplementation methodImplementation) {
    if (parameters == null) {
        parameters = ImmutableList.of();
    }
    return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType),
            internMethodParameters(parameters),
            accessFlags,
            context.annotationSetPool.internAnnotationSet(annotations),
            methodImplementation);
}
 
Example #2
Source File: DexBuilder.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass,
                                           @Nonnull String name,
                                           @Nullable List<? extends MethodParameter> parameters,
                                           @Nonnull String returnType,
                                           int accessFlags,
                                           @Nonnull Set<? extends Annotation> annotations,
                                           @Nullable MethodImplementation methodImplementation) {
    if (parameters == null) {
        parameters = ImmutableList.of();
    }
    return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType),
            internMethodParameters(parameters),
            accessFlags,
            context.annotationSetPool.internAnnotationSet(annotations),
            methodImplementation);
}
 
Example #3
Source File: ImmutableClassDef.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public ImmutableClassDef(@Nonnull String type,
                         int accessFlags,
                         @Nullable String superclass,
                         @Nullable Collection<String> interfaces,
                         @Nullable String sourceFile,
                         @Nullable Collection<? extends Annotation> annotations,
                         @Nullable Iterable<? extends Field> fields,
                         @Nullable Iterable<? extends Method> methods) {
    if (fields == null) {
        fields = ImmutableList.of();
    }
    if (methods == null) {
        methods = ImmutableList.of();
    }

    this.type = type;
    this.accessFlags = accessFlags;
    this.superclass = superclass;
    this.interfaces = interfaces==null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(interfaces);
    this.sourceFile = sourceFile;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.staticFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_STATIC));
    this.instanceFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_INSTANCE));
    this.directMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_DIRECT));
    this.virtualMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_VIRTUAL));
}
 
Example #4
Source File: ImmutableClassDef.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public ImmutableClassDef(@Nonnull String type,
                         int accessFlags,
                         @Nullable String superclass,
                         @Nullable Collection<String> interfaces,
                         @Nullable String sourceFile,
                         @Nullable Collection<? extends Annotation> annotations,
                         @Nullable Iterable<? extends Field> fields,
                         @Nullable Iterable<? extends Method> methods) {
    if (fields == null) {
        fields = ImmutableList.of();
    }
    if (methods == null) {
        methods = ImmutableList.of();
    }

    this.type = type;
    this.accessFlags = accessFlags;
    this.superclass = superclass;
    this.interfaces = interfaces==null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(interfaces);
    this.sourceFile = sourceFile;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.staticFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_STATIC));
    this.instanceFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_INSTANCE));
    this.directMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_DIRECT));
    this.virtualMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_VIRTUAL));
}
 
Example #5
Source File: ImmutableClassDef.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public ImmutableClassDef(@Nonnull String type,
                         int accessFlags,
                         @Nullable String superclass,
                         @Nullable Collection<String> interfaces,
                         @Nullable String sourceFile,
                         @Nullable Collection<? extends Annotation> annotations,
                         @Nullable Iterable<? extends Field> staticFields,
                         @Nullable Iterable<? extends Field> instanceFields,
                         @Nullable Iterable<? extends Method> directMethods,
                         @Nullable Iterable<? extends Method> virtualMethods) {
    this.type = type;
    this.accessFlags = accessFlags;
    this.superclass = superclass;
    this.interfaces = interfaces==null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(interfaces);
    this.sourceFile = sourceFile;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.staticFields = ImmutableField.immutableSetOf(staticFields);
    this.instanceFields = ImmutableField.immutableSetOf(instanceFields);
    this.directMethods = ImmutableMethod.immutableSetOf(directMethods);
    this.virtualMethods = ImmutableMethod.immutableSetOf(virtualMethods);
}
 
Example #6
Source File: ParameterIterator.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override public MethodParameter next() {
    @Nonnull final String type = parameterTypes.next().toString();
    @Nonnull final Set<? extends Annotation> annotations;
    @Nullable final String name;

    if (parameterAnnotations.hasNext()) {
        annotations = parameterAnnotations.next();
    } else {
        annotations = ImmutableSet.of();
    }

    if (parameterNames.hasNext()) {
        name = parameterNames.next();
    } else {
        name = null;
    }

    return new BaseMethodParameter() {
        @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return annotations; }
        @Nullable @Override public String getName() { return name; }
        @Nonnull @Override public String getType() { return type; }
    };
}
 
Example #7
Source File: BuilderAnnotationSetPool.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderAnnotationSet internAnnotationSet(@Nullable Set<? extends Annotation> annotations) {
    if (annotations == null) {
        return BuilderAnnotationSet.EMPTY;
    }

    BuilderAnnotationSet ret = internedItems.get(annotations);
    if (ret != null) {
        return ret;
    }

    BuilderAnnotationSet annotationSet = new BuilderAnnotationSet(
            ImmutableSet.copyOf(Iterators.transform(annotations.iterator(),
                    new Function<Annotation, BuilderAnnotation>() {
                        @Nullable @Override public BuilderAnnotation apply(Annotation input) {
                            return context.annotationPool.internAnnotation(input);
                        }
                    })));

    ret = internedItems.putIfAbsent(annotationSet, annotationSet);
    return ret==null?annotationSet:ret;
}
 
Example #8
Source File: AnnotationFormatter.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static void writeTo(@Nonnull IndentingWriter writer,
                           @Nonnull Collection<? extends Annotation> annotations,
                           @Nullable String containingClass, MethodReplaceAnnotation methodReplaceAnnotation) throws IOException {
    boolean first = true;
    for (Annotation annotation : annotations) {
        if (!first) {
            writer.write('\n');
        }
        first = false;

        writeTo(writer, annotation, containingClass);
    }
    if (null != methodReplaceAnnotation) {
        writeTo(writer, methodReplaceAnnotation, containingClass);
    }
}
 
Example #9
Source File: ImmutableClassDef.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public ImmutableClassDef(@Nonnull String type,
                         int accessFlags,
                         @Nullable String superclass,
                         @Nullable Collection<String> interfaces,
                         @Nullable String sourceFile,
                         @Nullable Collection<? extends Annotation> annotations,
                         @Nullable Iterable<? extends Field> staticFields,
                         @Nullable Iterable<? extends Field> instanceFields,
                         @Nullable Iterable<? extends Method> directMethods,
                         @Nullable Iterable<? extends Method> virtualMethods) {
    this.type = type;
    this.accessFlags = accessFlags;
    this.superclass = superclass;
    this.interfaces = interfaces==null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(interfaces);
    this.sourceFile = sourceFile;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.staticFields = ImmutableField.immutableSetOf(staticFields);
    this.instanceFields = ImmutableField.immutableSetOf(instanceFields);
    this.directMethods = ImmutableMethod.immutableSetOf(directMethods);
    this.virtualMethods = ImmutableMethod.immutableSetOf(virtualMethods);
}
 
Example #10
Source File: ReflectionMethod.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final java.lang.reflect.Method method = this.method;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #11
Source File: BuilderAnnotationSetPool.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderAnnotationSet internAnnotationSet(@Nullable Set<? extends Annotation> annotations) {
    if (annotations == null) {
        return BuilderAnnotationSet.EMPTY;
    }

    BuilderAnnotationSet ret = internedItems.get(annotations);
    if (ret != null) {
        return ret;
    }

    BuilderAnnotationSet annotationSet = new BuilderAnnotationSet(
            ImmutableSet.copyOf(Iterators.transform(annotations.iterator(),
                    new Function<Annotation, BuilderAnnotation>() {
                        @Nullable @Override public BuilderAnnotation apply(Annotation input) {
                            return context.annotationPool.internAnnotation(input);
                        }
                    })));

    ret = internedItems.putIfAbsent(annotationSet, annotationSet);
    return ret==null?annotationSet:ret;
}
 
Example #12
Source File: ReflectionMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final java.lang.reflect.Method method = this.method;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #13
Source File: ReflectionConstructor.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final Constructor method = this.constructor;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #14
Source File: ReflectionMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final java.lang.reflect.Method method = this.method;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #15
Source File: ParameterIterator.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override public MethodParameter next() {
    @Nonnull final String type = parameterTypes.next().toString();
    @Nonnull final Set<? extends Annotation> annotations;
    @Nullable final String name;

    if (parameterAnnotations.hasNext()) {
        annotations = parameterAnnotations.next();
    } else {
        annotations = ImmutableSet.of();
    }

    if (parameterNames.hasNext()) {
        name = parameterNames.next();
    } else {
        name = null;
    }

    return new BaseMethodParameter() {
        @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return annotations; }
        @Nullable @Override public String getName() { return name; }
        @Nonnull @Override public String getType() { return type; }
    };
}
 
Example #16
Source File: ParameterIterator.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override public MethodParameter next() {
    @Nonnull final String type = parameterTypes.next().toString();
    @Nonnull final Set<? extends Annotation> annotations;
    @Nullable final String name;

    if (parameterAnnotations.hasNext()) {
        annotations = parameterAnnotations.next();
    } else {
        annotations = ImmutableSet.of();
    }

    if (parameterNames.hasNext()) {
        name = parameterNames.next();
    } else {
        name = null;
    }

    return new BaseMethodParameter() {
        @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return annotations; }
        @Nullable @Override public String getName() { return name; }
        @Nonnull @Override public String getType() { return type; }
    };
}
 
Example #17
Source File: AnnotationFormatter.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static void writeTo(@Nonnull IndentingWriter writer, @Nonnull Annotation annotation,
                           @Nullable String containingClass) throws IOException {
    writer.write(".annotation ");
    writer.write(AnnotationVisibility.getVisibility(annotation.getVisibility()));
    writer.write(' ');
    writer.write(annotation.getType());
    writer.write('\n');

    AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotation.getElements(), containingClass);

    writer.write(".end annotation\n");
}
 
Example #18
Source File: DexPrinter.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private Annotation buildEnclosingMethodTag(EnclosingMethodTag t, Set<String> skipList) {
	if (!skipList.add("Ldalvik/annotation/EnclosingMethod;"))
		return null;
	
	if (t.getEnclosingMethod() == null)
		return null;

	String[] split1 = t.getEnclosingMethodSig().split("\\)");
 String parametersS = split1[0].replaceAll("\\(", "");
 String returnTypeS = split1[1];
 
 List<String> typeList = new ArrayList<String>();
    if (!parametersS.equals("")) {
        for (String p : Util.splitParameters(parametersS)) {
            if (!p.isEmpty())
            	typeList.add(p);
        }
    }
    
 ImmutableMethodReference mRef = new ImmutableMethodReference
 		(SootToDexUtils.getDexClassName(t.getEnclosingClass()),
 		t.getEnclosingMethod(), typeList, returnTypeS);
	ImmutableMethodEncodedValue methodRef = new ImmutableMethodEncodedValue
			(dexFile.internMethodReference(mRef));
	AnnotationElement methodElement = new ImmutableAnnotationElement("value", methodRef);
	
	return new ImmutableAnnotation(AnnotationVisibility.SYSTEM,
			"Ldalvik/annotation/EnclosingMethod;",
			Collections.singleton(methodElement));
}
 
Example #19
Source File: FieldDefinition.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException {
    EncodedValue initialValue = field.getInitialValue();
    int accessFlags = field.getAccessFlags();

    if (setInStaticConstructor &&
            AccessFlags.STATIC.isSet(accessFlags) &&
            AccessFlags.FINAL.isSet(accessFlags) &&
            initialValue != null) {
        if (!EncodedValueUtils.isDefaultValue(initialValue)) {
            writer.write("# The value of this static final field might be set in the static constructor\n");
        } else {
            // don't write out the default initial value for static final fields that get set in the static
            // constructor
            initialValue = null;
        }
    }

    writer.write(".field ");
    writeAccessFlags(writer, field.getAccessFlags());
    writer.write(field.getName());
    writer.write(':');
    writer.write(field.getType());
    if (initialValue != null) {
        writer.write(" = ");
        EncodedValueAdaptor.writeTo(writer, initialValue);
    }

    writer.write('\n');

    Collection<? extends Annotation> annotations = field.getAnnotations();
    if (annotations.size() > 0) {
        writer.indent(4);
        AnnotationFormatter.writeTo(writer, annotations);
        writer.deindent(4);
        writer.write(".end field\n");
    }
}
 
Example #20
Source File: ImmutableMethodParameter.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableMethodParameter(@Nonnull String type,
                                @Nullable Set<? extends Annotation> annotations,
                                @Nullable String name) {
    this.type = type;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.name = name;
}
 
Example #21
Source File: ImmutableMethod.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableMethod(@Nonnull String definingClass,
                       @Nonnull String name,
                       @Nullable Iterable<? extends MethodParameter> parameters,
                       @Nonnull String returnType,
                       int accessFlags,
                       @Nullable Set<? extends Annotation> annotations,
                       @Nullable MethodImplementation methodImplementation) {
    this.definingClass = definingClass;
    this.name = name;
    this.parameters = ImmutableMethodParameter.immutableListOf(parameters);
    this.returnType = returnType;
    this.accessFlags = accessFlags;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.methodImplementation = ImmutableMethodImplementation.of(methodImplementation);
}
 
Example #22
Source File: BackSmaliMain.java    From SimpleSmali with Apache License 2.0 5 votes vote down vote up
private static void annotionToString(Writer printStream, Annotation annotation, Indentation indent)
        throws IOException {
    List<String> attributes = new ArrayList<String>();
    Set<? extends AnnotationElement> elements = annotation.getElements();
    for (AnnotationElement element : elements) {
        attributes.add(String
                .format("%s=%s", element.getName(), DexEncodedValueUtils.getEncodeValue(element.getValue())));
    }
    printStream.write(indent.toString());
    printStream.write(String.format("@%s(%s)", annotation.getType(), String.join(",", attributes)));
    printStream.write(newLine);
}
 
Example #23
Source File: ImmutableField.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableField(@Nonnull String definingClass,
                      @Nonnull String name,
                      @Nonnull String type,
                      int accessFlags,
                      @Nullable EncodedValue initialValue,
                      @Nullable Collection<? extends Annotation> annotations) {
    this.definingClass = definingClass;
    this.name = name;
    this.type = type;
    this.accessFlags = accessFlags;
    this.initialValue = ImmutableEncodedValueFactory.ofNullable(initialValue);
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
}
 
Example #24
Source File: ImmutableField.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public ImmutableField(@Nonnull String definingClass,
                      @Nonnull String name,
                      @Nonnull String type,
                      int accessFlags,
                      @Nullable EncodedValue initialValue,
                      @Nullable Collection<? extends Annotation> annotations) {
    this.definingClass = definingClass;
    this.name = name;
    this.type = type;
    this.accessFlags = accessFlags;
    this.initialValue = ImmutableEncodedValueFactory.ofNullable(initialValue);
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
}
 
Example #25
Source File: AnnotationFormatter.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, Annotation annotation) throws IOException {
    writer.write(".annotation ");
    writer.write(AnnotationVisibility.getVisibility(annotation.getVisibility()));
    writer.write(' ');
    writer.write(annotation.getType());
    writer.write('\n');

    AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotation.getElements());

    writer.write(".end annotation\n");
}
 
Example #26
Source File: AnnotationSetPool.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void intern(@Nonnull Set<? extends Annotation> annotationSet) {
    if (annotationSet.size() > 0) {
        Integer prev = internedItems.put(annotationSet, 0);
        if (prev == null) {
            for (Annotation annotation: annotationSet) {
                annotationPool.intern(annotation);
            }
        }
    }
}
 
Example #27
Source File: BuilderAnnotationPool.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Nonnull public BuilderAnnotation internAnnotation(@Nonnull Annotation annotation) {
    BuilderAnnotation ret = internedItems.get(annotation);
    if (ret != null) {
        return ret;
    }

    BuilderAnnotation dexBuilderAnnotation = new BuilderAnnotation(
            annotation.getVisibility(),
            context.typePool.internType(annotation.getType()),
            context.internAnnotationElements(annotation.getElements()));
    ret = internedItems.putIfAbsent(dexBuilderAnnotation, dexBuilderAnnotation);
    return ret==null?dexBuilderAnnotation:ret;
}
 
Example #28
Source File: ImmutableAnnotation.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableAnnotation of(Annotation annotation) {
    if (annotation instanceof  ImmutableAnnotation) {
        return (ImmutableAnnotation)annotation;
    }
    return new ImmutableAnnotation(
            annotation.getVisibility(),
            annotation.getType(),
            annotation.getElements());
}
 
Example #29
Source File: FieldDefinition.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException {
    EncodedValue initialValue = field.getInitialValue();
    int accessFlags = field.getAccessFlags();

    if (setInStaticConstructor &&
            AccessFlags.STATIC.isSet(accessFlags) &&
            AccessFlags.FINAL.isSet(accessFlags) &&
            initialValue != null) {
        if (!EncodedValueUtils.isDefaultValue(initialValue)) {
            writer.write("# The value of this static final field might be set in the static constructor\n");
        } else {
            // don't write out the default initial value for static final fields that get set in the static
            // constructor
            initialValue = null;
        }
    }

    writer.write(".field ");
    writeAccessFlags(writer, field.getAccessFlags());
    writer.write(field.getName());
    writer.write(':');
    writer.write(field.getType());
    if (initialValue != null) {
        writer.write(" = ");
        EncodedValueAdaptor.writeTo(writer, initialValue);
    }

    writer.write('\n');

    Collection<? extends Annotation> annotations = field.getAnnotations();
    if (annotations.size() > 0) {
        writer.indent(4);
        AnnotationFormatter.writeTo(writer, annotations);
        writer.deindent(4);
        writer.write(".end field\n");
    }
}
 
Example #30
Source File: AnnotationSetPool.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void intern(@Nonnull Set<? extends Annotation> annotationSet) {
    if (annotationSet.size() > 0) {
        Integer prev = internedItems.put(annotationSet, 0);
        if (prev == null) {
            for (Annotation annotation: annotationSet) {
                annotationPool.intern(annotation);
            }
        }
    }
}