Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-33785

ClassLoader problem with SymbolLookup

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • structs-plugin
    • None
    • Jenkins 1.609
      Struts plugin 1.1

      I added a symbol to a plugin and added the org.jenkins-ci:symbol-annotation:1.1 lib to the plugin's dependencies as recommended.

      When testing the symbol lookup in Script Console, the lookup fails:

      import hudson.triggers.TriggerDescriptor
      import com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger
      import org.jenkinsci.plugins.structs.SymbolLookup
      import org.jenkinsci.Symbol
      
      println SymbolLookup.get().find(TriggerDescriptor, 'gerrit')
      println SymbolLookup.get().find(Object, 'gerrit')
      println GerritTrigger.DescriptorImpl.annotations
      println GerritTrigger.DescriptorImpl.isAnnotationPresent(Symbol)
      println GerritTrigger.DescriptorImpl.isAnnotationPresent(GerritTrigger.classLoader.loadClass(Symbol.name))
      println GerritTrigger.DescriptorImpl.isAnnotationPresent(Jenkins.instance.pluginManager.uberClassLoader.loadClass(Symbol.name))
      println Symbol.classLoader
      
      null
      null
      [@org.jenkinsci.Symbol(value=[gerrit]), @hudson.Extension(dynamicLoadable=MAYBE, ordinal=0.0, optional=false)]
      false
      true
      false
      AntClassLoader[/var/lib/jenkins/plugins/structs/WEB-INF/lib/structs.jar:/var/lib/jenkins/plugins/structs/WEB-INF/lib/annotation-indexer-1.9.jar:/var/lib/jenkins/plugins/structs/WEB-INF/lib/symbol-annotation-1.1.jar]
      

      If change the dependency to org.jenkins-ci.plugins:struct-plugin:1.1 instead of org.jenkins-ci:symbol-annotation:1.1, everything works as expected:

      com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger$DescriptorImpl@314d1fa3
      com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger$DescriptorImpl@314d1fa3
      [@org.jenkinsci.Symbol(value=[gerrit]), @hudson.Extension(dynamicLoadable=MAYBE, ordinal=0.0, optional=false)]
      true
      true
      true
      AntClassLoader[/var/lib/jenkins/plugins/structs/WEB-INF/lib/structs.jar:/var/lib/jenkins/plugins/structs/WEB-INF/lib/annotation-indexer-1.9.jar:/var/lib/jenkins/plugins/structs/WEB-INF/lib/symbol-annotation-1.1.jar]
      

            kohsuke Kohsuke Kawaguchi
            daspilker Daniel Spilker
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: