Java Code Examples for org.jf.dexlib2.iface.Annotation

The following examples show how to use org.jf.dexlib2.iface.Annotation. These examples are extracted from open source projects. 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 Project: ZjDroid   Source File: ImmutableClassDef.java    License: 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 2
Source Project: ZjDroid   Source File: ImmutableClassDef.java    License: 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 3
Source Project: ZjDroid   Source File: BuilderAnnotationSetPool.java    License: 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 4
Source Project: HeyGirl   Source File: ParameterIterator.java    License: 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 5
Source Project: ZjDroid   Source File: DexBuilder.java    License: 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 6
Source Project: ZjDroid   Source File: ReflectionConstructor.java    License: 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 7
Source Project: ZjDroid   Source File: ReflectionMethod.java    License: 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 8
Source Project: ZjDroid   Source File: ParameterIterator.java    License: 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 9
Source Project: ZjDroid   Source File: ParameterIterator.java    License: 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 10
Source Project: atlas   Source File: AnnotationFormatter.java    License: 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 11
Source Project: HeyGirl   Source File: ImmutableClassDef.java    License: 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 12
Source Project: HeyGirl   Source File: DexBuilder.java    License: 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 13
Source Project: HeyGirl   Source File: ImmutableClassDef.java    License: 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 14
Source Project: ZjDroid   Source File: BuilderAnnotationSetPool.java    License: 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 15
Source Project: ZjDroid   Source File: ReflectionMethod.java    License: 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 16
Source Project: HeyGirl   Source File: ReflectionMethod.java    License: 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 17
Source Project: ZjDroid   Source File: ImmutableMethod.java    License: 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 18
Source Project: ZjDroid   Source File: ImmutableMethodParameter.java    License: 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 19
Source Project: ZjDroid   Source File: FieldDefinition.java    License: 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 Project: ZjDroid   Source File: ParameterIterator.java    License: Apache License 2.0 5 votes vote down vote up
public ParameterIterator(@Nonnull List<? extends CharSequence> parameterTypes,
                         @Nonnull List<? extends Set<? extends Annotation>> parameterAnnotations,
                         @Nonnull Iterator<String> parameterNames) {
    this.parameterTypes = parameterTypes.iterator();
    this.parameterAnnotations = parameterAnnotations.iterator();
    this.parameterNames = parameterNames;
}
 
Example 21
Source Project: ZjDroid   Source File: AnnotationSetPool.java    License: 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 22
Source Project: ZjDroid   Source File: BaseAnnotation.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(Annotation o) {
    int res = Ints.compare(getVisibility(), o.getVisibility());
    if (res != 0) return res;
    res = getType().compareTo(o.getType());
    if (res != 0) return res;
    return CollectionUtils.compareAsSet(getElements(), o.getElements());
}
 
Example 23
Source Project: ZjDroid   Source File: AnnotationPool.java    License: Apache License 2.0 5 votes vote down vote up
public void intern(@Nonnull Annotation annotation) {
    Integer prev = internedItems.put(annotation, 0);
    if (prev == null) {
        typePool.intern(annotation.getType());
        for (AnnotationElement element: annotation.getElements()) {
            stringPool.intern(element.getName());
            DexPool.internEncodedValue(element.getValue(), stringPool, typePool, fieldPool, methodPool);
        }
    }
}
 
Example 24
Source Project: ZjDroid   Source File: BaseAnnotation.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (o instanceof Annotation) {
        Annotation other = (Annotation)o;
        return (getVisibility() == other.getVisibility()) &&
               getType().equals(other.getType()) &&
               getElements().equals(other.getElements());
    }
    return false;
}
 
Example 25
Source Project: ZjDroid   Source File: DexBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull public BuilderClassDef internClassDef(@Nonnull String type,
                                               int accessFlags,
                                               @Nullable String superclass,
                                               @Nullable List<String> interfaces,
                                               @Nullable String sourceFile,
                                               @Nonnull Set<? extends Annotation> annotations,
                                               @Nullable Iterable<? extends BuilderField> fields,
                                               @Nullable Iterable<? extends BuilderMethod> methods) {
    if (interfaces == null) {
        interfaces = ImmutableList.of();
    } else {
        interfaces = Lists.newArrayList(interfaces);
        Collections.sort(interfaces);
        String prev = null;
        Iterator<String> interfaceIterator = interfaces.iterator();
        while (interfaceIterator.hasNext()) {
            String iface = interfaceIterator.next();
            if (prev != null && iface.equals(prev)) {
                interfaceIterator.remove();
            }
            prev = iface;
        }
    }

    return context.classPool.internClass(new BuilderClassDef(context.typePool.internType(type),
            accessFlags,
            context.typePool.internNullableType(superclass),
            context.typeListPool.internTypeList(interfaces),
            context.stringPool.internNullableString(sourceFile),
            context.annotationSetPool.internAnnotationSet(annotations),
            fields,
            methods));
}
 
Example 26
Source Project: ZjDroid   Source File: BuilderAnnotationPool.java    License: 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 27
Source Project: HeyGirl   Source File: DexBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull public BuilderField internField(@Nonnull String definingClass,
                                         @Nonnull String name,
                                         @Nonnull String type,
                                         int accessFlags,
                                         @Nullable EncodedValue initialValue,
                                         @Nonnull Set<? extends Annotation> annotations) {
    return new BuilderField(context.fieldPool.internField(definingClass, name, type),
            accessFlags,
            context.internNullableEncodedValue(initialValue),
            context.annotationSetPool.internAnnotationSet(annotations));
}
 
Example 28
Source Project: JAADAS   Source File: DexPrinter.java    License: 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 29
Source Project: ZjDroid   Source File: AnnotationSetPool.java    License: 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 30
Source Project: ZjDroid   Source File: ImmutableAnnotation.java    License: 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());
}