Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Exception while generating AST in a non-eclipse environment('java.lang.NoSuchFieldError: ignoreMethodBodies' Exception while creating the AST)
icon5.gif  Exception while generating AST in a non-eclipse environment [message #835648] Tue, 03 April 2012 09:58 Go to next message
Manindra Moharana is currently offline Manindra Moharana
Messages: 5
Registered: April 2012
Junior Member
Hello,

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:

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)
...

The code I've used is quite basic:

ASTParser parser = ASTParser.newParser(AST.JLS4);
String src = readFile(filePath);
parser.setSource(src.toCharArray());
parser.setKind(ASTParser.K_COMPILATION_UNIT);
Map<String, String> options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_7, options);
parser.setCompilerOptions(options);
CompilationUnit cu = (CompilationUnit) parser.createAST(null);


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.

What can be causing this error?

Please help me out.

Here are the eclipse jar files I've included :

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
Re: Exception while generating AST in a non-eclipse environment [message #835666 is a reply to message #835648] Tue, 03 April 2012 10:21 Go to previous messageGo to next message
Olivier Thomann is currently offline Olivier Thomann
Messages: 518
Registered: July 2009
Senior Member
You must have a version of jdt.core bundle on your classpath which is not compatible with the one from your Eclipse environment.
--
Olivier
Re: Exception while generating AST in a non-eclipse environment [message #835729 is a reply to message #835666] Tue, 03 April 2012 11:49 Go to previous messageGo to next message
Manindra Moharana is currently offline Manindra Moharana
Messages: 5
Registered: April 2012
Junior Member
Yes, the java ide was using ecj. I updated its classpath to add the jdt plugins and now it works fine.

Thanks for the quick reply Smile
Re: Exception while generating AST in a non-eclipse environment [message #835865 is a reply to message #835729] Tue, 03 April 2012 15:32 Go to previous messageGo to next message
Manindra Moharana is currently offline Manindra Moharana
Messages: 5
Registered: April 2012
Junior Member
Hi,

Another follow up query - Is it possible for ecj.jar and the jdt-core plugin to co-exist in the classpath and not generate the above error? Any type of workaround to achieve this?
Re: Exception while generating AST in a non-eclipse environment [message #835874 is a reply to message #835865] Tue, 03 April 2012 15:49 Go to previous messageGo to next message
Olivier Thomann is currently offline Olivier Thomann
Messages: 518
Registered: July 2009
Senior Member
Why do you need both? The org.eclipse.jdt.core bundle and its fragments contains what the ecj.jar contains. org.eclipse.jdt.core is also an executable jar. I would leave only the latter on the classpath and remove ecj.jar.

HTH,

Olivier
Re: Exception while generating AST in a non-eclipse environment [message #838821 is a reply to message #835874] Sat, 07 April 2012 14:25 Go to previous message
Manindra Moharana is currently offline Manindra Moharana
Messages: 5
Registered: April 2012
Junior Member
Yes, you're right. I've solved my problem. Big thanks for all the help!
Previous Topic:Eclipse RenameParticipant offset handling
Next Topic:How to add my preferences to the File/Export dialog?
Goto Forum:
  


Current Time: Wed Jul 30 17:18:54 EDT 2014

Powered by FUDForum. Page generated in 0.01756 seconds