Meta-annotations written at use-site are ignored
See original GitHub issueCompiler version
3.0.0
Minimized code
This is an issue I’ve encountered while trying to port squeryl to scala 3.
In a MyColumnBase.java
file:
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface MyColumnBase {
String value() default "";
String name() default "";
}
and in a scala file:
import annotation.meta.field
type MyColumn = MyColumnBase @field
class MyTable(
@MyColumn(name="BRAND_NAME")
val brandName: String
) {
@MyColumn(name="WEIGHT")
val weightInGrams: Option[String] = None
}
val clasz = classOf[MyTable]
for(m <- clasz.getDeclaredFields) {
m.setAccessible(true)
if(m.getName == "weightInGrams" || m.getName == "brandName"){
println(s"inspecting field ${m.getName}")
assert(m.getAnnotations().size == 1, s"no annotation found for ${m.getName}")
}
}
Output
Array() had size 0 instead of expected size 1 no annotation found for brandName
Expectation
I would expect to see the annotation on the field brandName
. In scala 2.13, I can at least.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Why does Hibernate Validator ignore my custom annotations ...
I was debugging into Hibernate Validator and when it lists found annotations, the custom ones are not added in the bean meta data...
Read more >Nullable meta annotations are ignored · Issue #973 - GitHub
A schema that contains @NotBlank inside a meta-annotation is not marked as required but should be. Provide with a sample code (HelloController) ...
Read more >Annotations | Kotlin
Annotations are means of attaching metadata to code. To declare an annotation, put the annotation modifier in front of a class:.
Read more >Support Java custom meta-annotations to selectively ignore ...
In our code base, the objects exchanged via our REST API are defined as classes (views) with all fields public, no constructor (i.e....
Read more >Wikipedia:Ignored feature requests
The village pump is crowded, and is explicitly not for the requesting of new features. Use MediaZilla or the correct meta page instead....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same thing yes.
In that case the meta-annotation isn’t needed since we’re directly annotating a field (from https://www.scala-lang.org/api/current/scala/annotation/meta/index.html):