Skip to content

Commit 4bf54d5

Browse files
committed
Don't depend on JVM's Annotation toString impl
1 parent 1c644d7 commit 4bf54d5

File tree

6 files changed

+47
-40
lines changed

6 files changed

+47
-40
lines changed

a.check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
inspecting field value
2+
@JsonProperty("REAL_VALUE")
3+
inspecting method getValue
4+
@JsonProperty("REAL_VALUE")
5+
inspecting method setValue
6+
inspecting method value
7+
inspecting method value_$eq
8+
inspecting constructor TestBeanProperty

tests/run/i12492.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inspecting field brandName
2-
@MyColumnBase(name="BRAND_NAME")
2+
interface MyColumnBase
33
inspecting field companyName
4-
@MyColumnBase(name="COMPANY_NAME")
4+
interface MyColumnBase
55
inspecting method brandName
66
inspecting method companyName
77
inspecting constructor MyTable

tests/run/i12492/MyTable.scala

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,3 @@ class MyTable(
88
@MyColumn(name="COMPANY_NAME")
99
val companyName: String,
1010
)
11-
12-
object Test:
13-
def main(args: Array[String]): Unit =
14-
val clasz = classOf[MyTable]
15-
16-
for (m <- clasz.getDeclaredFields.sortBy(_.getName)) {
17-
m.setAccessible(true)
18-
println(s"inspecting field ${m.getName}")
19-
for a <- m.getAnnotations().sortBy(_.toString) do
20-
println(a)
21-
}
22-
23-
for (m <- clasz.getDeclaredMethods.sortBy(_.getName)) {
24-
m.setAccessible(true)
25-
println(s"inspecting method ${m.getName}")
26-
for a <- m.getAnnotations().sortBy(_.toString) do
27-
println(a)
28-
}
29-
30-
for c <- clasz.getDeclaredConstructors.sortBy(_.getName) do
31-
c.setAccessible(true)
32-
println(s"inspecting constructor ${c.getName}")
33-
for p <- c.getParameters.sortBy(_.getName) do
34-
println(s"inspecting param ${p.getName}")
35-
for a <- p.getAnnotations.sortBy(_.toString) do
36-
println(s"annotation $a")

tests/run/i12492/Test.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
object Test:
2+
def main(args: Array[String]): Unit =
3+
val cls = classOf[MyTable]
4+
5+
for (m <- cls.getDeclaredFields.sortBy(_.getName)) {
6+
m.setAccessible(true)
7+
println(s"inspecting field ${m.getName}")
8+
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do
9+
println(a.annotationType)
10+
}
11+
12+
for (m <- cls.getDeclaredMethods.sortBy(_.getName)) {
13+
m.setAccessible(true)
14+
println(s"inspecting method ${m.getName}")
15+
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do
16+
println(a.annotationType)
17+
}
18+
19+
for c <- cls.getDeclaredConstructors.sortBy(_.getName) do
20+
c.setAccessible(true)
21+
println(s"inspecting constructor ${c.getName}")
22+
for p <- c.getParameters.sortBy(_.getName) do
23+
println(s"inspecting param ${p.getName}")
24+
for a <- p.getAnnotations.sortBy(_.annotationType.toString) do
25+
println(a.annotationType)

tests/run/i15318.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inspecting field value
2-
@JsonProperty(value="REAL_VALUE")
2+
interface JsonProperty
33
inspecting method getValue
4-
@JsonProperty(value="REAL_VALUE")
4+
interface JsonProperty
55
inspecting method setValue
66
inspecting method value
77
inspecting method value_$eq

tests/run/i15318/Test.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
object Test:
22
def main(args: Array[String]): Unit =
3-
val clasz = classOf[TestBeanProperty]
3+
val cls = classOf[TestBeanProperty]
44

5-
for (m <- clasz.getDeclaredFields.sortBy(_.getName)) {
5+
for (m <- cls.getDeclaredFields.sortBy(_.getName)) {
66
m.setAccessible(true)
77
println(s"inspecting field ${m.getName}")
8-
for a <- m.getAnnotations().sortBy(_.toString) do
9-
println(a)
8+
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do
9+
println(a.annotationType)
1010
}
1111

12-
for (m <- clasz.getDeclaredMethods.sortBy(_.getName)) {
12+
for (m <- cls.getDeclaredMethods.sortBy(_.getName)) {
1313
m.setAccessible(true)
1414
println(s"inspecting method ${m.getName}")
15-
for a <- m.getAnnotations().sortBy(_.toString) do
16-
println(a)
15+
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do
16+
println(a.annotationType)
1717
}
1818

19-
for c <- clasz.getDeclaredConstructors.sortBy(_.getName) do
19+
for c <- cls.getDeclaredConstructors.sortBy(_.getName) do
2020
c.setAccessible(true)
2121
println(s"inspecting constructor ${c.getName}")
2222
for p <- c.getParameters.sortBy(_.getName) do
2323
println(s"inspecting param ${p.getName}")
24-
for a <- p.getAnnotations.sortBy(_.toString) do
25-
println(s"annotation $a")
24+
for a <- p.getAnnotations.sortBy(_.annotationType.toString) do
25+
println(a.annotationType)

0 commit comments

Comments
 (0)