Nope, Unsafe is gory bull****t :)

There is only one situation where you still need it: if you manually pack 
constant definitions in an existing class. But this is highly non-portable.

LieGrue,
strub



----- Original Message -----
> From: Romain Manni-Bucau <rmannibu...@gmail.com>
> To: dev@openejb.apache.org; Mark Struberg <strub...@yahoo.de>
> Cc: 
> Sent: Monday, December 31, 2012 12:20 PM
> Subject: Re: ASM proxy improvement
> 
> Hi Mark,
> 
> unsafe is used in all frameworks so i'd consider it as safe ;)
> 
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
> 
> 
> 
> 2012/12/31 Mark Struberg <strub...@yahoo.de>:
>>  hi folks!
>> 
>>  While looking at the ASM proxy David imported to OWB I saw that it's 
> based on the sun.misc.Unsafe class.
>>  This makes this approach non-portable to other JVMs.
>> 
>>  I now played around with an alternative way to do the same: I just invoke 
> the protected ClassLoader#defineClass method via reflection instead. In my 
> tests 
> this works pretty well already. See defineAndLoadClass inĀ  [1]. Maybe I can 
> even 
> remove the 2nd explicit loadClass. It also works without in java6 but the 
> docs 
> says that the class is only available after doing a loadClass. Would need 
> some 
> more tests to make sure it also works portable without this redundant call.
>> 
>>  Happy about any feedback.
>> 
>> 
>>  LieGrue,
>>  strub
>> 
>> 
>>  [1] 
> http://svn.apache.org/repos/asf/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/asm/InterceptorDecoratorProxyFactory.java
>> 
>

Reply via email to