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

Bug 350522

Summary: MTJ preprocessor does not work in Eclipse 3.7
Product: [Tools] MTJ Reporter: Rainer <rburgst>
Component: MTJ projectsAssignee: Project Inbox <dsdp.mtj-inbox>
Status: REOPENED --- QA Contact:
Severity: major    
Priority: P3 CC: rburgst
Version: unspecified   
Target Milestone: 1.0 M6   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Rainer CLA 2011-06-28 04:20:58 EDT
Build Identifier: 20110615-0604

Installed the Eclipse 3.7 for Java developers (cocoa 64 bit), then the MTJ tools via "Install new..." -> all available sites -> type MTJ.

I have this version installed now.

  Mobile Tools for Java	1.1.2.201106060709	org.eclipse.mtj.feature.group	Eclipse.org

I then manually added the hook into config.ini as described in the original MTJ install instructions.

I have a working project from a 3.6 pulsar release. When trying to preprocess, I see the following error in the log.

java.lang.NoSuchFieldError: ruleMemo
	at antenna.preprocessor.v3.parser.APPParser.<init>(APPParser.java:89)
	at antenna.preprocessor.v3.parser.Defines.addDefines(Defines.java:197)
	at antenna.preprocessor.v3.Preprocessor.addDefines(Preprocessor.java:325)
	at org.eclipse.mtj.internal.core.build.preprocessor.PreprocessorBuilder.preprocess(PreprocessorBuilder.java:692)
	at org.eclipse.mtj.internal.core.build.preprocessor.PreprocessorBuilder.doPreprocessing(PreprocessorBuilder.java:498)
	at org.eclipse.mtj.internal.core.build.preprocessor.PreprocessorBuilder.doBuild(PreprocessorBuilder.java:347)
	at org.eclipse.mtj.internal.core.build.MTJIncrementalProjectBuilder.build(MTJIncrementalProjectBuilder.java:70)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


I guess that the version of ANTLR that is picked up is not compatible with MTJ.

Reproducible: Always

Steps to Reproduce:
1. try and build an MTJ project with preprocessing enabled
Comment 1 Gorkem Ercan CLA 2011-10-10 02:20:00 EDT
I see that antenna.preprocessor bundle only provides a minimum version number for ANTLR runtime. Eclipse indigo ships both ANTLR runtime 3.2 and 3.0.1 and I think 3.2 is picked up. I will update the bundle and give a maximum supported version so that 3.2 is not used anymore.
Comment 2 Gorkem Ercan CLA 2011-10-24 18:19:09 EDT
A fix is released to git repository and you can pick up the update that includes the fix from http://download.eclipse.org/mtj/updates/nightly update site.
Comment 3 Rainer CLA 2011-10-27 10:00:56 EDT
Hmm, now I get the following error

Preprocessor invoked, but hook is not installed.  Consult the installation instructions for MTJ.

I do have the following in configurations/config.ini


#This configuration file was written by: org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser
#Tue Oct 25 10:39:40 CEST 2011
org.eclipse.update.reconcile=false
eclipse.p2.profile=epp.package.java
osgi.instance.area.default=@user.home/Documents/workspace
osgi.framework=file\:plugins/org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar
equinox.use.ds=true
eclipse.buildId=M20110909-1335
osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.0.200.v20110502-1955.jar@1\:start
org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info
eclipse.product=org.eclipse.platform.ide
osgi.splashPath=platform\:/base/plugins/org.eclipse.platform
osgi.framework.extensions=org.eclipse.mtj.core.hooks
osgi.bundles.defaultStartLevel=4
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.p2.data.area=@config.dir/../p2/



I.e. the hook for osgi.framework.extensions=org.eclipse.mtj.core.hooks. But somehow that doesn't seem to be enough.
Comment 4 Gorkem Ercan CLA 2011-12-24 12:43:08 EST
Reopening to take a look
Comment 5 -- -- CLA 2016-07-26 14:08:27 EDT
Oh well guess nobody noticed this before, but this line of eclipse:

https://github.com/eclipse/rt.equinox.framework/blob/e490d7954ccc2f68113309730a67bbdaa242055d/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java#L907

Seems to add a dot to the classpath of the "org.eclipse.mtj.core.hooks" library.

      entries[j] = one entry from the eclipse.properties:
      Content of eclipse.properties:
          http://git.eclipse.org/c/mtj/org.eclipse.mtj.git/tree/trunk/plugins/org.eclipse.mtj.core.hooks/eclipse.properties?id=2781779133edabd848add3a0b49b1ebacae4a1b0


I'm not really shure if this is intended but i guess it is not.
But even if this would be correct it would probably get a problem with asm-all-3.0.jar, because the following line will fail:
      https://github.com/eclipse/rt.equinox.framework/blob/e490d7954ccc2f68113309730a67bbdaa242055d/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java#L980


So the classloader was looking for a file called "org.eclipse.mtj.core.hooks-*.jar.".
So basically it doesn't even read the hookconfigurators.properties file after that.


The only Solution for me was to add "Eclipse-BundleShape: dir" to the manifest of the plugin ,package it with maven again, and install it from the plugin-zip-file.
That way it would take the classpath "org.eclipse.mtj.core.hooks-*/." instead, because the plugin gets stored inside a directory in the plugin-folder and not as jar file.



I also modified the "Debug.java" because it throw Exceptions about not finding a Platform class.
(But I'm not shure if this step is really needed, i changed this before i found the problem with the classloader)

http://git.eclipse.org/c/mtj/org.eclipse.mtj.git/plain/trunk/plugins/org.eclipse.mtj.core.hooks/src/org/eclipse/mtj/internal/core/hooks/Debug.java?id=2781779133edabd848add3a0b49b1ebacae4a1b0

So i just used "DEBUG_GENERAL = false" for example.