Note that there are some explanatory texts on larger screens.

plurals
  1. POException while generating AST using Eclipse JDT SDK in a non-eclipse environment
    text
    copied!<p>I'm trying to use the jdt's AST generation feature in a non-eclipse environment(as a plugin for another basic java ide). My program creates the AST correctly when I run it inside eclipse, but when I test the plugin it from the ide I get this exception:</p> <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NoSuchFieldError: ignoreMethodBodies at org.eclipse.jdt.core.dom.CompilationUnitResolver.parse(CompilationUnitResolver.java:491) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1200) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java :807) at mytreetest.TreeMaker.buildTree(Unknown Source) ... (further stack trace) ... </code></pre> <p>The code I've used is quite basic:</p> <p>Code:</p> <pre><code>ASTParser parser = ASTParser.newParser(AST.JLS4); String src = readFile(filePath); parser.setSource(src.toCharArray()); parser.setKind(ASTParser.K_COMPILATION_UNIT); Map&lt;String, String&gt; options = JavaCore.getOptions(); JavaCore.setComplianceOptions(JavaCore.VERSION_1_7, options); parser.setCompilerOptions(options); CompilationUnit cu = (CompilationUnit) parser.createAST(null); </code></pre> <p>I went through the source code of org.eclipse.jdt.core.dom.CompilationUnitResolver and org.eclipse.jdt.internal.compiler.impl.CompilerOptions. CompilerOptions does have a public boolean field called ignoreMethodBodies.</p> <p>What can be causing this error?</p> <p>Please help me out.</p> <p>Here are the eclipse jar files I've included :</p> <pre><code>org.eclipse.core.contenttype_3.4.100.v20110423-0524.jar org.eclipse.core.jobs_3.5.100.v20110404.jar org.eclipse.core.resources_3.7100.v20110510-0712.jar org.eclipse.core.runtime_3.7.O.v20110110.jar org.eclipse.equinoxcommon_3.6.O.v20110523.jar org.eclipse.equinox.preferences_3.4.1.R37x_v20110725.jar org.eclipse.jdt.compiler.apt_1.O.400.v0110816-0800.jar org.eclipse.jdt.compiler.tooLl.O.100.v_B76_R37x.jar org.edipse.jdt.core_3.7.1.v_B76_R37x.jar org.eclipse.jface3.7.0J20110522-1430.jar org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar org.eclipse.osgi.utiL3.2.200.v20110110.jar org.eclipse.text3.5101 .r371y20110810-O800jar </code></pre> <p><strong>UPDATE:</strong></p> <p>I've found the fix for this. The java-ide from which I was running this code was using ecj. The problem was that ecj.jar was clashing with the jdt-core modules I'd included with my plugin. Replacing the ide's ecj with jdt-core(org.eclipse.jdt.core_XX.XX.jar and the rest of the jars) and updating its classpath solved the problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload