'java.lang.NoSuchFieldError: ignoreMethodBodies' Exception while creating AST

ε祈祈猫儿з 提交于 2019-12-13 07:35:58

问题


While passing a java source code to the below mentioned code, I get an exception and have no idea how to fix this. Kindlly let me know where I am wrong/ any alternative solution...

Source Code:

char[] source = resultEntryIndustry.text.toCharArray();
ASTParser parser = ASTParser.newParser(AST.JLS3);  
parser.setSource(source);
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_5, options);
parser.setCompilerOptions(options);
CompilationUnit cUnit = (CompilationUnit) parser.createAST(null);

Exception thrown:

Exception in thread "main" 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:1194)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:801)
at itjava.model.CompilationUnitStoreIndustry.createCompilationUnitFacadeList(CompilationUnitStoreIndustry.java:71)
at itjava.presenter.WordInfoPresenterIndustry.SetCompilationUnitListAndAccessRepository(WordInfoPresenterIndustry.java:162)
at itjava.industry.code2String.main(code2String.java:31)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]

The source code parsed is a simple java file used to connect to database using JDBC.


回答1:


I was facing an almost similar problem and found the fix. Whatever environment you're running the code in, it has some component in its classpath which is not compatible with jdt core.



来源:https://stackoverflow.com/questions/9961588/java-lang-nosuchfielderror-ignoremethodbodies-exception-while-creating-ast

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!