users@codemodel.java.net

Re: static import

From: Johannes Schneider <mailings_at_cedarsoft.com>
Date: Wed, 16 Jun 2010 19:23:30 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here is a very simple test case:


    JDefinedClass daClass = model._class( "a.b.c.Foo" );

    JMethod method = daClass.method( JMod.PUBLIC, Void.TYPE, "aMethod" );

    method.body().decl( model.ref( "a.b.c.d.Bar1" ), "bar1" );
    method.body().decl( model.ref( "a.b.c.d.Bar1" ), "bar2" );

    JClass bar2Type = model.ref( "a.b.c.d.Bar2" );
    method.body().decl( bar2Type, "bar1" );
    method.body().decl( bar2Type, "bar2" );


I have worked around that problem using a HashMap (mapping the fqn to
the created ref).


Thanks,

Johannes


On 06/15/2010 11:29 PM, Aleksei Valikov wrote:
> Hi,
>
>> I think the problem (if it is one) is located in:
>>
>> com.sun.codemodel.JCodeModel#ref(String fullyQualifiedClassName)
>>
>> If called multiple times with the same fully qualified class name, it
>> returns new instances of JDirectClass every time.
>> Maybe there should be some kind of Map<String,JDirectClass> be introduced?
>
> Hard to say. Would you mind writing a test to reproduce your case?
>
> Bye.
> /lexi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_codemodel.dev.java.net
> For additional commands, e-mail: users-help_at_codemodel.dev.java.net
>

- --
Johannes Schneider - blog.cedarsoft.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBAgAGBQJMGQiSAAoJEAytD9R7Qv6d/vUIAL/4NTrblFjGZDlIY4fD1vyU
FnjO1ngPEGeqUYRsD5cHKY2G5hLr9mc9YUnt4lkHG8b21g5GTMw3CmrgCnwpEhfs
cJmaY6DyW1qDRsLtnSKb9zdZiPvZd24Mp6n1xVq8q9RQP9mrW9OsrvAQcZrtd6Y3
qKTpFNZERirs/xo5GmZQ3j2TPBzjDR3t/CnlplfFAVlZcP6ytWqSojEoKpZI5l+1
mTdABFRQ50DbScd+lPYus8YbE/EYvDGYXovrPFg2P2kM18/Ajkh0pNRZ6cyvFVHC
quagOFKhe0ctoyiqhF2Im55mi+tcehI7X3iOzzd8n+z8gTakXqXoTxGZD6abNlo=
=/49b
-----END PGP SIGNATURE-----