1
Ich habe ein Problem mit Java-Annotationen, weil einige Funktionen veraltet sind und ich nicht weiß, wie man es mit "Annotation.tree" schreibt, was vorgeschlagen wird.Java-Annotationen javaArgs und LiteralArguments sind veraltet
hier Code veraltet:
lazy val lengthOfAnnotation = p.annotations.find(_.tpe == ru.typeOf[Len])
lazy val maxLength = lengthOfAnnotation.get.javaArgs.head._2.asInstanceOf[ru.LiteralArgument].value.value.asInstanceOf[Int]
hier ist neuer Code, der nicht funktioniert:
lazy val lengthOfAnnotation = p.annotations.find(_.tree.tpe == ru.typeOf[Len])
lazy val maxLength = lengthOfAnnotation.get.tree.children.tail.head.tpe.value.asInstanceOf[Int]
Fehler:
method javaArgs in trait AnnotationApi is deprecated: Use tree.children.tail instead
type LiteralArgument in trait Annotations is deprecated: Use Annotation.tree to inspect annotation arguments
method value in trait LiteralArgumentApi is deprecated: Use Annotation.tree to inspect annotation arguments