Java strategies don't work after deployment
To reproduce:
Submitted by Oskar van Rest on 27 April 2012 at 14:34
- start with a vanilla Spoofax project
- add a call to “java-strategy” somewhere in your code (so that it gets executed on-save or during analysis or something).
- deploy the project according to http://strategoxt.org/Spoofax/Tour#Plugin_deployment
- in a clean workspace, install and test your deployed plugin.
org.spoofax.interpreter.core.InterpreterException: Exception during evaluation
at org.spoofax.interpreter.core.Interpreter.evaluate(Interpreter.java:117)
at org.spoofax.interpreter.core.Interpreter.invoke(Interpreter.java:82)
at org.strategoxt.HybridInterpreter.invoke(HybridInterpreter.java:424)
at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:706)
at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:674)
at org.strategoxt.imp.runtime.services.StrategoBuilder.invokeObserver(StrategoBuilder.java:311)
at org.strategoxt.imp.runtime.services.StrategoBuilder.execute(StrategoBuilder.java:188)
at org.strategoxt.imp.runtime.services.StrategoBuilder.access$1(StrategoBuilder.java:173)
at org.strategoxt.imp.runtime.services.StrategoBuilder$1.run(StrategoBuilder.java:160)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.spoofax.interpreter.core.UndefinedStrategyException: Not found ‘java_strategy_0_0’
at org.spoofax.interpreter.stratego.CallT.eval(CallT.java:46)
at org.spoofax.interpreter.stratego.Strategy.evaluate(Strategy.java:76)
at org.spoofax.interpreter.core.Interpreter.evaluate(Interpreter.java:109)
… 9 more
Issue Log
the issue didn’t appear to be a bug in deployment after all. what was missing was that I didn’t select “Unpack the plug-in archive after installation” in my Feature project.
Maybe this could be added to http://strategoxt.org/Spoofax/Tour#Plugin_deployment
selecting “Unpack the plug-in archive after installation” doesn’t work for Tycho. Tycho seems to ignore this flag: https://issues.sonatype.org/browse/TYCHO-555
Solution is to add
Eclipse-BundleShape: dir
to your MANIFEST.MF. This solution also works for update sites created with Eclipse (instead of Tycho). It’s then not necessary to also select “Unpack the plug-in archive after installation”.Maybe add
Eclipse-BundleShape: dir
as default to each Spoofax project?
I also see the same behaviour for the Analysis language (org.metaborg.meta.lang.analysis), even though it is set to be unpacked. What was the solution (or is there even one)? Does it matter if it uses a ctree or jar build?
Apparently it cannot load the JAR with the java stratgies:
[org.strategoxt.imp] Editor services loaded: Analysis-1 ms [org.strategoxt.imp] Created new Stratego runtime instance-2 ms [org.strategoxt.imp] Loading Stratego module include/analysis.ctree [org.strategoxt.imp] Successfully loaded include/analysis.ctree-38 ms [org.strategoxt.imp] Loading Stratego modules [include/analysis-java.jar] [org.strategoxt.imp] Loading JARs from [file:/Users/gohla/Spoofax/Eclipses/Eclipse-4.2/Spoofax-nightly/plugins/org.metaborg.meta.lang.analysis_1.2.0.201310081000/include/analysis-java.jar] [org.strategoxt.imp] Parent class loader: org.metaborg.meta.lang.analysis.AnalysisParseControllerGenerated; org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader org.strategoxt.imp.runtime.dynamicloading.BadDescriptorException: Could not load compiler service provider(s): [include/analysis-java.jar] [org.strategoxt.imp] Loaded analysis components-1 ms at org.strategoxt.imp.runtime.services.StrategoObserver.reportLoadException(StrategoObserver.java:444) at org.strategoxt.imp.runtime.services.StrategoObserver.loadJars(StrategoObserver.java:433) at org.strategoxt.imp.runtime.services.StrategoObserver.initialize(StrategoObserver.java:357) at org.strategoxt.imp.runtime.services.StrategoObserver.getRuntime(StrategoObserver.java:863) at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:835) at org.strategoxt.imp.runtime.stratego.ForeignLangCallPrimitive.loadDescriptor(ForeignLangCallPrimitive.java:89) at org.strategoxt.imp.runtime.stratego.ForeignLangCallPrimitive.call(ForeignLangCallPrimitive.java:67) at org.strategoxt.lang.Context.invokePrimitive(Context.java:227) at org.strategoxt.lang.Context.invokePrimitive(Context.java:216) at trans.foreign_call_0_2.invoke(foreign_call_0_2.java:28) at trans.analysis_debug_task_partition_0_1.invoke(analysis_debug_task_partition_0_1.java:231) at trans.debug_task_partition_0_0.invoke(debug_task_partition_0_0.java:33) at org.strategoxt.lang.Strategy.invokeDynamic(Strategy.java:30) at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:192) at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:183) at org.strategoxt.lang.InteropSDefT$StrategyBody.evaluate(InteropSDefT.java:245) at org.spoofax.interpreter.core.Interpreter.evaluate(Interpreter.java:109) at org.spoofax.interpreter.core.Interpreter.invoke(Interpreter.java:82) at org.strategoxt.HybridInterpreter.invoke(HybridInterpreter.java:424) at org.strategoxt.imp.debug.core.str.launching.DebuggableHybridInterpreter.invoke(DebuggableHybridInterpreter.java:150) at org.strategoxt.imp.runtime.Environment$2.invoke(Environment.java:195) at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:704) at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:673) at org.strategoxt.imp.runtime.services.StrategoBuilder.invokeObserver(StrategoBuilder.java:327) at org.strategoxt.imp.runtime.services.StrategoBuilder.execute(StrategoBuilder.java:193) at org.strategoxt.imp.runtime.services.StrategoBuilder.access$1(StrategoBuilder.java:177) at org.strategoxt.imp.runtime.services.StrategoBuilder$1.run(StrategoBuilder.java:164) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) Caused by: org.strategoxt.NoInteropRegistererJarException: No STRJ InteropRegisterer classes found in JAR files: [Ljava.net.URL;@77972044:file:/Users/gohla/Spoofax/Eclipses/Eclipse-4.2/Spoofax-nightly/plugins/org.metaborg.meta.lang.analysis_1.2.0.201310081000/include/analysis-java.jar at org.strategoxt.HybridInterpreter.loadJars(HybridInterpreter.java:295) at org.strategoxt.imp.debug.core.str.launching.DebuggableHybridInterpreter.loadJars(DebuggableHybridInterpreter.java:107) at org.strategoxt.imp.runtime.services.StrategoObserver.loadJars(StrategoObserver.java:428) ... 26 more [org.strategoxt.imp] Loaded parse table for Analysis-6 ms
Edit:
After inspecting the jar file this becomes obvious, the jar file doesn’t contain any class files.
I suspect that in a ctree build, the Java files in the editor/java directory are not compiled to class files inside the bin directory. This in turn leads to an empty < language >-java.jar, which means that external Java strategies are not loaded and cannot be found. This is not a problem when building in Eclipse, since Eclipse automatically compiles all Java files in all source folders, but this does not happen in the Tycho build on the build farm.
That is indeed the problem, closing this issue and creating a new one.
Log in to post comments