This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Public methods generated are inaccessible!

3 replies
eugener
Joined: 2009-09-14,
User offline. Last seen 12 weeks 6 days ago.

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?

Simon Ochsenreither
Joined: 2011-07-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Public methods generated are inaccessible!
Hi Eugene,

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
eugener
Joined: 2009-09-14,
User offline. Last seen 12 weeks 6 days ago.
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

nilskp
Joined: 2009-01-30,
User offline. Last seen 1 year 27 weeks ago.
Re: Re: Public methods generated are inaccessible!
On Tue, Dec 27, 2011 at 12:07 PM, Eugene Ryzhikov <eryzhikov@gmail.com> wrote:
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 

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland