Community
Participate
Working Groups
ImportReferencesCollector needs to support old AST levels, see bug 435540. org.eclipse.jdt.ui.actions.OverrideMethodsAction#createRunnable(..) is a legal way to create an AddUnimplementedMethodsOperation, and there's no restriction on the AST level there. Most of JDT UI only uses the latest AST level, but in this case, we have to support older levels as well. org.eclipse.jst.j2ee.ejb.annotation.model Error Thu May 22 19:26:03 EEST 2014 Operation only supported in JLS8 and later AST java.lang.UnsupportedOperationException: Operation only supported in JLS8 and later AST at org.eclipse.jdt.core.dom.ASTNode.unsupportedIn2_3_4(ASTNode.java:1968) at org.eclipse.jdt.core.dom.AnnotatableType.annotations(AnnotatableType.java:99) at org.eclipse.jdt.internal.corext.codemanipulation.ImportReferencesCollector.visit(ImportReferencesCollector.java:203) at org.eclipse.jdt.core.dom.SimpleType.accept0(SimpleType.java:197) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782) at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:469) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782) at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:212) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711) at org.eclipse.jdt.internal.corext.codemanipulation.ImportReferencesCollector.collect(ImportReferencesCollector.java:68) at org.eclipse.jdt.internal.corext.codemanipulation.ImportReferencesCollector.collect(ImportReferencesCollector.java:62) at org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext.getImportedNames(ContextSensitiveImportRewriteContext.java:226) at org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext.findInContext(ContextSensitiveImportRewriteContext.java:99) at org.eclipse.jdt.core.dom.rewrite.ImportRewrite.internalAddImport(ImportRewrite.java:941) at org.eclipse.jdt.core.dom.rewrite.ImportRewrite.addImport(ImportRewrite.java:639) at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createThrownExceptions(StubUtility2.java:509) at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createImplementationStub(StubUtility2.java:349) at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createImplementationStub(StubUtility2.java:315) at org.eclipse.jdt.internal.corext.codemanipulation.AddUnimplementedMethodsOperation.run(AddUnimplementedMethodsOperation.java:213) at org.eclipse.jst.j2ee.ejb.annotations.internal.classgen.EjbBuilder.createInheritedMethods(EjbBuilder.java:221) ...
Created attachment 243416 [details] Fix 1 Tentative fix. I think this covers all relevant cases, but the fix needs more testing.
Created attachment 243439 [details] Fix 1 + tests
Did you check the following locations for similar issues? org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal.createImportRewrite(CompilationUnit) org.eclipse.jdt.ui.text.java.IProblemLocation.getCoveringNode(CompilationUnit) org.eclipse.jdt.ui.text.java.IProblemLocation.getCoveredNode(CompilationUnit) org.eclipse.jdt.ui.CodeStyleConfiguration.createImportRewrite(CompilationUnit, boolean) ?
Comment on attachment 243439 [details] Fix 1 + tests I've code reviewed the fix and it looks good. Also ran /Eclipse ZRH ALL Tests. For the final review+ I need an positive answer to comment 3.
(In reply to Dani Megert from comment #3) > Did you check the following locations for similar issues? Yes, I checked the whole ImportRewrite stuff and referenced classes like ContextSensitiveImportRewriteContext and ScopeAnalyzer (covers location 1 & 4). The implementations of IProblemLocation.getCover*Node() are harmless as well. I've also looked through the entry points mentioned in bug 435572 comment 1. We do have some problems with JLS2 ASTs, that's why the tests only start with JLS3. But these problems have been in before Luna and JLS2 is very outdated. I don't think we should touch more code than necessary at RC3.
(In reply to Markus Keller from comment #5) Thanks for the complete analysis.
Looks good.
Comment on attachment 243439 [details] Fix 1 + tests Fix looks good.
Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=28a197ac59da2ad5e3d634328ec686072a2a6f7c Manju found a compile error for the generic array creation in the test case. I've fixed that and added an assertion that the AddUnimplementedMethodsOperation really fixes all compile problems.
*** Bug 436198 has been marked as a duplicate of this bug. ***
Verified in I20140601-2000 via code inspection and by verifying that AddUnimplementedMethodsTest#testJLS[348]() are running and green in the build.
Verified fix on RC3 via Sapphire and Oracle product usecases.