Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

rajsaini
Hi,

org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
*javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
implementation. ServiceRegistry class internally uses sun.misc.Service
class which is internal to sun and may not be part of other JDKs.

Starting with JDK 1.6, java.util.ServiceLoader class is provided to
replace the javax.imageio.spi.ServiceRegistry class and this class does
not depend on sun.misc.Service class. This is minor two line code change
and if community agree I can provide the patch.

Thanks,

Raj

Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

Jacques Le Roux
Administrator
Hi Raj,

I can't see any reasons to not create a Jira and a patch

Thanks

Jacques

From: "Raj Saini" <[hidden email]>

> Hi,
>
> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
> implementation. ServiceRegistry class internally uses sun.misc.Service
> class which is internal to sun and may not be part of other JDKs.
>
> Starting with JDK 1.6, java.util.ServiceLoader class is provided to
> replace the javax.imageio.spi.ServiceRegistry class and this class does
> not depend on sun.misc.Service class. This is minor two line code change
> and if community agree I can provide the patch.
>
> Thanks,
>
> Raj
>

Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

rajsaini
Thanks Jacques. Will create a JIRA issue and attach the patch.

Raj

Jacques Le Roux wrote:

> Hi Raj,
>
> I can't see any reasons to not create a Jira and a patch
>
> Thanks
>
> Jacques
>
> From: "Raj Saini" <[hidden email]>
>> Hi,
>>
>> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
>> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
>> implementation. ServiceRegistry class internally uses
>> sun.misc.Service class which is internal to sun and may not be part
>> of other JDKs.
>>
>> Starting with JDK 1.6, java.util.ServiceLoader class is provided to
>> replace the javax.imageio.spi.ServiceRegistry class and this class
>> does not depend on sun.misc.Service class. This is minor two line
>> code change and if community agree I can provide the patch.
>>
>> Thanks,
>>
>> Raj
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

Adam Heath-2
In reply to this post by rajsaini
Raj Saini wrote:
> Hi,
>
> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
> implementation. ServiceRegistry class internally uses sun.misc.Service
> class which is internal to sun and may not be part of other JDKs.

So?  ServiceRegistry is a public class, who cares how it works internally.

> Starting with JDK 1.6, java.util.ServiceLoader class is provided to
> replace the javax.imageio.spi.ServiceRegistry class and this class does
> not depend on sun.misc.Service class. This is minor two line code change
> and if community agree I can provide the patch.

The api isn't exactly compatible, but yes.

Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

Adam Heath-2
Adam Heath wrote:

> Raj Saini wrote:
>> Hi,
>>
>> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
>> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
>> implementation. ServiceRegistry class internally uses sun.misc.Service
>> class which is internal to sun and may not be part of other JDKs.
>
> So?  ServiceRegistry is a public class, who cares how it works internally.
>
>> Starting with JDK 1.6, java.util.ServiceLoader class is provided to
>> replace the javax.imageio.spi.ServiceRegistry class and this class does
>> not depend on sun.misc.Service class. This is minor two line code change
>> and if community agree I can provide the patch.
>
> The api isn't exactly compatible, but yes.

Btw, I'm happy to just do this, but I'm a bit busy for the next few
days.  There's no immediate hurry for this either.

Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

rajsaini
In reply to this post by Adam Heath-2
Adam Heath wrote:

> Raj Saini wrote:
>  
>> Hi,
>>
>> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
>> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
>> implementation. ServiceRegistry class internally uses sun.misc.Service
>> class which is internal to sun and may not be part of other JDKs.
>>    
>
> So?  ServiceRegistry is a public class, who cares how it works internally.
>  
Try debugging the code in Eclipse and you wont be able to attach source
code the source code internal classes is not part of the JDK. I had hard
time resolving a class loading issues as I could not look into look into
the source code in Eclipse debugger.
>  
>> Starting with JDK 1.6, java.util.ServiceLoader class is provided to
>> replace the javax.imageio.spi.ServiceRegistry class and this class does
>> not depend on sun.misc.Service class. This is minor two line code change
>> and if community agree I can provide the patch.
>>    
>
> The api isn't exactly compatible, but yes.
>  
You are right they are not exactly compatible. I had to add one more
line of code to replace the ServiceRegistry with ServiceLoader.

Thanks,

Raj
Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

Adam Heath-2
Raj Saini wrote:

> Adam Heath wrote:
>> Raj Saini wrote:
>>  
>>> Hi,
>>>
>>> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
>>> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
>>> implementation. ServiceRegistry class internally uses sun.misc.Service
>>> class which is internal to sun and may not be part of other JDKs.
>>>    
>>
>> So?  ServiceRegistry is a public class, who cares how it works
>> internally.
>>  
> Try debugging the code in Eclipse and you wont be able to attach source
> code the source code internal classes is not part of the JDK. I had hard
> time resolving a class loading issues as I could not look into look into
> the source code in Eclipse debugger.

Huh?  ServiceRegistry is not an internal class, it's a public class.
There's nothing keeping ServiceLoader from being an *exact* copy of
ServiceRegistry, with any and all same-class internal uses, including
using some internal jvm-specific class.

So, to change this class just because eclipse can't debug it because
it's trying to read the source of some internal jvm class is the wrong
reason.


Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

rajsaini
In reply to this post by Adam Heath-2
Thanks Adam. Look forward to it.

Raj

Adam Heath wrote:

> Adam Heath wrote:
>  
>> Raj Saini wrote:
>>    
>>> Hi,
>>>
>>> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
>>> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
>>> implementation. ServiceRegistry class internally uses sun.misc.Service
>>> class which is internal to sun and may not be part of other JDKs.
>>>      
>> So?  ServiceRegistry is a public class, who cares how it works internally.
>>
>>    
>>> Starting with JDK 1.6, java.util.ServiceLoader class is provided to
>>> replace the javax.imageio.spi.ServiceRegistry class and this class does
>>> not depend on sun.misc.Service class. This is minor two line code change
>>> and if community agree I can provide the patch.
>>>      
>> The api isn't exactly compatible, but yes.
>>    
>
> Btw, I'm happy to just do this, but I'm a bit busy for the next few
> days.  There's no immediate hurry for this either.
>
>
>  


Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

rajsaini
In reply to this post by Adam Heath-2
You can find a better description of the problem here:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5014358

Thanks,

Raj

Adam Heath wrote:

> Raj Saini wrote:
>  
>> Adam Heath wrote:
>>    
>>> Raj Saini wrote:
>>>  
>>>      
>>>> Hi,
>>>>
>>>> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
>>>> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
>>>> implementation. ServiceRegistry class internally uses sun.misc.Service
>>>> class which is internal to sun and may not be part of other JDKs.
>>>>    
>>>>        
>>> So?  ServiceRegistry is a public class, who cares how it works
>>> internally.
>>>  
>>>      
>> Try debugging the code in Eclipse and you wont be able to attach source
>> code the source code internal classes is not part of the JDK. I had hard
>> time resolving a class loading issues as I could not look into look into
>> the source code in Eclipse debugger.
>>    
>
> Huh?  ServiceRegistry is not an internal class, it's a public class.
> There's nothing keeping ServiceLoader from being an *exact* copy of
> ServiceRegistry, with any and all same-class internal uses, including
> using some internal jvm-specific class.
>
> So, to change this class just because eclipse can't debug it because
> it's trying to read the source of some internal jvm class is the wrong
> reason.
>
>
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: Replace javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

Adam Heath-2
Raj Saini wrote:
> You can find a better description of the problem here:
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5014358

So?  What does that have to do with my observation, that any class
provided by the jvm may end up using internal classes, and that
eclipse shouldn't bitch about it.


>
> Thanks,
>
> Raj
>
> Adam Heath wrote:
>> Raj Saini wrote:
>>  
>>> Adam Heath wrote:
>>>    
>>>> Raj Saini wrote:
>>>>  
>>>>      
>>>>> Hi,
>>>>>
>>>>> org.ofbiz.base.util.UtilObject#getObjectFromFactory class uses
>>>>> *javax.imageio.spi.ServiceRegistry *class to load DelegatorFactory
>>>>> implementation. ServiceRegistry class internally uses sun.misc.Service
>>>>> class which is internal to sun and may not be part of other JDKs.
>>>>>            
>>>> So?  ServiceRegistry is a public class, who cares how it works
>>>> internally.
>>>>        
>>> Try debugging the code in Eclipse and you wont be able to attach source
>>> code the source code internal classes is not part of the JDK. I had hard
>>> time resolving a class loading issues as I could not look into look into
>>> the source code in Eclipse debugger.
>>>    
>>
>> Huh?  ServiceRegistry is not an internal class, it's a public class.
>> There's nothing keeping ServiceLoader from being an *exact* copy of
>> ServiceRegistry, with any and all same-class internal uses, including
>> using some internal jvm-specific class.
>>
>> So, to change this class just because eclipse can't debug it because
>> it's trying to read the source of some internal jvm class is the wrong
>> reason.
>>
>>
>>
>>  
>