Bug 535675 - Validator exception thrown is EDataType class is provided by a custom plugin
Summary: Validator exception thrown is EDataType class is provided by a custom plugin
Status: RESOLVED FIXED
Alias: None
Product: Viatra
Classification: Modeling
Component: Query (show other bugs)
Version: 2.0.0   Edit
Hardware: Macintosh Mac OS X
: P3 normal
Target Milestone: 2.0.1   Edit
Assignee: Zoltan Ujhelyi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-08 04:24 EDT by Zoltan Ujhelyi CLA
Modified: 2018-07-06 07:14 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Ujhelyi CLA 2018-06-08 04:24:28 EDT
I have noticed a few ClassNotFoundException instances thrown by the VQL validator in a proprietary project:


!STACK 0
org.eclipse.emf.common.util.WrappedException: java.lang.ClassNotFoundException: custom.Float cannot be found by org.eclipse.emf.ecore_2.14.0.v20180420-1131
	at org.eclipse.xtext.util.Exceptions.throwUncheckedException(Exceptions.java:26)
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator$MethodWrapper.handleInvocationTargetException(AbstractDeclarativeValidator.java:137)
	at org.eclipse.viatra.query.patternlanguage.emf.validation.EMFPatternLanguageValidator$CustomMethodWrapper.handleInvocationTargetException(EMFPatternLanguageValidator.java:179)
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator$MethodWrapper.invoke(AbstractDeclarativeValidator.java:125)
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator.internalValidate(AbstractDeclarativeValidator.java:312)
	at org.eclipse.xtext.validation.AbstractInjectableValidator.validate(AbstractInjectableValidator.java:71)
	at org.eclipse.xtext.validation.CompositeEValidator.validate(CompositeEValidator.java:151)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:257)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:244)
	at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:40)
	at org.eclipse.xtext.xbase.validation.XbaseDiagnostician.validate(XbaseDiagnostician.java:48)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:201)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:143)
	at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:146)
	at org.eclipse.xtext.xbase.annotations.validation.DerivedStateAwareResourceValidator.validate(DerivedStateAwareResourceValidator.java:32)
	at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
	at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:91)
	at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
	at org.eclipse.xtext.util.concurrent.CancelableUnitOfWork.exec(CancelableUnitOfWork.java:26)
	at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:527)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:499)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:137)
	at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:86)
	at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:60)
Caused by: java.lang.ClassNotFoundException: custom.Float cannot be found by org.eclipse.emf.ecore_2.14.0.v20180420-1131
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:419)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:411)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.eclipse.viatra.query.patternlanguage.emf.types.EMFTypeSystem.getJavaClass(EMFTypeSystem.java:311)
	at org.eclipse.viatra.query.patternlanguage.emf.validation.EMFPatternLanguageValidator.calculateIssueData(EMFPatternLanguageValidator.java:125)
	at org.eclipse.viatra.query.patternlanguage.emf.validation.EMFPatternLanguageValidator.reportMissingParameterTypeDeclaration(EMFPatternLanguageValidator.java:428)
	at org.eclipse.viatra.query.patternlanguage.emf.validation.EMFPatternLanguageValidator.checkParameterTypes(EMFPatternLanguageValidator.java:369)
	at org.eclipse.viatra.query.patternlanguage.emf.validation.EMFPatternLanguageValidator.checkVariableType(EMFPatternLanguageValidator.java:257)
	at sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator$MethodWrapper.invoke(AbstractDeclarativeValidator.java:118)
	... 22 more

 A debugging session has shown that the exception can be reproduced by the following steps:
  * Have a custom EDataType that represents a custom Java Object (not one available in EMF or the Java Standard Library)
  * Have the metamodel only available in the target platform, but NOT installed and NOT imported as a Java project.
  * Have a pattern that returns this EDataType as parameter but does not specify the parameter type, e.g. as follows
  
    pattern test(f) {
      CustomFloat(f);
    }
    
----

There are two issues to fix here:
 1) Ensure that such ClassNotFoundExceptions are not reported as exceptions but wrapped in a better way.
 2) Handle correctly this case, e.g. by referring the type by classnames during validation instead of Java Classes (that may or may not be available).
Comment 1 Eclipse Genie CLA 2018-06-08 10:51:40 EDT
New Gerrit change created: https://git.eclipse.org/r/124258
Comment 2 Eclipse Genie CLA 2018-06-19 11:18:18 EDT
New Gerrit change created: https://git.eclipse.org/r/124748