eclipse-qvto / org.eclipse.qvto

Eclipse Public License 2.0
0 stars 1 forks source link

Confusion of ModuleHandle #1072

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

eclipse-qvt-oml-bot commented 5 days ago

| --- | --- | | Bugzilla Link | 563721 | | Status | NEW | | Importance | P3 normal | | Reported | May 29, 2020 08:55 EDT | | Modified | May 29, 2020 15:03 EDT | | Blocks | 472482 | | Reporter | Ed Willink |

Description

While trying to debug Bug 472482, I attempted to build the org.eclipse.ocl.examples.build project which has a blabkbox in a nested workspace, with an org.eclipse.ocl.examples.build 'plugin' in the outer workpsace.

I instrumented the ModuleHandle construction and got the trace below showing amongst other things that a BundleModuleHandle is used to access org.eclipse.ocl.examples.build even though it is a project; surely the JdtModuleHandle should be used. I also see many StandaloneModuleHandle which should surely never happen when EClipse is running?


BundleModuleHandle org.eclipse.m2m.tests.qvt.oml.bbox.AnnotatedJavaLibrary FooJavaLib\ BundleModuleHandle org.eclipse.m2m.tests.qvt.oml.bbox.Bug289982_Library Bug289982_Lib\ BundleModuleHandle org.eclipse.m2m.tests.qvt.oml.bbox.Bug427237_Library Bug427237_Lib\ BundleModuleHandle org.eclipse.m2m.tests.qvt.oml.bbox.Bug425066_Library Bug425066_Lib\ BundleModuleHandle org.eclipse.m2m.tests.qvt.oml.bbox.CollectionTypeLibrary FooCollectionsLib\ BundleModuleHandle org.eclipse.m2m.tests.qvt.oml.bbox.SimpleJavaLibrary SimpleJavaLibrary\ BundleModuleHandle org.eclipse.m2m.tests.qvt.oml.bbox.InvalidLibrary InvalidLibrary\ BundleModuleHandle org.eclipse.ocl.examples.build.qvto.BlackBoxLibrary BlackBoxLibrary\ org.eclipse.m2m.tests.qvt.oml - org.eclipse.m2m.tests.qvt.oml.bbox.AnnotatedJavaLibrary\ org.eclipse.m2m.tests.qvt.oml - org.eclipse.m2m.tests.qvt.oml.bbox.Bug289982_Library\ org.eclipse.m2m.tests.qvt.oml - org.eclipse.m2m.tests.qvt.oml.bbox.Bug427237_Library\ org.eclipse.m2m.tests.qvt.oml - org.eclipse.m2m.tests.qvt.oml.bbox.Bug425066_Library\ org.eclipse.m2m.tests.qvt.oml - org.eclipse.m2m.tests.qvt.oml.bbox.CollectionTypeLibrary\ org.eclipse.m2m.tests.qvt.oml - org.eclipse.m2m.tests.qvt.oml.bbox.SimpleJavaLibrary\ org.eclipse.m2m.tests.qvt.oml - org.eclipse.m2m.tests.qvt.oml.bbox.InvalidLibrary

!ENTRY org.eclipse.m2m.qvt.oml.blackbox.java 4 0 2020-05-29 12:54:12.664\ !MESSAGE Failed to load Java black-box unit 'org.eclipse.m2m.tests.qvt.oml.bbox.InvalidLibrary'\ !SUBENTRY 1 org.eclipse.m2m.qvt.oml.blackbox.java 4 0 2020-05-29 12:54:12.664\ !MESSAGE Loading Java module diagnostics 'InvalidLibrary, javaClass: org.eclipse.m2m.tests.qvt.oml.bbox.InvalidLibrary, bundle: org.eclipse.m2m.tests.qvt.oml'\ !SUBENTRY 2 org.eclipse.m2m.qvt.oml.blackbox.java 4 0 2020-05-29 12:54:12.664\ !MESSAGE Loading Operation diagnostics 'public static java.lang.StringBuffer org.eclipse.m2m.tests.qvt.oml.bbox.InvalidLibrary.invalidOperation()'\ !SUBENTRY 3 org.eclipse.m2m.qvt.oml.blackbox.java 4 0 2020-05-29 12:54:12.664\ !MESSAGE Can't resolve 'class java.lang.StringBuffer' as OCL type in Java method 'public static java.lang.StringBuffer org.eclipse.m2m.tests.qvt.oml.bbox.InvalidLibrary.invalidOperation()'. Possibly definition of metamodel is missed in the library. \ org.eclipse.ocl.examples.build - org.eclipse.ocl.examples.build.qvto.BlackBoxLibrary

!ENTRY org.eclipse.m2m.qvt.oml.blackbox.java 4 0 2020-05-29 12:54:12.666\ !MESSAGE Failed to load Java black-box unit 'm2m.qvt.oml.ExampleJavaLib'\ !SUBENTRY 1 org.eclipse.m2m.qvt.oml.blackbox.java 4 0 2020-05-29 12:54:12.666\ !MESSAGE Loading Java module diagnostics 'BlackBoxLibrary, javaClass: org.eclipse.ocl.examples.build.qvto.BlackBoxLibrary, bundle: org.eclipse.ocl.examples.build'\ !SUBENTRY 2 org.eclipse.m2m.qvt.oml.blackbox.java 4 0 2020-05-29 12:54:12.666\ !MESSAGE Can't find Java implementation class for module 'BlackBoxLibrary'\ !STACK 0\ java.lang.ClassNotFoundException: org.eclipse.ocl.examples.build.qvto.BlackBoxLibrary cannot be found by org.eclipse.ocl.examples.build_2.12.0.qualifier\ at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:516)\ at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171)\ at java.lang.ClassLoader.loadClass(ClassLoader.java:357)\ at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:620)\ at org.eclipse.m2m.internal.qvt.oml.blackbox.java.BundleModuleHandle.getModuleJavaClass(BundleModuleHandle.java:45)\ at org.eclipse.m2m.internal.qvt.oml.blackbox.java.JavaModuleLoader.loadModule(JavaModuleLoader.java:63)\ at org.eclipse.m2m.internal.qvt.oml.blackbox.java.JavaBlackboxProvider$JavaUnitDescriptor.load(JavaBlackboxProvider.java:197)\ at org.eclipse.m2m.internal.qvt.oml.blackbox.BlackboxProvider.getBlackboxCallHandler(BlackboxProvider.java:128)\ 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.fullBuild(QVTOBuilder.java:94)\ at org.eclipse.m2m.internal.qvt.oml.project.builder.QVTOBuilder.build(QVTOBuilder.java:81)\ 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)\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary\ StandaloneModuleHandle BlackBoxLibrary BlackBoxLibrary\ StandaloneModuleHandle BlackBoxLibrary BlackBoxLibrary\ StandaloneModuleHandle BlackBoxLibrary BlackBoxLibrary\ StandaloneModuleHandle BlackBoxLibrary BlackBoxLibrary\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary\ StandaloneModuleHandle VisitorPatternLibrary VisitorPatternLibrary

eclipse-qvt-oml-bot commented 5 days ago

By Christopher Gerking on May 29, 2020 13:43

The reason is that, without explicitly importing a blackbox, all the available blackboxes are scanned for matching method signatures. Definitely a security nightmare, but it had always been like that.

(In reply to Ed Willink from comment #0)

I instrumented the ModuleHandle construction and got the trace below showing amongst other things that a BundleModuleHandle is used to access org.eclipse.ocl.examples.build even though it is a project; surely the JdtModuleHandle should be used.

A BundleModuleHandle is used for all blackboxes inside a deployed bundle. I expect QVTo to be installed? In this case, all the test blackboxes from org.eclipse.m2m.tests.qvt.oml are deployed, so this behavior is more or less expected.

I also see many StandaloneModuleHandle which should surely never happen when EClipse is running?

QVTo treats its Eclipse mode as an addon of the standalone mode, so all the standalone functionality is present at any time. Technically speaking, you could therefore register a blackbox programmatically from within a running plugin, even without a registration in the corresponding plugin.xml file.

eclipse-qvt-oml-bot commented 5 days ago

By Ed Willink on May 29, 2020 15:03

(In reply to Christopher Gerking from comment #1)

The reason is that, without explicitly importing a blackbox, all the available blackboxes are scanned for matching method signatures. Definitely a security nightmare, but it had always been like that.

Not sure what question you are commenting on.

(In reply to Ed Willink from comment #0)

I instrumented the ModuleHandle construction and got the trace below showing amongst other things that a BundleModuleHandle is used to access org.eclipse.ocl.examples.build even though it is a project; surely the JdtModuleHandle should be used. A BundleModuleHandle is used for all blackboxes inside a deployed bundle. I expect QVTo to be installed? In this case, all the test blackboxes from org.eclipse.m2m.tests.qvt.oml are deployed, so this behavior is more or less expected.

Yes but org.eclipse.ocl.examples.build is a workspace project. The in-Eclipse algorithm for finding x.y.x is.

If x.y.z is a workspace project open the project => JdtModuleHandle\ else if x.y.z is a bundle open the bundle => BundleModuleHandle

never both, never bundle for project.

I also see many StandaloneModuleHandle which should surely never happen when EClipse is running? QVTo treats its Eclipse mode as an addon of the standalone mode, so all the standalone functionality is present at any time. Technically speaking, you could therefore register a blackbox programmatically from within a running plugin, even without a registration in the corresponding plugin.xml file.

This appears to be one of many aspects of the mis-design.

In Eclipse requires the use of Eclipse class loaders that use plugin class paths.

Standalone is completely different. You have to use, and may be search, the invocation classpath.