Skip to content

Commit d430b03

Browse files
committed
Fix BeanInfo generation for GenBCode
1 parent 9e1b464 commit d430b03

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
11081108

11091109
constructor.visitVarInsn(asm.Opcodes.ALOAD, 0)
11101110
// push the class
1111-
constructor.visitLdcInsn(exemplar(cls).c)
1111+
constructor.visitLdcInsn(exemplar(cls).c.toASMType)
11121112

11131113
// push the string array of field information
11141114
constructor.visitLdcInsn(new java.lang.Integer(fieldList.length))

test/files/jvm/beanInfo.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
property descriptors
2+
x -- int -- public int p.C.x() -- null
3+
y -- class java.lang.String -- public java.lang.String p.C.y() -- public void p.C.y_$eq(java.lang.String)
4+
z -- class scala.collection.immutable.List -- public scala.collection.immutable.List p.C.z() -- public void p.C.z_$eq(scala.collection.immutable.List)
5+
method descriptors
6+
f -- public p.C p.C.f()

test/files/jvm/beanInfo/C_1.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package p
2+
3+
@scala.beans.BeanInfo
4+
class C {
5+
val x: Int = 0
6+
var y: String = ""
7+
var z: List[_] = Nil
8+
def f: C = ???
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object Test extends App {
2+
val info = java.beans.Introspector.getBeanInfo(classOf[p.C])
3+
4+
println("property descriptors")
5+
6+
val pds = info.getPropertyDescriptors
7+
for (pd <- pds) {
8+
println(s"${pd.getName} -- ${pd.getPropertyType} -- ${pd.getReadMethod} -- ${pd.getWriteMethod}")
9+
}
10+
11+
println("method descriptors")
12+
13+
val mds = info.getMethodDescriptors
14+
for (md <- mds) {
15+
println(s"${md.getName} -- ${md.getMethod}")
16+
}
17+
}

0 commit comments

Comments
 (0)