Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 445293

Summary: Post M1 Problem with ClasspathTypeProviderFactory evolution
Product: [Modeling] TMF Reporter: Ed Willink <ed>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource, karsten.thoms, sven.efftinge
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
Whiteboard:
Bug Depends on:    
Bug Blocks: 445697    

Description Ed Willink CLA 2014-09-28 16:42:48 EDT
ClasspathTypeProviderFactory is not API so I have no right to complain but:

For Eclipse OCL I have a problem that I am using a plain ResourceSetImpl and require the user's class loader to be used for the JVM path. I therefore have a ResourceSetClasspathTypeProviderFactory that has the following overload:

@Override
protected ClasspathTypeProvider createClasspathTypeProvider(ResourceSet resourceSet) {
   return new ClasspathTypeProvider(resourceSet.getClass().getClassLoader(), resourceSet, getIndexedJvmTypeAccess());
	}

to ensure that resourceSet.getClass().getClassLoader() is used.

The recent constructor change causes my build to fail.

? any chance of restoring the old constructor ?

? better: any chance of using resourceSet.getClass().getClassLoader() for non-XtextResourceSets avoiding the need for an overload in the first place ?

[Since XtextResourceSet.getClasspathURIContext() provides an important functionality change, shouldn't it be available to everyone via a ResourceSet adapter rather than a non-standard ResourceSet?]
Comment 1 Ed Willink CLA 2014-09-29 01:42:59 EDT
(In reply to Ed Willink from comment #0)
> ? any chance of restoring the old constructor ?

Doh! Injection allows me to just add the extra argument. Need to investigate backwards compatibility.

> ? better: any chance of using resourceSet.getClass().getClassLoader() for
> non-XtextResourceSets avoiding the need for an overload in the first place ?
Comment 2 Sven Efftinge CLA 2014-09-29 02:24:58 EDT
Not sure I understand. The old constructor has just been deprecated and is still available, no?
Comment 3 Ed Willink CLA 2014-09-29 05:57:12 EDT
No.

The old constructor:

	@Inject
	public ClasspathTypeProviderFactory(ClassLoader classLoader) {
		this.classLoader = classLoader;
	}

has been replaced by:

	@Inject
	public ClasspathTypeProviderFactory(ClassLoader classLoader, TypeResourceServices services) {
		this.classLoader = classLoader;
		this.services = services;
	}

so my derived constructor fails and I need some Class.forName trickery to be compatible.
Comment 4 Ed Willink CLA 2014-10-05 07:11:14 EDT
The specific Eclipse OCL problem has gone away because of recoding to avoid all usage of xtext.common.types.

Xtext may wish to morph this bug into an enhancement request to make at least part of xtext.common.types.access public API and therefore extensible.

Xtext may also review the API to enable the user classpath to be specified. Recent newsgroup postings suggest that the classpathURI context doesn't really work.

I suggest that the user be encouraged to load their own class in their own context so that this class can determine what the user context is. Fortunately FileEditorInput is not final, so a user-defined FileEditorInput derivation makes for a good way of passing context through the IEditorInput open editor parameter in JUnit tests.
Comment 5 Christian Dietrich CLA 2017-09-21 03:03:45 EDT
i dont think it still makes sense to do anything about this besides being more careful about such changes in future
Comment 6 Ed Willink CLA 2017-09-21 03:17:34 EDT
If you are 'more careful' about changing internal API, you will never be able to improve Xtext ever again.

The eventual issue was the need for the user's class loader/path to be used. This could be addressed by a better API.
Comment 7 Christian Dietrich CLA 2017-09-21 03:20:20 EDT
i dont understand. you can specify the classloader to be used.
you can bind e.g. a urlclassloader there
Comment 8 Ed Willink CLA 2017-09-21 03:38:47 EDT
(In reply to Ed Willink from comment #0)
> For Eclipse OCL I have a problem that I am using a plain ResourceSetImpl and
> require the user's class loader to be used for the JVM path.

Enhanced facilities are only available with the non-standard XtextResourceSet.
Comment 9 Karsten Thoms CLA 2017-09-21 03:50:12 EDT
Please understand that we can't deal all issues and decide to not work on certain items. Christian decided to set this to WONTFIX, or we could just keep this here open forever.
If you think that this is important for you and there is a way to solve your issue in a way acceptable for the project, we are willing to accept PRs and review them.