- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Traits and reflection
Mon, 2009-03-09, 00:55
I'd love to create an instance of a class using reflection with a given trait. Anybody know how this is done.
For example, I'd like the following
trait Krunk{}
Class.forName("java.util.Date") with Krunk
Any help is appreciated!
-Dustin
For example, I'd like the following
trait Krunk{}
Class.forName("java.util.Date") with Krunk
Any help is appreciated!
-Dustin
Mon, 2009-03-09, 13:37
#2
Re: Re: Traits and reflection
Is that a funny way of saying "no, some form of 'Class.forName("java.util.Date").newInstance with Krunk' is not possible."?
-Dustin
On Mar 9, 2009 4:28am, Szymon Jachim <sjachim@gmail.com> wrote:
> Traits cocktail can not be prepared during the party.
> Unless you are scala-compiler.jar... ;-)
>
>
>
> I hope this will help you get the date you want.
>
>
> Szymon
>
>
> On Mon, Mar 9, 2009 at 12:50 AM, Dustin Whitney dustin.whitney@gmail.com> wrote:
>
> I'd love to create an instance of a class using reflection with a given trait. Anybody know how this is done.
>
> For example, I'd like the following
>
> trait Krunk{}
> Class.forName("java.util.Date") with Krunk
>
>
>
> Any help is appreciated!
>
> -Dustin
>
>
>
>
> --
> ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ı ǝɯıʇ ʇsɐן ǝɥʇ sı sıɥʇ
>
>
>
-Dustin
On Mar 9, 2009 4:28am, Szymon Jachim <sjachim@gmail.com> wrote:
> Traits cocktail can not be prepared during the party.
> Unless you are scala-compiler.jar... ;-)
>
>
>
> I hope this will help you get the date you want.
>
>
> Szymon
>
>
> On Mon, Mar 9, 2009 at 12:50 AM, Dustin Whitney dustin.whitney@gmail.com> wrote:
>
> I'd love to create an instance of a class using reflection with a given trait. Anybody know how this is done.
>
> For example, I'd like the following
>
> trait Krunk{}
> Class.forName("java.util.Date") with Krunk
>
>
>
> Any help is appreciated!
>
> -Dustin
>
>
>
>
> --
> ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ı ǝɯıʇ ʇsɐן ǝɥʇ sı sıɥʇ
>
>
>
Mon, 2009-03-09, 13:47
#3
Re: Re: Traits and reflection
This is not possible on the JVM without classloader tricks involving
generating bytecode at runtime. Scala doesn't do that.
2009/3/9 :
> Is that a funny way of saying "no, some form of
> 'Class.forName("java.util.Date").newInstance with Krunk' is not possible."?
>
> -Dustin
>
> On Mar 9, 2009 4:28am, Szymon Jachim wrote:
>> Traits cocktail can not be prepared during the party.
>> Unless you are scala-compiler.jar... ;-)
>>
>>
>>
>> I hope this will help you get the date you want.
>>
>>
>> Szymon
>>
>>
>> On Mon, Mar 9, 2009 at 12:50 AM, Dustin Whitney dustin.whitney@gmail.com>
>> wrote:
>>
>> I'd love to create an instance of a class using reflection with a given
>> trait. Anybody know how this is done.
>>
>> For example, I'd like the following
>>
>> trait Krunk{}
>> Class.forName("java.util.Date") with Krunk
>>
>>
>>
>> Any help is appreciated!
>>
>> -Dustin
>>
>>
>>
>>
>> --
>> ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ı ǝɯıʇ ʇsɐן ǝɥʇ sı sıɥʇ
>>
>>
>>
Unless you are scala-compiler.jar... ;-)
I hope this will help you get the date you want.
Szymon
On Mon, Mar 9, 2009 at 12:50 AM, Dustin Whitney <dustin.whitney@gmail.com> wrote:
--
ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ı ǝɯıʇ ʇsɐן ǝɥʇ sı sıɥʇ