Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366992 - ClasspathTypeProviderFactory may not use suitable ClassLoader
Summary: ClasspathTypeProviderFactory may not use suitable ClassLoader
Status: CLOSED DUPLICATE of bug 326407
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.2.1   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-16 17:19 EST by Ed Willink CLA
Modified: 2016-08-19 08:28 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2011-12-16 17:19:04 EST
JVMTypes are resolved by the ClasspathTypeProviderFactory using the ClassLoader of the non-ui Xtext plugin. This seems to work fine for editors and standalone JUnit tests.

However it fails for plugin JUnit tests that need to resolve a JVMType defined in the test plugin.

This can be worked around by a derived ClasspathTypeProviderFactory that uses the ResourceSet's class loader as the class loader. This could usefully be the standard functionality.

The workaround runs into problems with restricted access to ClasspathTypeProviderFactory  . Perhaps this could be relaxed.
Comment 1 Christian Dietrich CLA 2016-08-19 03:04:45 EDT
this can no longer be reproduced since the factory does the following now

public ClassLoader getClassLoader(ResourceSet resourceSet) {
		if (resourceSet instanceof XtextResourceSet) {
			XtextResourceSet xtextResourceSet = (XtextResourceSet) resourceSet;
			Object ctx = xtextResourceSet.getClasspathURIContext();
			if (ctx != null) {
		        if (ctx instanceof Class<?>) {
		            return ((Class<?>)ctx).getClassLoader();
		        }
		        if (!(ctx instanceof ClassLoader)) {
		        	return ctx.getClass().getClassLoader();
		        }
		        return (ClassLoader) ctx;
			}
		}
		return classLoader;
	}
Comment 2 Ed Willink CLA 2016-08-19 08:02:09 EDT
I think the limitation is still there, since your code snippet doesn't help for an ordinary ResourceSet.

However to ensure that JVMTypes are resolved in a worker thread, I had to rewrite anyway, so this problem no longer affects me.
Comment 3 Christian Dietrich CLA 2016-08-19 08:21:30 EDT
should think about this one more
Comment 4 Moritz Eysholdt CLA 2016-08-19 08:28:49 EDT
(In reply to Ed Willink from comment #2)
> I think the limitation is still there, since your code snippet doesn't help
> for an ordinary ResourceSet.

This argument turns the bug into a duplicate of bug#326407

*** This bug has been marked as a duplicate of bug 326407 ***