- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Public methods generated are inaccessible!
Mon, 2011-12-26, 18:16
I have to admit - I tested only under Scala 2.9.x. But what I found is
that all public methods, including ones generated with @BeanProperty
annotation, are generated as in-accessible.
Public methods should be accessible by default. It is a big problem,
since a lot of tools, which use reflection, are relying on this fact.
Is my assessment wrong or should I file the bug?
Tue, 2011-12-27, 19:11
#2
Re: Public methods generated are inaccessible!
Simon,
In my experience (2.9.x) even if I define the method myself (without
@BeanProperty) it is generated as in-accessible
Tue, 2011-12-27, 19:51
#3
Re: Re: Public methods generated are inaccessible!
On Tue, Dec 27, 2011 at 12:07 PM, Eugene Ryzhikov <eryzhikov@gmail.com> wrote:
Appears to be correct, at least in REPL:
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). Type in expressions to have them evaluated.Type :help for more information.
scala> class Foo { | def bar = 42 | } defined class Foo
scala> classOf[Foo].getMethod("bar") res0: java.lang.reflect.Method = public int Foo.bar()
scala> res0.isAccessible res1: Boolean = false
Simon,
In my experience (2.9.x) even if I define the method myself (without
@BeanProperty) it is generated as in-accessible
Appears to be correct, at least in REPL:
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). Type in expressions to have them evaluated.Type :help for more information.
scala> class Foo { | def bar = 42 | } defined class Foo
scala> classOf[Foo].getMethod("bar") res0: java.lang.reflect.Method = public int Foo.bar()
scala> res0.isAccessible res1: Boolean = false
as far as I understand those methods generated by BeanProperty are added to the "internal" model quite late, so then end up in the class file, but do not really exist in the eyes of the compiler when checking if some method exists.
There should already exist some issue with further details in JIRA.
Hope that helps a bit.
Bye,
Simon