Community
Participate
Working Groups
Hi, I was editing java class and suddenly all the editor collapse. Some how compiler error had managed to stop the editor. I could not open the java class to fix it. I could no build the project. The line that causes this error was: String s = prefix " Fail to insert record to db " + e.getMessage(); (Note: missing '+' between the prefix and the rest of the string) (I had to find it out using notepad since the eclipse stopped working) The error console showed the following exceptions: Error 2005-06-20 15:23:51.808 Error in JDT Core during AST creation java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.LocalDeclaration at org.eclipse.jdt.internal.compiler.parser.RecoveredMethod.updateFromParserState (RecoveredMethod.java:378) at org.eclipse.jdt.internal.compiler.parser.Parser.updateRecoveryState (Parser.java:9324) at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError (Parser.java:9258) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8440) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8739) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements (MethodDeclaration.java:116) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod (TypeDeclaration.java:839) at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies (Parser.java:7818) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:787) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:498) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST (ASTParser.java:779) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:588) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run (ASTProvider.java:566) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST (ASTProvider.java:563) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST (ASTProvider.java:493) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartList enerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:165) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run (SelectionListenerWithASTManager.java:142) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76) Error 2005-06-20 15:23:54.339 Problems occurred when invoking code from plug- in: "org.eclipse.jdt.ui". java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.LocalDeclaration at org.eclipse.jdt.internal.compiler.parser.RecoveredMethod.updateFromParserState (RecoveredMethod.java:378) at org.eclipse.jdt.internal.compiler.parser.Parser.updateRecoveryState (Parser.java:9324) at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError (Parser.java:9258) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8440) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8739) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements (MethodDeclaration.java:116) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod (TypeDeclaration.java:839) at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies (Parser.java:7818) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:787) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:498) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST (ASTParser.java:779) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:588) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run (ASTProvider.java:566) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST (ASTProvider.java:563) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST (ASTProvider.java:493) at org.eclipse.jdt.internal.ui.text.java.hover.NLSStringHover.getHoverInfo (NLSStringHover.java:84) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo (BestMatchHover.java:102) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInf o(JavaEditorTextHoverProxy.java:69) at org.eclipse.jface.text.TextViewerHoverManager$4.run (TextViewerHoverManager.java:160)
(In reply to comment #0) THe full methos is: public static void notif(DomWrapper xml, int notifType) throws DatabaseErrorException CallableStatement st = null; ResultSet rs = null; Connection con = null; int tempInt = -1; String tempStr = null; int index = 0; String prefix = "notif: type(" + notifType +")"; try { con = DataSourceManager.getConnection(); String sql = null; st =con.prepareCall(sql); tempInt = xml.getAttAsInt(FulfillmentParser.SHIPMENT_ID); st.setInt(++index, tempInt) ; st.registerOutParameter(++index, Types.VARCHAR); st.execute(); String status = st.getString(index); if ( !OK.equals(status) ) throw new DatabaseErrorException(prefix + " Fail to insert record to db " + status ,status); } catch (SQLException e) { Debugger.error(prefix + " Fail insert record to db xml = " + xml, e); throw new DatabaseErrorException(prefix " Fail to insert record to db " + e.getMessage()); } finally { close(con, st); } } Note: the starting '{' before the start of the method is missing and '+' after the prefix in the catch clause. > Hi, > I was editing java class and suddenly all the editor collapse. > Some how compiler error had managed to stop the editor. > I could not open the java class to fix it. I could no build the project. > The line that causes this error was: > String s = prefix " Fail to insert record to db " + e.getMessage(); > (Note: missing '+' between the prefix and the rest of the string) > (I had to find it out using notepad since the eclipse stopped working) > The error console showed the following exceptions: > Error 2005-06-20 15:23:51.808 Error in JDT Core during AST creation > java.lang.ClassCastException: > org.eclipse.jdt.internal.compiler.ast.LocalDeclaration > at > org.eclipse.jdt.internal.compiler.parser.RecoveredMethod.updateFromParserState > (RecoveredMethod.java:378) > at org.eclipse.jdt.internal.compiler.parser.Parser.updateRecoveryState > (Parser.java:9324) > at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError > (Parser.java:9258) > at org.eclipse.jdt.internal.compiler.parser.Parser.parse > (Parser.java:8440) > at org.eclipse.jdt.internal.compiler.parser.Parser.parse > (Parser.java:8739) > at > org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements > (MethodDeclaration.java:116) > at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod > (TypeDeclaration.java:839) > at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies > (Parser.java:7818) > at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve > (CompilationUnitResolver.java:787) > at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve > (CompilationUnitResolver.java:498) > at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST > (ASTParser.java:779) > at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:588) > at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run > (ASTProvider.java:566) > at org.eclipse.core.internal.runtime.InternalPlatform.run > (InternalPlatform.java:1038) > at org.eclipse.core.runtime.Platform.run(Platform.java:775) > at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST > (ASTProvider.java:563) > at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST > (ASTProvider.java:493) > at > org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartList > enerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:165) > at > org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run > (SelectionListenerWithASTManager.java:142) > at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76) > Error 2005-06-20 15:23:54.339 Problems occurred when invoking code from plug- > in: "org.eclipse.jdt.ui". > java.lang.ClassCastException: > org.eclipse.jdt.internal.compiler.ast.LocalDeclaration > at > org.eclipse.jdt.internal.compiler.parser.RecoveredMethod.updateFromParserState > (RecoveredMethod.java:378) > at org.eclipse.jdt.internal.compiler.parser.Parser.updateRecoveryState > (Parser.java:9324) > at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError > (Parser.java:9258) > at org.eclipse.jdt.internal.compiler.parser.Parser.parse > (Parser.java:8440) > at org.eclipse.jdt.internal.compiler.parser.Parser.parse > (Parser.java:8739) > at > org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements > (MethodDeclaration.java:116) > at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod > (TypeDeclaration.java:839) > at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies > (Parser.java:7818) > at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve > (CompilationUnitResolver.java:787) > at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve > (CompilationUnitResolver.java:498) > at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST > (ASTParser.java:779) > at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:588) > at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run > (ASTProvider.java:566) > at org.eclipse.core.internal.runtime.InternalPlatform.run > (InternalPlatform.java:1038) > at org.eclipse.core.runtime.Platform.run(Platform.java:775) > at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST > (ASTProvider.java:563) > at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST > (ASTProvider.java:493) > at > org.eclipse.jdt.internal.ui.text.java.hover.NLSStringHover.getHoverInfo > (NLSStringHover.java:84) > at > org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo > (BestMatchHover.java:102) > at > org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInf > o(JavaEditorTextHoverProxy.java:69) > at org.eclipse.jface.text.TextViewerHoverManager$4.run > (TextViewerHoverManager.java:160)
Created attachment 23539 [details] Compile this code It produces: Eclipse Java Compiler 0.567, pre-3.1.0 release candidate-3, Copyright IBM Corp 2000, 2005. All rights reserved. [parsing d:\tests_sources\X.java - #1/1] [reading java/lang/Object.class] [analyzing d:\tests_sources\X.java - #1/1] ---------- 1. ERROR in d:\tests_sources\X.java (at line 0) public class X { ^ Internal compiler error java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.MessageSend at org.eclipse.jdt.internal.compiler.parser.RecoveredMethod.updateFromParserState(RecoveredMethod.java:378) at org.eclipse.jdt.internal.compiler.parser.Parser.updateRecoveryState(Parser.java:9326) at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError(Parser.java:9260) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:8442) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:8741) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements(MethodDeclaration.java:116) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod(TypeDeclaration.java:839) at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies(Parser.java:7820) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:493) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329) at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:2691) at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1151) at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1048) at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1040) at org.eclipse.jdt.core.tools.compiler.Compile.main(Compile.java:19) ---------- 2. ERROR in d:\tests_sources\X.java (at line 2) public static void notif(DomWrapper xml, int notifType) throws DatabaseErrorException ^^^^^^^^^^^^^^^^^^^^^^ Syntax error on token "DatabaseErrorException", { expected after this token ---------- 3. ERROR in d:\tests_sources\X.java (at line 28) throw new DatabaseErrorException(prefix " Fail to insert record to db " + e.getMessage()); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Syntax error on token "" Fail to insert record to db "", delete this token ---------- Once this happen in the java editor, the editor dies and it is impossible to edit the file again.
This bug occurs in build 3.0 and 3.0.2. Simple test case: public class X { public void foo() try { } catch (Exception e) { bar("blabla"); throw new Exception(prefix "bloblo"); } } }
The attachment x.java cannot be openned by the editor and cannot be compilles open editor error: Error 2005-06-20 17:54:29.523 Problems occurred when invoking code from plug- in: "org.eclipse.jface". java.lang.ClassCastException at org.eclipse.jdt.internal.compiler.parser.RecoveredMethod.updateFromParserState (RecoveredMethod.java:378) at org.eclipse.jdt.internal.compiler.parser.Parser.updateRecoveryState (Parser.java:9324) at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError (Parser.java:9258) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8440) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8739) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements (MethodDeclaration.java:116) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod (TypeDeclaration.java:839) at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies (Parser.java:7818) at org.eclipse.jdt.internal.compiler.SourceElementParser.parseCompilationUnit (SourceElementParser.java:1339) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure (CompilationUnit.java:130) at org.eclipse.jdt.internal.core.Openable.generateInfos (Openable.java:233) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed (JavaElement.java:488) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java:232) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java:218) at org.eclipse.jdt.internal.core.JavaElement.getChildren (JavaElement.java:173) at org.eclipse.jdt.internal.core.JavaElement.getChildrenOfType (JavaElement.java:187) at org.eclipse.jdt.internal.core.CompilationUnit.getTypes (CompilationUnit.java:813) at org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil.getMainType (JavaElementUtil.java:85) at org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester.isUseS uperTypeAvailable(RefactoringAvailabilityTester.java:884) at org.eclipse.jdt.ui.actions.UseSupertypeAction.selectionChanged (UseSupertypeAction.java:86) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionChanged (SelectionDispatchAction.java:210) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.selectionChanged (SelectionDispatchAction.java:205) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:162) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged (Viewer.java:160) at org.eclipse.jface.viewers.StructuredViewer.updateSelection (StructuredViewer.java:1784) at org.eclipse.jface.viewers.StructuredViewer.handleSelect (StructuredViewer.java:1027) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected (StructuredViewer.java:1053) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent (OpenStrategy.java:209) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:204) at org.eclipse.jface.util.OpenStrategy$1.handleEvent (OpenStrategy.java:364) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3058) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2691) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1716) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1680) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:365) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) build error: Error 2005-06-20 17:55:59.697 Problems occurred when invoking code from plug- in: "org.eclipse.core.resources". java.lang.ClassCastException at org.eclipse.jdt.internal.compiler.parser.RecoveredMethod.updateFromParserState (RecoveredMethod.java:378) at org.eclipse.jdt.internal.compiler.parser.Parser.updateRecoveryState (Parser.java:9324) at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError (Parser.java:9258) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8440) at org.eclipse.jdt.internal.compiler.parser.Parser.parse (Parser.java:8739) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements (MethodDeclaration.java:116) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod (TypeDeclaration.java:839) at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies (Parser.java:7818) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:493) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (AbstractImageBuilder.java:240) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (AbstractImageBuilder.java:190) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build (IncrementalImageBuilder.java:114) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas (JavaBuilder.java:224) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build (JavaBuilder.java:152) at org.eclipse.core.internal.events.BuildManager$2.run (BuildManager.java:593) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:168) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:202) at org.eclipse.core.internal.events.BuildManager$1.run (BuildManager.java:231) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:234) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop (BuildManager.java:253) at org.eclipse.core.internal.events.BuildManager.build (BuildManager.java:282) at org.eclipse.core.internal.resources.Workspace.build (Workspace.java:211) at org.eclipse.ui.actions.GlobalBuildAction$1.run (GlobalBuildAction.java:182) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
Scenario is not new, was already in 3.0, and absolutely no one ever found it until now. Decreasing priority, since not a stop ship for 3.1. However, now we know about it, we want to address it in a forthoming 3.1.1 maintenance stream.
I forgot a word in comment 3: This bug occurs 'also' in build 3.0 and 3.0.2.
Created attachment 23611 [details] Proposed patch This patch add two protection: - Check if nodes are really Argument - Update RecoveredMethod only if parent is not null because in this case the method has been already recovered in diet parse.
Given you rely on "correct" signatures, what if some tool (like our compiler) did have a bug in some signatures ? An IllegalArgumentException could traverse the code now... what are the consequences ?
Fix released and test added. DietRecoveryTest#test112()
Verified in I20050808-2000
Verified for 3.1.1 using build M20050923-1430.