Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-779

Class parameters are not correctly loaded for the consuming addon's classloader

    Details

    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      The following method in ForgeWizard was created to temporarily workaround the issue:

      private <T> Class<T> locateNativeClass(Class<T> type) {
      	Class<T> result = type;
      	AddonRegistry registry = ForgeService.INSTANCE.getAddonRegistry();
      	for (Addon addon : registry.getRegisteredAddons()) {
      		try {
      			ClassLoader classLoader = addon.getClassLoader();
      			result = (Class<T>) classLoader.loadClass(type.getName());
      			break;
      		} catch (ClassNotFoundException e) {
      		}
      	}
      	return result;
      }
      

      Show
      The following method in ForgeWizard was created to temporarily workaround the issue: private <T> Class<T> locateNativeClass(Class<T> type) { Class<T> result = type; AddonRegistry registry = ForgeService.INSTANCE.getAddonRegistry(); for (Addon addon : registry.getRegisteredAddons()) { try { ClassLoader classLoader = addon.getClassLoader(); result = (Class<T>) classLoader.loadClass(type.getName()); break; } catch (ClassNotFoundException e) { } } return result; }
    • Estimated Difficulty:
      Medium

      Description

      Having the following scenario:

      Eclipse plugin -> calls ConverterFactory -> passes Resource.class as a parameter

      ConverterFactory.getConverter(File.class, Resource.class)
      

      in ResourceConverterGenerator (resources addon):

         @Override
         public boolean handles(Class<?> source, Class<?> target)
         {
            return Resource.class.isAssignableFrom(target);
         }
      

      Returns false, because the classloader that loaded the Resource class is the Eclipse classloader, not the Resource addon classloader AND Resource.class is not visible in the convert addon.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                lincolnthree Lincoln Baxter III
                Reporter:
                gastaldi George Gastaldi
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: