úterý 5. července 2011

Java has debugging support for other languages

I am trying to figure out how to do mappings of DSL statements to Java (or generally any GPL) statements. At the moment, Acceleo can provide mapping of input file regions to output file regions, even though it turned out that it has its problems as well. But this is not what I want to discuss about now.

To test the mapping, I started with the elementary debugging task - a breakpoint. The aim is to automatically create corresponding Java breakpoint for a DSL breakpoint and this is where I got stuck. I can only create line Java breakpoints in Eclipse, so if there are more statements on the same line, I can't tell which one should trigger the breakpoint. To understand the problem I started to study some Java papers and specifications and I've found the com.sun.jdi.Location interface. After reading the documentation of that interface I found out that Java class files can contain source information related to more source files than just Java sources. This is used for instance in JSP which are translated to a Java source files and these are compiled. It could be as well used for any DSL.

For more about the feature read JSR-45.

pondělí 4. července 2011

Long breaks from work suck!

It's month and a half since my last commit to the project, not counting a little commit consisting of only gitignore files :). A lot of things happen since that time. First of all, I forgot a lot about the project, so I don't know how long it will take to get back. And there's another new thing - a brand new version of Eclipse is out.

I was experimenting with Indigo before but I've got some problems with that. I don't really remember what was the problem, but since Indigo is oficially out now, I will try to finally port trunk to Indigo and then I will carry on with development. I created a branch for indigo before, it's called eclipse-indigo. So let's see if there's still a problem.

So the problem seems to be with Acceleo and can be reproduced using these steps:

  1. First I launch karel plugins (org.macjariel.karel, org.macjariel.karel.generator) in another Eclipse runtime.
  2. In new Eclipse instance I create new Acceleo project. I set metamodel to my karel metamodel and I import org.macjariel.karel.generator project.
  3. Then I create a main Acceleo module which imports the generateKarelProgram module from generator project.
  4. I got a build error and a NullPointerException in the main Eclipse instance:
!ENTRY org.eclipse.core.resources 4 75 2011-07-04 21:16:32.493
!MESSAGE Errors occurred during the build.
!SUBENTRY 1 org.eclipse.acceleo.ide.ui 4 75 2011-07-04 21:16:32.494
!MESSAGE Errors running builder 'Acceleo Builder' on project 'org.macjariel.karel.sample'.
!STACK 0
java.lang.NullPointerException
at org.eclipse.acceleo.internal.parser.ast.ocl.environment.AcceleoTypeResolver.classifierEqual(AcceleoTypeResolver.java:228)
at org.eclipse.acceleo.internal.parser.ast.ocl.environment.AcceleoTypeResolver.findShadowClass(AcceleoTypeResolver.java:205)
at org.eclipse.acceleo.internal.parser.ast.ocl.environment.AcceleoTypeResolver.findShadowClass(AcceleoTypeResolver.java:1)
at org.eclipse.ocl.AbstractTypeResolver.getShadowClass(AbstractTypeResolver.java:950)
at org.eclipse.ocl.AbstractTypeResolver.resolveAdditionalOperation(AbstractTypeResolver.java:737)
at org.eclipse.ocl.AbstractEnvironment.addOperation(AbstractEnvironment.java:478)
at org.eclipse.ocl.AbstractEnvironment.addHelperOperation(AbstractEnvironment.java:456)
at org.eclipse.ocl.ecore.EcoreEnvironment.defineOperation(EcoreEnvironment.java:582)
at org.eclipse.acceleo.internal.parser.ast.ocl.OCLParser.addTemplateToScope(OCLParser.java:497)
at org.eclipse.acceleo.internal.parser.ast.ocl.OCLParser.addBehavioralFeaturesToScope(OCLParser.java:443)
at org.eclipse.acceleo.internal.parser.ast.ocl.OCLParser.addRecursivelyBehavioralFeaturesToScope(OCLParser.java:347)
at org.eclipse.acceleo.internal.parser.ast.ocl.OCLParser.addRecursivelyBehavioralFeaturesToScope(OCLParser.java:323)
at org.eclipse.acceleo.internal.parser.ast.CST2ASTConverterWithResolver.transformStepResolve(CST2ASTConverterWithResolver.java:185)
at org.eclipse.acceleo.internal.parser.ast.CST2ASTConverterWithResolver.resolveAST(CST2ASTConverterWithResolver.java:125)
at org.eclipse.acceleo.internal.parser.ast.CST2ASTConverterWithResolver.resolveAST(CST2ASTConverterWithResolver.java:104)
at org.eclipse.acceleo.parser.AcceleoSourceBuffer.resolveAST(AcceleoSourceBuffer.java:336)
at org.eclipse.acceleo.parser.AcceleoParser.resolveAST(AcceleoParser.java:239)
at org.eclipse.acceleo.parser.AcceleoParser.parse(AcceleoParser.java:215)
at org.eclipse.acceleo.parser.AcceleoParser.parse(AcceleoParser.java:123)
at org.eclipse.acceleo.internal.ide.ui.builders.AcceleoCompileOperation.doCompileResources(AcceleoCompileOperation.java:171)
at org.eclipse.acceleo.internal.ide.ui.builders.AcceleoCompileOperation.run(AcceleoCompileOperation.java:127)
at org.eclipse.acceleo.internal.ide.ui.builders.AcceleoBuilder.incrementalBuild(AcceleoBuilder.java:233)
at org.eclipse.acceleo.internal.ide.ui.builders.AcceleoBuilder.build(AcceleoBuilder.java:94)
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)

After some time I found a workaround to this problem. Import the generator project into the runtime Eclipse instance (it should just override the plugin package, so you don't need to close the generator package in the first instance). Then the problem disappears.

In the future I would like to solve the problem. It seems that Acceleo has problems importing modules from plug-in bundles.

EDIT: It seems that problem is solved, but don't ask me why :). I've just removed the imported generator project and it worked. So I've just commited it - I'm too lazy to investigate more, or there are more necessary things to do.

Viva le Blog

Well, the summer is here and there isn't anything better than taking a great rest from school. Damn, I wish I could.

The situation is different, however. I didn't work much on my diploma thesis last days, weeks and months and since I feel a little bit guilty I decided to make things better. From now on, I will use this blog to track my progress, store my ideas, etc. I don't except anyone to read this blog, at least till the project gets to be interesting to someone else (if ever).

I'm so bad at general talk, so let's get rolling.