PicoContainer
  1. PicoContainer
  2. PICO-378

Inconsistent Script Behavior When Run in Custom ClassLoader

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.10
    • Fix Version/s: 3.0
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      When run inside a custom classloader, the scripting behaviors vary from one implementation to another.

      The test case (Jython Example)

      	@Test
      	public void testExecutionWithinCustomClassLoader() 
      			throws MalformedURLException, ClassNotFoundException {
      		Reader script = new StringReader("" +
              		"from org.picocontainer import *;\n" +
              		"from org.picocontainer.parameters import ComponentParameter;\n" +
                              "pico = PicoBuilder().withLifecycle().withCaching().build();\n" +
      				"pico.addComponent(\"TestComp\",TestComp\n);"
      			);
              File testCompJar = TestHelper.getTestCompJarFile();
              assertTrue(testCompJar.isFile());
              URL compJarURL = testCompJar.toURI().toURL();
              final URLClassLoader cl  = new URLClassLoader(new URL[] {compJarURL}, 
              		getClass().getClassLoader());
              assertNotNull(cl.loadClass("TestComp"));
              
              ContainerBuilder containerBuilder = new JythonContainerBuilder(script, cl);
              
              PicoContainer pico = buildContainer(containerBuilder, null, null);
              assertNotNull(pico.getComponent("TestComp"));
              assertEquals("TestComp", pico.getComponent("TestComp").getClass().getName());
      		
      	}
      

      Status of this bug:

      BeanShell: Ok
      Groovy : Ok
      Rhino : [Failed] but I have it fixed in my local code base and will check in shortly to the Pico 3 codebase.
      Jython : [Failed] and I haven't been able to figure out how to fix it.
      JRuby : Haven't tried it yet.

        People

        • Assignee:
          Unassigned
          Reporter:
          Michael Rimov
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: