Error when creating AST's

146 views Asked by At

I am getting the error below, the methode that gives the nullpointerexception is:

public java set[M3] createM3sFromFiles(set[loc] files, bool errorRecovery = false, list[loc] sourcePath = [], list[loc] classPath = [], str javaVersion = "1.7");  

My code executes correctly on the smallSQL project but not on hsqldb.

My workflow is as follows:

  1. I load the original files in memory
  2. removing the comments
  3. save all processed files in 1 tempdir
  4. try to build M3 with createM3FromDirectory
  5. create ASTs for individual files

The only way I can get it to work is by removing the "package xxx.yyy;" part in the processed source files. Which makes no sense to me, any ideas why it's working on smallSQL but not with hsqldb? If I inspect some class files I can see both are compiled for Java SE 8. If I test with some individual files, it doesn't work, even if the source is very simple (a couple of fields & (g/s)etters)

When I use the original files still containing the comments it does work. (After fixing the out of memory exception by editing the eclipse.ini file). But then it gives me some error that it can not find a key inside a map. I am pretty sure the key gets added, could it be that the map just gets too big and therefore shows erroneous behaviour?


|std:///lang/java/m3/Core.rsc|(2548,246,<70,0>,<72,161>): Java("NullPointerException","")
    at org.rascalmpl.library.lang.java.m3.internal.SourceConverter.getParent(|unknown:///SourceConverter.java|(0,0,<324,0>,<324,0>))
    at org.rascalmpl.library.lang.java.m3.internal.SourceConverter.generatePackageDecls(|unknown:///SourceConverter.java|(0,0,<319,0>,<319,0>))
    at org.rascalmpl.library.lang.java.m3.internal.SourceConverter.generatePackageDecls(|unknown:///SourceConverter.java|(0,0,<319,0>,<319,0>))
    at org.rascalmpl.library.lang.java.m3.internal.SourceConverter.generatePackageDecls(|unknown:///SourceConverter.java|(0,0,<319,0>,<319,0>))
    at org.rascalmpl.library.lang.java.m3.internal.SourceConverter.generatePackageDecls(|unknown:///SourceConverter.java|(0,0,<319,0>,<319,0>))
    at org.rascalmpl.library.lang.java.m3.internal.SourceConverter.visit(|unknown:///SourceConverter.java|(0,0,<344,0>,<344,0>))
    at org.eclipse.jdt.core.dom.PackageDeclaration.accept0(|unknown:///PackageDeclaration.java|(0,0,<219,0>,<219,0>))
    at org.eclipse.jdt.core.dom.ASTNode.accept(|unknown:///ASTNode.java|(0,0,<2711,0>,<2711,0>))
    at org.eclipse.jdt.core.dom.ASTNode.acceptChild(|unknown:///ASTNode.java|(0,0,<2759,0>,<2759,0>))
    at org.eclipse.jdt.core.dom.CompilationUnit.accept0(|unknown:///CompilationUnit.java|(0,0,<210,0>,<210,0>))
    at org.eclipse.jdt.core.dom.ASTNode.accept(|unknown:///ASTNode.java|(0,0,<2711,0>,<2711,0>))
    at org.rascalmpl.library.lang.java.m3.internal.JavaToRascalConverter.convert(|unknown:///JavaToRascalConverter.java|(0,0,<317,0>,<317,0>))
    at org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler.convertToM3(|unknown:///EclipseJavaCompiler.java|(0,0,<163,0>,<163,0>))
    at org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler.lambda$createM3sFromFiles$0(|unknown:///EclipseJavaCompiler.java|(0,0,<78,0>,<78,0>))
    at org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler$1.acceptAST(|unknown:///EclipseJavaCompiler.java|(0,0,<203,0>,<203,0>))
    at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(|unknown:///CompilationUnitResolver.java|(0,0,<1040,0>,<1040,0>))
    at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(|unknown:///CompilationUnitResolver.java|(0,0,<639,0>,<639,0>))
    at org.eclipse.jdt.core.dom.ASTParser.createASTs(|unknown:///ASTParser.java|(0,0,<993,0>,<993,0>))
    at org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler.buildCompilationUnits(|unknown:///EclipseJavaCompiler.java|(0,0,<200,0>,<200,0>))
    at org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler.createM3sFromFiles(|unknown:///EclipseJavaCompiler.java|(0,0,<76,0>,<76,0>))
    at sun.reflect.NativeMethodAccessorImpl.invoke0(|unknown:///NativeMethodAccessorImpl.java|(0,0,<0,0>,<0,0>))
    at createM3sFromFiles(|std:///lang/java/m3/Core.rsc|(4650,11,<108,226>,<108,237>))
    at main(|project://Opdracht%201/src/NewVersionMainModule.rsc|(2645,5398,<87,0>,<209,1>))
    at $root$(|prompt:///|(0,7,<1,0>,<1,7>))
0

There are 0 answers