Re: Re: ASM4 / Java 7

Jeremy Manson <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CAHF5=kSg-Ru7-ppQcpiUdfDtah8U0FthS+q4oHDdNRg8SR9v7Q@mail.gmail.com>
Hi Eugene,

This occurred to me when writing my version.  For my use case, which
rewrites at class load time using java.lang.instrument, the vast
majority of necessary superclasses are going to be available at
rewrite time.  My code tries to use Class.forName first: only if the
class is unavailable does it try to load it from the classloader.  I
don't know if that is a good enough strategy to checkin as is, but it
seems preferable to what's in there now, which tries Class.forName,
and then dies on failure.

This isn't good enough for pure static rewriting, of course.  For
that, you probably need the user to supply the superclasses - the ones
on the classpath may not be the ones you want.

Jeremy

On Fri, Aug 26, 2011 at 6:32 PM, Eugene Kuleshov <[email protected]> wrote:
> Jeremy,
>
>  The problem is that code from the test you are referring to is too
> naive to be ready for use in production. For instance, it should
> maintain some kind of repository of the loaded class info and have
> some kind of abstraction for loading class data. Our original
> conclusion was that might be out of scope for ASM, but if you believe
> the issue became common for Java 7, perhaps we may have to add
> something to the commons package. Now it is only matter of finding a
> volunteer. :)
>
>  regards,
>  Eugene
>
>
> On Fri, Aug 26, 2011 at 6:59 PM, Jeremy Manson <[email protected]> wrote:
>> Hi all,
>>
>> I seem to be having a problem with ASM 3.3 and Java 7...
>>
>> Basically, the problem is that:
>>
>> 1) I have to generate StackMaps when transforming bytecode with Java
>> 7, or I get a VerifyError,
>> 2) I can't generate StackMaps using ClassWriter, because doing so
>> requires superclasses to be loaded - if I load a subclass B as a
>> result of loading a superclass A, then A isn't available when B is
>> transformed.
>>
>> You guys have a workaround for this, which is basically "copy the code
>> in http://websvn.ow2.org/filedetails.php?repname=asm&path=%2Ftrunk%2Fasm%2Ftest%2Fconform%2Forg%2Fow2%2Fasm%2FClassWriterComputeFramesTest.java".
>>  But doesn't it seem as if this would be a common enough problem for
>> the code to be extracted from this test to somewhere everyone can use
>> it, if not made the default behavior for ClassWriter?  Do I have the
>> wrong end of the stick here?
>>
>> If it is just a question of someone extracting it, I've done so, and
>> if you want me to send it along, I can.  If I'm completely
>> misunderstanding the problem, I'd be interested to hear about that,
>> too.
>>
>> (Why do I care?  Mostly, I don't want to duplicate ASM's code in my
>> little OSS ASM project.)
>>
>> Jeremy
>>
>>
>> --
>> 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
>>
>>
>
>
> --
> 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
>
>
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.