eclipse-qvto / org.eclipse.qvto

Eclipse Public License 2.0
0 stars 1 forks source link

ClassNotFoundException: org.eclipse.xtext.generator.DefaultGeneratorFragment #1071

Open eclipse-qvt-oml-bot opened 5 days ago

eclipse-qvt-oml-bot commented 5 days ago

| --- | --- | | Bugzilla Link | 563596 | | Status | NEW | | Importance | P3 major | | Reported | May 26, 2020 11:49 EDT | | Modified | May 29, 2020 07:04 EDT | | Depends on | 472482 | | Reporter | Ed Willink |

Description

After migrating my workspace to a 4.16M3 platform, I get a build failed popup with

a Error Log entry below.

From a superficial look it would appear that QVTo is attempting to use org.eclipse.xtext.generator.DefaultGeneratorFragment as a black box.


Errors running builder 'QVT Operational Builder' on project 'org.eclipse.ocl.examples.build'.

java.lang.NoClassDefFoundError: org/eclipse/xtext/generator/DefaultGeneratorFragment\ at java.lang.ClassLoader.defineClass1(Native Method)\ at java.lang.ClassLoader.defineClass(ClassLoader.java:756)\ at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)\ at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)\ at java.net.URLClassLoader.access$100(URLClassLoader.java:74)\ at java.net.URLClassLoader$1.run(URLClassLoader.java:369)\ at java.net.URLClassLoader$1.run(URLClassLoader.java:363)\ at java.security.AccessController.doPrivileged(Native Method)\ at java.net.URLClassLoader.findClass(URLClassLoader.java:362)\ at java.lang.ClassLoader.loadClass(ClassLoader.java:418)\ at java.lang.ClassLoader.loadClass(ClassLoader.java:351)\ at org.eclipse.m2m.internal.qvt.oml.jdt.runtime.blackbox.JdtBlackboxProvider.getJdtUnitDescriptor(JdtBlackboxProvider.java:106)\ at org.eclipse.m2m.internal.qvt.oml.jdt.runtime.blackbox.JdtBlackboxProvider.getUnitDescriptors(JdtBlackboxProvider.java:62)\ at org.eclipse.m2m.internal.qvt.oml.blackbox.BlackboxProvider.getBlackboxCallHandler(BlackboxProvider.java:125)\ at org.eclipse.m2m.internal.qvt.oml.blackbox.BlackboxRegistry.getBlackboxCallHandler(BlackboxRegistry.java:80)\ at org.eclipse.m2m.internal.qvt.oml.ast.parser.QvtOperationalVisitorCS.visitMappingMethodCS(QvtOperationalVisitorCS.java:3750)\ at org.eclipse.m2m.internal.qvt.oml.ast.parser.QvtOperationalVisitorCS.visitMethodBodies(QvtOperationalVisitorCS.java:2412)\ at org.eclipse.m2m.internal.qvt.oml.ast.parser.QvtOperationalVisitorCS.visitUnitCS(QvtOperationalVisitorCS.java:2109)\ at org.eclipse.m2m.internal.qvt.oml.compiler.QVTOCompiler.analyze(QVTOCompiler.java:279)\ at org.eclipse.m2m.internal.qvt.oml.compiler.QVTOCompiler.doCompile(QVTOCompiler.java:444)\ at org.eclipse.m2m.internal.qvt.oml.compiler.QVTOCompiler.compileSingleFile(QVTOCompiler.java:325)\ at org.eclipse.m2m.internal.qvt.oml.compiler.QVTOCompiler.compile(QVTOCompiler.java:183)\ at org.eclipse.m2m.internal.qvt.oml.project.builder.QVTOBuilder.rebuildAll(QVTOBuilder.java:216)\ at org.eclipse.m2m.internal.qvt.oml.project.builder.QVTOBuilder.incrementalBuild(QVTOBuilder.java:140)\ at org.eclipse.m2m.internal.qvt.oml.project.builder.QVTOBuilder.build(QVTOBuilder.java:83)\ at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:832)\ at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)\ at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)\ at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)\ at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)\ at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)\ at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)\ at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)\ at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)\ at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)\ at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)\ at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)\ Caused by: java.lang.ClassNotFoundException: org.eclipse.xtext.generator.DefaultGeneratorFragment\ at java.net.URLClassLoader.findClass(URLClassLoader.java:382)\ at java.lang.ClassLoader.loadClass(ClassLoader.java:418)\ at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 37 more

eclipse-qvt-oml-bot commented 5 days ago

By Ed Willink on May 26, 2020 11:50

org.eclipse.ocl.examples.build has a plugin.xml with

<extension point="org.eclipse.m2m.qvt.oml.javaBlackboxUnits">\
    <unit name="ExampleJavaLib" namespace="m2m.qvt.oml">\
        <library name="BlackBoxLibrary" class="org.eclipse.ocl.examples.build.qvto.BlackBoxLibrary">\
            <metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/>\
        </library>\
    </unit>\
</extension>

so there is a blackbox to be found, but there are very many other Java files that are nothing to do with QVTo at all.

eclipse-qvt-oml-bot commented 5 days ago

By Christopher Gerking on May 26, 2020 18:05

Clearly a regression introduced in the course of bug 472482. It seems as if we are about to kick off the same discussion we had over one year ago...

(In reply to Ed Willink from bug 472482, comment #23)

My suspicion is that you are looking at thousands of Java classes and have not considered all the possible things that can happen in arbitrary classes.

Right. Adjusted the error handling on cgerking/472482. Commit ID: c4d04d47a7c349f946608d36e723a42eb9b5af12

Maybe even more unanticipated errors should be handled by using catch(Throwable) instead of catch(NoClassDefFoundError).

eclipse-qvt-oml-bot commented 5 days ago

By Ed Willink on May 27, 2020 01:03

Fixing the error handling may hide the problem, but whay is EVERY class looked at?

class="org.eclipse.ocl.examples.build.qvto.BlackBoxLibrary"

identifies precisely one class in a package containing no other .java files; just .qvto's. The imports

import org.eclipse.emf.ecore.EObject;\ import org.eclipse.emf.ecore.util.EcoreUtil;\ import org.eclipse.m2m.qvt.oml.blackbox.java.Module;

cannot explain why org/eclipse/xtext/generator/DefaultGeneratorFragment was even opened.

Searching the enclosing project for DefaultGeneratorFragment reveals three class files in org.eclipse.ocl.examples.build.fragments that import and extends it.

eclipse-qvt-oml-bot commented 5 days ago

By Ed Willink on May 27, 2020 02:55

Searching up the stack trace for the offending loop I find in JdtBlackboxProvider

Set referencedProjects = ProjectDependencyTracker.getAllReferencedProjects(project, true);\ \ final List classes = getAllClasses(p);

Ouch! Lots of projects and lots of classes, when only one class was interesting.

Changing to MAJOR since it is a waste of CPU time.

eclipse-qvt-oml-bot commented 5 days ago

By Christopher Gerking on May 27, 2020 03:15

(In reply to Ed Willink from comment #3)

Fixing the error handling may hide the problem, but whay is EVERY class looked at?

Take a look at bug 472482.

(In reply to Christopher Gerking from bug 472482, comment #26)

(In reply to Ed Willink from comment bug 472482, #25)

In the QVTo world there is a BlackBoxLibrary Library=Class(+Package), which is mapped to a Java org.eclipse.ocl.examples.build.qvto.BlackBoxLibrary class by

Yes but how can we be aware of such registrations inside our workspace projects? Is there an easy way to parse/analyze plugin.xml files from the workspace? Does PDE provide such a thing? Of course we could implement this manually, but that sounds like a great effort.

If a QVTo file does not explicitly import a Java class, then all Java classes are currently searched. In particular that's because imports of Java classes go beyond the specification. Normally they shouldn't be supported at all.

Analyzing the plugin.xml seems feasible, though.

eclipse-qvt-oml-bot commented 5 days ago

By Ed Willink on May 27, 2020 03:51

PluginReader in org.eclipse.ocl.pivot.internal.resource.StandaloneProjectMap is a custom reader of plugin.xml to parse the org.eclipse.emf.ecore.generated_package for standalone purposes.

It should be easy to clone as a parser of the org.eclipse.m2m.qvt.oml.javaBlackboxUnits extension point. The current PluginReader is a precursor to a GenModelReader which you don't need so much of the complexity should vanish.

EMF's extension point readers are tightly coupled to the platform interfaces and opaque objects making them very difficult to re-use. Hence the independent parser. The QVTo reader may be refactorable to support usage from the platform reader context or a standalone context.