Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Osgi class loader bug?
Osgi class loader bug? [message #466475] Thu, 19 April 2007 17:27 Go to next message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

Hi,

I discovered this while trying to load an obfuscated lib.

If you create a java file with a field name *new.super* the osgi class
loader fails to load it (class format error) *BUT* the java class loader
does it fine...

Step to reproduce :

Create this class:
public class CLTest
{

String new_super;
}

--> modifie the generated .class file by replacing *new_super* with
*new.super*

--> In an another java class try to instanciate the CLTest (new CLTest()).

1°) if you launch as a java program it works.

2°) If you try to instantiate CLTest in your plugin's Activator you will
get this:

java.lang.ClassFormatError: Illegal field name "new.super" in class
com/*****/****/core/CLTest
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

[............]

at
org.eclipse.osgi.framework.internal.core.AbstractBundle.load BundleActivator(AbstractBundle.java:136)


How is wrong ?

valere.
Re: Osgi class loader bug? [message #466476 is a reply to message #466475] Thu, 19 April 2007 20:46 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Why would you hand-edit the class file like this? . is not a valid identifier in a simple name, so it's not a valid name for a field anyway. VMs are not required to accept this as a valid name; therefore, nor are classloaders.

Alex.
Re: Osgi class loader bug? [message #466490 is a reply to message #466476] Fri, 20 April 2007 07:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

>>VMs are not required to accept this as a valid name; therefore, nor
are classloaders.

I know that it is not a valid indentifier but the sun classLoader loads
the class!
I can inspect it with my debugger and see the field *new.super*.
So i just ask why the osgi class loader fails.

> Why would you hand-edit the class file like this?

It is just to show how to reproduce it. But in fact i have a third-party
library that is obfuscated (with a field renamed *new.super*), and i
cannot use it with osgi.

I just say that, if the sun classloader can load this class, the osgi
classloader should load it too.

valere.



Alex Blewitt wrote:
> Why would you hand-edit the class file like this? . is not a valid identifier in a simple name, so it's not a valid name for a field anyway. VMs are not required to accept this as a valid name; therefore, nor are classloaders.
>
> Alex.
Re: Osgi class loader bug? [message #466503 is a reply to message #466490] Fri, 20 April 2007 08:49 Go to previous messageGo to next message
Stefan Langer is currently offline Stefan LangerFriend
Messages: 236
Registered: July 2009
Senior Member
valere fedronic schrieb:
> >>VMs are not required to accept this as a valid name; therefore, nor
> are classloaders.
>
> I know that it is not a valid indentifier but the sun classLoader loads
> the class!
> I can inspect it with my debugger and see the field *new.super*.
> So i just ask why the osgi class loader fails.
>
> > Why would you hand-edit the class file like this?
>
> It is just to show how to reproduce it. But in fact i have a third-party
> library that is obfuscated (with a field renamed *new.super*), and i
> cannot use it with osgi.
>
> I just say that, if the sun classloader can load this class, the osgi
> classloader should load it too.
>
Actually no! This is a bug in the obfuscated code and should be reported
against the third class lib.
I would go as far as say that loading this class in the vm is a bug
since new.super clearly violates the java spec.

Regards
Stefan
Re: Osgi class loader bug? [message #466507 is a reply to message #466503] Fri, 20 April 2007 09:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

For those interested:

The lib is obfuscated with yGuard using this option :

<obfuscate ...>
<property name="language-conformity" value="illegal"/>

And the doc specifies that :
*illegal* will produce names, that will crash some tools but usually not
the jvm, but JBuilder7 in many occasions for example.


--> will crash some tools but *usually not* the jvm.
It crashes osgi..

valere.

Stefan Langer wrote:
> valere fedronic schrieb:
>> >>VMs are not required to accept this as a valid name; therefore, nor
>> are classloaders.
>>
>> I know that it is not a valid indentifier but the sun classLoader
>> loads the class!
>> I can inspect it with my debugger and see the field *new.super*.
>> So i just ask why the osgi class loader fails.
>>
>> > Why would you hand-edit the class file like this?
>>
>> It is just to show how to reproduce it. But in fact i have a
>> third-party library that is obfuscated (with a field renamed
>> *new.super*), and i cannot use it with osgi.
>>
>> I just say that, if the sun classloader can load this class, the osgi
>> classloader should load it too.
>>
> Actually no! This is a bug in the obfuscated code and should be reported
> against the third class lib.
> I would go as far as say that loading this class in the vm is a bug
> since new.super clearly violates the java spec.
>
> Regards
> Stefan
Re: Osgi class loader bug? [message #466511 is a reply to message #466507] Fri, 20 April 2007 09:39 Go to previous messageGo to next message
Stefan Langer is currently offline Stefan LangerFriend
Messages: 236
Registered: July 2009
Senior Member
As the options says "illegal".
Its this kind of coding that produced the mess with HTML and CSS in IE.
Why do we have a java standard if software doesn't comply to it?
Being to fault tolerant leads to buggy, unmaintainable, vendor specific
code and as such I stand to my previous statement it is not a bug but a
feature. If you use illegal class formats don't expect confirming code
to support it.

Regards
Stefan

valere fedronic schrieb:
> For those interested:
>
> The lib is obfuscated with yGuard using this option :
>
> <obfuscate ...>
> <property name="language-conformity" value="illegal"/>
>
> And the doc specifies that :
> *illegal* will produce names, that will crash some tools but usually not
> the jvm, but JBuilder7 in many occasions for example.
>
>
> --> will crash some tools but *usually not* the jvm.
> It crashes osgi..
>
> valere.
>
> Stefan Langer wrote:
>> valere fedronic schrieb:
>>> >>VMs are not required to accept this as a valid name; therefore,
>>> nor are classloaders.
>>>
>>> I know that it is not a valid indentifier but the sun classLoader
>>> loads the class!
>>> I can inspect it with my debugger and see the field *new.super*.
>>> So i just ask why the osgi class loader fails.
>>>
>>> > Why would you hand-edit the class file like this?
>>>
>>> It is just to show how to reproduce it. But in fact i have a
>>> third-party library that is obfuscated (with a field renamed
>>> *new.super*), and i cannot use it with osgi.
>>>
>>> I just say that, if the sun classloader can load this class, the osgi
>>> classloader should load it too.
>>>
>> Actually no! This is a bug in the obfuscated code and should be
>> reported against the third class lib.
>> I would go as far as say that loading this class in the vm is a bug
>> since new.super clearly violates the java spec.
>>
>> Regards
>> Stefan
Re: Osgi class loader bug? [message #466515 is a reply to message #466507] Fri, 20 April 2007 11:09 Go to previous messageGo to next message
Neil Bartlett is currently offline Neil BartlettFriend
Messages: 93
Registered: July 2009
Member
Valere,

I hope you're not still suggesting that this is an OSGi problem. The documentation for yGuard clearly states that the option you have used generates illegal bytecode. The fact that it works in the some of Sun's classloaders is pure chance - it might not work in older or newer versions of those same classloaders.

This is a highly non-portable feature which should be avoided at all costs. Garbage in, garbage out.

Neil
Re: Osgi class loader bug? [message #466519 is a reply to message #466515] Fri, 20 April 2007 11:33 Go to previous message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

Hi Bartlett,

I never suggest that it was an osgi problem (i put a question mark).
And my last post was to say that it was an yguard problem!

Propose to transform your code into an invalid code.... this is
obfuscating ;) !

I didn't want to upset anybody, and i am sorry if it is the case.
Thanks all for your responses.

valere.

Neil Bartlett wrote:
> Valere,
>
> I hope you're not still suggesting that this is an OSGi problem. The documentation for yGuard clearly states that the option you have used generates illegal bytecode. The fact that it works in the some of Sun's classloaders is pure chance - it might not work in older or newer versions of those same classloaders.
>
> This is a highly non-portable feature which should be avoided at all costs. Garbage in, garbage out.
>
> Neil
Previous Topic:Exiting RCP with System.exit(1)
Next Topic:Listener to View minimise/maxmise icons clicked?
Goto Forum:
  


Current Time: Wed Sep 25 01:27:17 GMT 2024

Powered by FUDForum. Page generated in 0.04149 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top