Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0M15
    • Component/s: None
    • Labels:
    • Patch Info:
      Patch Available

      Description

      spec - http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/spi/ServiceRegistry.html#lookupProviders(java.lang.Class)

      I have created a new Iterator - "private static class LookupProvidersIterator implements Iterator" for this method. The iterator needs to instantiates new objects and throws ServiceConfigurationError exception at runtime, so we have to use customized Iterator.

      The flow:
      1. call ClassLoader.getResourse(String) to get a set of provider-configuration files that related to the specified class.

      2. The iterator parses all provider-configuration files to get the names of provider classes

      3. In LookupProvidersIterator.next(), instantiate objects

        Activity

        Hide
        Lang Yang added a comment -

        Thanks Mark for the change.

        Verified. The patch has been applied as expected

        Show
        Lang Yang added a comment - Thanks Mark for the change. Verified. The patch has been applied as expected
        Hide
        Hudson added a comment -

        Integrated in Harmony-select-1.5-head-linux-x86_64 #95 (See https://hudson.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/95/)
        Apply patch from "HARMONY-6553 Implement
        ServiceRegistry.lookupProviders(class)".

        Add a <metainf> line to test jar ant task so that the test passes when
        run from the hdk.

        Show
        Hudson added a comment - Integrated in Harmony-select-1.5-head-linux-x86_64 #95 (See https://hudson.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/95/ ) Apply patch from " HARMONY-6553 Implement ServiceRegistry.lookupProviders(class)". Add a <metainf> line to test jar ant task so that the test passes when run from the hdk.
        Hide
        Hudson added a comment -

        Integrated in Harmony-1.5-head-linux-x86_64 #933 (See https://hudson.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/933/)
        Apply patch from "HARMONY-6553 Implement
        ServiceRegistry.lookupProviders(class)".

        Add a <metainf> line to test jar ant task so that the test passes when
        run from the hdk.

        Show
        Hudson added a comment - Integrated in Harmony-1.5-head-linux-x86_64 #933 (See https://hudson.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/933/ ) Apply patch from " HARMONY-6553 Implement ServiceRegistry.lookupProviders(class)". Add a <metainf> line to test jar ant task so that the test passes when run from the hdk.
        Hide
        Mark Hindess added a comment -

        Please confirm (by closing this JIRA) that the latest commit resolves this issue.

        Show
        Mark Hindess added a comment - Please confirm (by closing this JIRA) that the latest commit resolves this issue.
        Hide
        Mark Hindess added a comment -

        Applied at r986136. I also made a minor modification the imageio test ant task to ensure the META-INF entries get added to the jar in the hdk.

        Show
        Mark Hindess added a comment - Applied at r986136. I also made a minor modification the imageio test ant task to ensure the META-INF entries get added to the jar in the hdk.
        Hide
        Lang Yang added a comment -

        I have implemented two related methods in the latest version patch.

        ImageIO.scanForPlugins()
        IIORegistry.registerApplicationClasspathSpis()

        The registerApplicationClasspathSpis() uses lookupProviders() to get every category spis and register them all to the registry.

        JDoc:
        http://download.oracle.com/javase/1.5.0/docs/api/javax/imageio/spi/IIORegistry.html#registerApplicationClasspathSpis()
        http://download-llnw.oracle.com/javase/1.5.0/docs/api/javax/imageio/ImageIO.html#scanForPlugins()

        Thanks.

        Show
        Lang Yang added a comment - I have implemented two related methods in the latest version patch. ImageIO.scanForPlugins() IIORegistry.registerApplicationClasspathSpis() The registerApplicationClasspathSpis() uses lookupProviders() to get every category spis and register them all to the registry. JDoc: http://download.oracle.com/javase/1.5.0/docs/api/javax/imageio/spi/IIORegistry.html#registerApplicationClasspathSpis( ) http://download-llnw.oracle.com/javase/1.5.0/docs/api/javax/imageio/ImageIO.html#scanForPlugins( ) Thanks.
        Hide
        Lang Yang added a comment -

        Hi, please take a look at patch HARMONY-6553-v2.diff

        I've added a folder META-INF under src/test/java folder in order to test the method. There are two provider-configuration files under META-INF\services:
        1. javax.imageio.spi.CorrectProviderConfiguration - good configuration
        2. javax.imageio.spi.IncorrectProviderConfiguration - bad configuration

        and two dummy classes: CorrectProviderConfiguration and IncorrectProviderConfiguration are created accordingly.

        Show
        Lang Yang added a comment - Hi, please take a look at patch HARMONY-6553 -v2.diff I've added a folder META-INF under src/test/java folder in order to test the method. There are two provider-configuration files under META-INF\services: 1. javax.imageio.spi.CorrectProviderConfiguration - good configuration 2. javax.imageio.spi.IncorrectProviderConfiguration - bad configuration and two dummy classes: CorrectProviderConfiguration and IncorrectProviderConfiguration are created accordingly.
        Hide
        Alexei Fedotov added a comment -

        An interesting documentation link which answers the question where are we going (note, ServiceLoader is a new class in Java 6 javadoc).

        http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html

        Show
        Alexei Fedotov added a comment - An interesting documentation link which answers the question where are we going (note, ServiceLoader is a new class in Java 6 javadoc). http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html
        Hide
        Alexei Fedotov added a comment -

        Lang, is there anything in common between two implementations? I believe there should be something in common, for example, features described by the specification.

        Could you create a unit test from your "TestLookupProviders"? As you said, there could be some behavior difference which the test should ignore. You may ignore particular class names, and check only their existence, or their allowed MIME types regardless of their order.

        Show
        Alexei Fedotov added a comment - Lang, is there anything in common between two implementations? I believe there should be something in common, for example, features described by the specification. Could you create a unit test from your "TestLookupProviders"? As you said, there could be some behavior difference which the test should ignore. You may ignore particular class names, and check only their existence, or their allowed MIME types regardless of their order.
        Hide
        Lang Yang added a comment -

        As the return result of this method is highly JRE-dependent, so it has different return result between RI and Harmony.

        It also seems we don't have those provider-configuration files? I couldn't find them.

        So, in order to test if this implementation is correct, I've created a independent program runs on Sun's JRE to see if it returns the same result as RI's result. See TestLookupProviders.java (Please don't commit this file, it's just a reference)

        Show
        Lang Yang added a comment - As the return result of this method is highly JRE-dependent, so it has different return result between RI and Harmony. It also seems we don't have those provider-configuration files? I couldn't find them. So, in order to test if this implementation is correct, I've created a independent program runs on Sun's JRE to see if it returns the same result as RI's result. See TestLookupProviders.java (Please don't commit this file, it's just a reference)

          People

          • Assignee:
            Mark Hindess
            Reporter:
            Lang Yang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development