Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351970 - Package org.eclipse.xtext.util is exported twice
Summary: Package org.eclipse.xtext.util is exported twice
Status: RESOLVED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext Backlog (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-13 09:24 EDT by Moritz Eysholdt CLA
Modified: 2017-07-11 14:17 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Eysholdt CLA 2011-07-13 09:24:09 EDT
We export the package org.eclipse.xtext.util twice:

/org.eclipse.xtext/emf-gen/org/eclipse/xtext/util
/org.eclipse.xtext.util/src/org/eclipse/xtext/util

This causes package-imports (in MANIFEST.MFs) to fail when they refer to org.eclipse.xtext.util.
Comment 1 Sven Efftinge CLA 2012-11-22 07:43:35 EST
I don't see how we can solve this without removing or changing public API.
Comment 2 Andrey Loskutov CLA 2016-01-13 05:31:03 EST
There is a possibility: right now this package is exported by those two bundles:

org.eclipse.xtext 2.8.4.v201508050135
org.eclipse.xtext.util 2.8.4.v201508050135

but xtext bundle depends AND re-exports org.eclipse.xtext.util bundle. By reexporting the bundle all exported packages are also exported.

So all what we need is to *move* org.eclipse.xtext.util.XtextAdapterFactory and org.eclipse.xtext.util.XtextSwitch classes from org.eclipse.xtext bundle to org.eclipse.xtext.util (and same for source code). Not sure if this is doable by changing the source paths because XtextSwitch seem to depend on other xtext classes, but at least at "deployment" level, after compiler has generated classes this should work.

Since the package is the same and since the org.eclipse.xtext bundle re-exports the org.eclipse.xtext.util bundle classes, there will be no breakage for any client. The only clients who could notice the difference will be those who used org.eclipse.xtext.util bundle without using org.eclipse.xtext, and I doubt there were many and I also doubt they will be affected in any way.

Beside the fact that exporting different contents under the same package name is a clear violation of any good practices, this causes issues in our environment because we have *patched* xtext bundle (but neither xtext.util bundle nor package) and the MWE build in the Eclipse can't build anything after the patch because the classloader denies to load classes from same package if the signing information of those classes differs:

247  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
336  [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems instantiating module com.advantest.itee.GenerateFlowProgrammingLanguage: java.lang.SecurityException: class "org.eclipse.xtext.util.XtextSwitch"'s signer information does not match signer information of other classes in the same package
java.lang.RuntimeException: Problems instantiating module com.advantest.itee.GenerateFlowProgrammingLanguage: java.lang.SecurityException: class "org.eclipse.xtext.util.XtextSwitch"'s signer information does not match signer information of other classes in the same package
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:95)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.SecurityException: class "org.eclipse.xtext.util.XtextSwitch"'s signer information does not match signer information of other classes in the same package
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.create(Mwe2ExecutionEngine.java:157)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:104)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:296)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:142)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:114)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:296)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:80)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:296)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.create(Mwe2ExecutionEngine.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:93)
	... 4 more
Caused by: java.lang.SecurityException: class "org.eclipse.xtext.util.XtextSwitch"'s signer information does not match signer information of other classes in the same package
	at java.lang.ClassLoader.checkCerts(ClassLoader.java:952)
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:666)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:794)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
	at java.lang.Class.getDeclaredConstructors(Class.java:1914)
	at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:243)
	at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:96)
	at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:629)
	at com.google.inject.internal.UntargettedBindingProcessor$1.visit(UntargettedBindingProcessor.java:51)
	at com.google.inject.internal.UntargettedBindingProcessor$1.visit(UntargettedBindingProcessor.java:35)
	at com.google.inject.internal.UntargettedBindingImpl.acceptTargetVisitor(UntargettedBindingImpl.java:42)
	at com.google.inject.internal.UntargettedBindingProcessor.visit(UntargettedBindingProcessor.java:35)
	at com.google.inject.internal.UntargettedBindingProcessor.visit(UntargettedBindingProcessor.java:27)
	at com.google.inject.internal.BindingImpl.acceptVisitor(BindingImpl.java:93)
	at com.google.inject.internal.AbstractProcessor.process(AbstractProcessor.java:55)
	at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:178)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
	at com.google.inject.Guice.createInjector(Guice.java:95)
	at com.google.inject.Guice.createInjector(Guice.java:72)
	at com.google.inject.Guice.createInjector(Guice.java:62)
	at org.eclipse.xtext.XtextStandaloneSetupGenerated.createInjector(XtextStandaloneSetupGenerated.java:29)
	at org.eclipse.xtext.XtextStandaloneSetupGenerated.createInjectorAndDoEMFRegistration(XtextStandaloneSetupGenerated.java:23)
	at org.eclipse.xtext.generator.Generator.<init>(Generator.java:125)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at java.lang.Class.newInstance(Class.java:383)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.create(Mwe2ExecutionEngine.java:155)
	... 28 more
Comment 3 Karsten Thoms CLA 2017-07-11 14:17:58 EDT
The classes can't be moved to org.eclipse.xtext.util since they rely on the EMF classes in org.eclipse.xtext, and they are not visible in the util bundle.