switch (type) { case AnnotationValue.ANNOTATION: return new AnnotationValue(readAnnotation(input)); case AnnotationValue.BOOLEAN: return new AnnotationValue(input.readBoolean()); case AnnotationValue.BYTE: return new AnnotationValue(input.readByte()); case AnnotationValue.CLASS: return new AnnotationValue(ValueType.parse(symbolTable.at(input.readInt()))); case AnnotationValue.DOUBLE: return new AnnotationValue(input.readDouble()); case AnnotationValue.ENUM: { String className = symbolTable.at(input.readInt()); String fieldName = symbolTable.at(input.readInt()); return new AnnotationValue(new FieldReference(className, fieldName)); return new AnnotationValue(input.readFloat()); case AnnotationValue.INT: return new AnnotationValue(input.readInt()); case AnnotationValue.LIST: { List<AnnotationValue> list = new ArrayList<>(); return new AnnotationValue(list); return new AnnotationValue(input.readLong()); case AnnotationValue.SHORT: return new AnnotationValue(input.readShort()); case AnnotationValue.STRING: return new AnnotationValue(input.readUTF());
private static AnnotationValue copyAnnotationValue(AnnotationValue value) { switch (value.getType()) { case AnnotationValue.LIST: { List<AnnotationValue> listCopy = new ArrayList<>(); for (AnnotationValue item : value.getList()) { listCopy.add(copyAnnotationValue(item)); } return new AnnotationValue(listCopy); } case AnnotationValue.ANNOTATION: return new AnnotationValue(copyAnnotation(value.getAnnotation())); default: return value; } } }
String[] enumInfo = (String[]) value; ValueType.Object object = (ValueType.Object) ValueType.parse(enumInfo[0]); return new AnnotationValue(referenceCache.getCached(new FieldReference(object.getClassName(), enumInfo[1]))); } else if (value instanceof Type) { Type cls = (Type) value; return new AnnotationValue(referenceCache.getCached(ValueType.parse(cls.getDescriptor()))); } else if (value instanceof List<?>) { List<?> originalList = (List<?>) value; return new AnnotationValue(resultList); } else if (value instanceof AnnotationNode) { AnnotationNode annotNode = (AnnotationNode) value; AnnotationHolder annotation = new AnnotationHolder(object.getClassName()); parseAnnotationValues(annotation, annotNode.values); return new AnnotationValue(annotation); } else if (value instanceof String) { return new AnnotationValue((String) value); } else if (value instanceof Boolean) { return new AnnotationValue((Boolean) value); } else if (value instanceof Byte) { return new AnnotationValue((Byte) value); } else if (value instanceof Short) { return new AnnotationValue((Short) value); } else if (value instanceof Integer) { return new AnnotationValue((Integer) value); } else if (value instanceof Long) { return new AnnotationValue((Long) value);
@Override public void transformClass(ClassHolder cls, ClassHolderTransformerContext context) { for (MethodHolder method : cls.getMethods()) { if (method.getAnnotations().get(JavaScriptBody.class.getName()) != null) { AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( JavaScriptBodyGenerator.class.getName()))); method.getAnnotations().add(genAnnot); method.setProgram(null); method.getModifiers().add(ElementModifier.NATIVE); } } } }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
@Override public void transformClass(ClassHolder cls, ClassHolderTransformerContext context) { int index = 0; for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { AnnotationReader providerAnnot = method.getAnnotations().get(MetadataProvider.class.getName()); if (providerAnnot != null) { transformMetadataMethod(cls, method, context.getDiagnostics(), context.getHierarchy(), index++); } providerAnnot = method.getAnnotations().get(ClassScopedMetadataProvider.class.getName()); if (providerAnnot != null) { ValueType[] params = method.getParameterTypes(); if (params.length != 1 && params[0].isObject(PlatformClass.class.getName())) { context.getDiagnostics().error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} must take exactly one parameter of type {{c2}}", method.getReference(), ClassScopedMetadataProvider.class.getName(), PlatformClass.class.getName()); } AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( ClassScopedMetadataProviderNativeGenerator.class.getName()))); method.getAnnotations().add(genAnnot); } } }
cls.addMethod(createMethod); AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( MetadataProviderNativeGenerator.class.getName()))); createMethod.getAnnotations().add(genAnnot); refAnnot.getValues().put("value", new AnnotationValue(method.getReference().toString())); createMethod.getAnnotations().add(refAnnot);
annot.getValues().put("name", new AnnotationValue(publicAlias)); exportedMethod.getAnnotations().add(annot);
switch (type) { case AnnotationValue.ANNOTATION: return new AnnotationValue(readAnnotation(input)); case AnnotationValue.BOOLEAN: return new AnnotationValue(input.readBoolean()); case AnnotationValue.BYTE: return new AnnotationValue(input.readByte()); case AnnotationValue.CLASS: return new AnnotationValue(ValueType.parse(symbolTable.at(input.readInt()))); case AnnotationValue.DOUBLE: return new AnnotationValue(input.readDouble()); case AnnotationValue.ENUM: { String className = symbolTable.at(input.readInt()); String fieldName = symbolTable.at(input.readInt()); return new AnnotationValue(new FieldReference(className, fieldName)); return new AnnotationValue(input.readFloat()); case AnnotationValue.INT: return new AnnotationValue(input.readInt()); case AnnotationValue.LIST: { List<AnnotationValue> list = new ArrayList<>(); return new AnnotationValue(list); return new AnnotationValue(input.readLong()); case AnnotationValue.SHORT: return new AnnotationValue(input.readShort()); case AnnotationValue.STRING: return new AnnotationValue(input.readUTF());
String[] enumInfo = (String[]) value; ValueType.Object object = (ValueType.Object) ValueType.parse(enumInfo[0]); return new AnnotationValue(new FieldReference(object.getClassName(), enumInfo[1])); } else if (value instanceof Type) { Type cls = (Type) value; return new AnnotationValue(ValueType.parse(cls.getDescriptor())); } else if (value instanceof List<?>) { List<?> originalList = (List<?>) value; return new AnnotationValue(resultList); } else if (value instanceof AnnotationNode) { AnnotationNode annotNode = (AnnotationNode) value; AnnotationHolder annotation = new AnnotationHolder(object.getClassName()); parseAnnotationValues(annotation, annotNode.values); return new AnnotationValue(annotation); } else if (value instanceof String) { return new AnnotationValue((String) value); } else if (value instanceof Boolean) { return new AnnotationValue((Boolean) value); } else if (value instanceof Byte) { return new AnnotationValue((Byte) value); } else if (value instanceof Short) { return new AnnotationValue((Short) value); } else if (value instanceof Integer) { return new AnnotationValue((Integer) value); } else if (value instanceof Long) { return new AnnotationValue((Long) value); } else if (value instanceof Float) {
private static AnnotationValue copyAnnotationValue(AnnotationValue value) { switch (value.getType()) { case AnnotationValue.LIST: { List<AnnotationValue> listCopy = new ArrayList<>(); for (AnnotationValue item : value.getList()) { listCopy.add(copyAnnotationValue(item)); } return new AnnotationValue(listCopy); } case AnnotationValue.ANNOTATION: return new AnnotationValue(copyAnnotation(value.getAnnotation())); default: return value; } } }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
void createJSMethods(ClassHolder cls) { for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { MethodReference methodRef = method.getReference(); if (method.getAnnotations().get(JSBody.class.getName()) == null) { continue; } requireJSBody(diagnostics, method); if (!repository.methodMap.containsKey(method.getReference())) { continue; } MethodReference proxyRef = repository.methodMap.get(methodRef); MethodHolder proxyMethod = new MethodHolder(proxyRef.getDescriptor()); proxyMethod.getModifiers().add(ElementModifier.NATIVE); proxyMethod.getModifiers().add(ElementModifier.STATIC); boolean inline = repository.inlineMethods.contains(methodRef); AnnotationHolder generatorAnnot = new AnnotationHolder(inline ? InjectedBy.class.getName() : GeneratedBy.class.getName()); generatorAnnot.getValues().put("value", new AnnotationValue(ValueType.parse(JSBodyGenerator.class))); proxyMethod.getAnnotations().add(generatorAnnot); cls.addMethod(proxyMethod); Set<MethodReference> callbacks = repository.callbackMethods.get(proxyRef); if (callbacks != null) { for (MethodReference callback : callbacks) { generateCallbackCaller(cls, callback); } } } }
@Override public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) { for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { AnnotationReader providerAnnot = method.getAnnotations().get(MetadataProvider.class.getName()); if (providerAnnot != null) { transformMetadataMethod(cls, method, diagnostics, innerSource); } providerAnnot = method.getAnnotations().get(ClassScopedMetadataProvider.class.getName()); if (providerAnnot != null) { ValueType[] params = method.getParameterTypes(); if (params.length != 1 && params[0].isObject(PlatformClass.class.getName())) { diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} " + "must take exactly one parameter of type {{c2}}", method.getReference(), ClassScopedMetadataProvider.class.getName(), PlatformClass.class.getName()); } AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( ClassScopedMetadataProviderNativeGenerator.class.getName()))); method.getAnnotations().add(genAnnot); AnnotationHolder noCacheAnnot = new AnnotationHolder(NoCache.class.getName()); method.getAnnotations().add(noCacheAnnot); } } }
annot.getValues().put("value", new AnnotationValue(ValueType.parse(AsyncMethodGenerator.class))); method.getAnnotations().add(annot); annot = new AnnotationHolder(PluggableDependency.class.getName()); annot.getValues().put("value", new AnnotationValue(ValueType.parse(AsyncMethodGenerator.class))); method.getAnnotations().add(annot);
annot.getValues().put("name", new AnnotationValue(publicAlias)); exportedMethod.getAnnotations().add(annot);
cls.addMethod(createMethod); AnnotationHolder genAnnot = new AnnotationHolder(GeneratedBy.class.getName()); genAnnot.getValues().put("value", new AnnotationValue(ValueType.object( MetadataProviderNativeGenerator.class.getName()))); createMethod.getAnnotations().add(genAnnot); refAnnot.getValues().put("value", new AnnotationValue(method.getReference().toString())); createMethod.getAnnotations().add(refAnnot);