Re: Re: Loading int.class onto the stack

Rémi Forax <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
  Le 02/02/2011 21:32, Scott Vachalek a écrit :
> Afaik, primitives do not have true Class objects and 
> int.class/Integer.TYPE are just a thin facade to unify the type 
> system.  I wouldn't be surprised that they won't fit into the constant 
> pool as Classes.  Before Java 1.5, even constructs like String.class 
> weren't supported by LDC, they generated a block of code that cached 
> Class.forName().

primitive classes are true Class objects from the VM point of view but
they can't be lookup by classloader/Class.forName(). That why LDC 
int.class doesn't work.

Rémi

>
> On Wed, Feb 2, 2011 at 12:15 PM, Arshan Dabirsiaghi 
> <[email protected] <mailto:[email protected]>> 
> wrote:
>
>     Sorry in advance for what is probably a stupid question.
>
>     How do I load the int.class primitive Class representation (as
>     opposed to Integer.class) via an ldc instruction? I've tried the
>     following:
>
>     visitLdcInsn( Type.getType(int.class) );
>     visitLdcInsn( Type.INT_TYPE );
>     visitLdcInsn( Type.getType("I") );
>
>     These either cause NoClassDefFoundErrors or generate the wrong
>     type (they generate Integer.class instead of int.class).
>
>     The compiler generates GETSTATIC instructions to fetch the
>     int.class indirectly from Integer.TYPE, like for the code show:
>
>     Class[] classes = new Class[]{int.class};
>
>     Emulating this isn't currently causing us any direct issues, but I
>     don't know if it's a good idea or performant when compared to a
>     direct reference to int.class.
>
>     Thanks,
>     Arshan
>
>
>     --
>     You receive this message as a subscriber of the [email protected]
>     <mailto:[email protected]> mailing list.
>     To unsubscribe: mailto:[email protected]
>     <mailto:[email protected]>
>     For general help: mailto:[email protected]
>     <mailto:[email protected]>?subject=help
>     OW2 mailing lists service home page: http://www.ow2.org/wws
>
>
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.