Community
Participate
Working Groups
The following program causes the compiler to crash on either XP or Linux when the assert is uncommented: public class Test { class CacheEntry { private void add(int i) { // assert (i < 0) : "message"; } } } The log entries are: !ENTRY org.eclipse.ui 4 4 Dec 20, 2002 09:24:15.720 !MESSAGE Save Failed !ENTRY org.eclipse.ui 2 0 Dec 20, 2002 09:24:15.720 !MESSAGE Save Failed !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ClassFile.addFieldInfo (ClassFile.java:434) at org.eclipse.jdt.internal.compiler.ClassFile.addFieldInfos (ClassFile.java:579) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode (TypeDeclaration.java:694) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode (TypeDeclaration.java:762) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode (TypeDeclaration.java:709) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode (TypeDeclaration.java:770) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode (CompilationUnitDeclaration.java:158) at org.eclipse.jdt.internal.compiler.Compiler.resolve (Compiler.java:591) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process (CompilationUnitProblemFinder.java:204) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure (CompilationUnit.java:90) at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent (CompilationUnit.java:664) at org.eclipse.jdt.internal.core.WorkingCopy.reconcile (WorkingCopy.java:446) at org.eclipse.jdt.internal.core.WorkingCopy.reconcile (WorkingCopy.java:421) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.doSaveDo cument(CompilationUnitDocumentProvider.java:903) at org.eclipse.ui.texteditor.AbstractDocumentProvider.saveDocument (AbstractDocumentProvider.java:454) at org.eclipse.ui.texteditor.AbstractTextEditor$11.execute (AbstractTextEditor.java:2772) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run (WorkspaceModifyOperation.java:65) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1564) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.performSaveOperation (AbstractTextEditor.java:2790) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.performSaveOperati on(CompilationUnitEditor.java:849) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSave (CompilationUnitEditor.java:913) at org.eclipse.ui.internal.EditorManager$11.run (EditorManager.java:1032) at org.eclipse.ui.internal.EditorManager$8.run(EditorManager.java:901) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:296) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:246) at org.eclipse.jface.window.ApplicationWindow$1.run (ApplicationWindow.java:432) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:65) at org.eclipse.jface.window.ApplicationWindow.run (ApplicationWindow.java:429) at org.eclipse.ui.internal.WorkbenchWindow.run (WorkbenchWindow.java:1174) at org.eclipse.ui.internal.EditorManager.runProgressMonitorOperation (EditorManager.java:907) at org.eclipse.ui.internal.EditorManager.saveEditor (EditorManager.java:1037) at org.eclipse.ui.internal.WorkbenchPage.saveEditor (WorkbenchPage.java:2143) at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:30) at org.eclipse.jface.action.Action.runWithEvent(Action.java:769) at org.eclipse.ui.internal.WWinKeyBindingService.invoke (WWinKeyBindingService.java:139) at org.eclipse.ui.internal.WWinKeyBindingService.pressed (WWinKeyBindingService.java:120) at org.eclipse.ui.internal.WWinKeyBindingService$6.widgetSelected (WWinKeyBindingService.java:376) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent (AcceleratorMenu.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1692) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1410) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1446) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1429) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:247) at org.eclipse.core.launcher.Main.run(Main.java:703) at org.eclipse.core.launcher.Main.main(Main.java:539)
I will investigate.
The bug is due to the fact that two synthetic fields share the same index. Therefore we got a null in the synthetic fields arrays and we cannot generate the field info properly. I will see how to fix it.
I think the bug is that we put 0 as the index for the assertion synthetic fields instead of synthetics[FIELD].size(). A fix could be to replace: synthField = new SyntheticFieldBinding( "$assertionsDisabled".toCharArray(), //$NON-NLS-1$ BooleanBinding, AccDefault | AccStatic | AccSynthetic | AccFinal, this, Constant.NotAConstant, 0); synthetics[FIELD].put("assertionEmulation", synthField); //$NON-NLS-1$ with: synthField = new SyntheticFieldBinding( "$assertionsDisabled".toCharArray(), //$NON-NLS-1$ BooleanBinding, AccDefault | AccStatic | AccSynthetic | AccFinal, this, Constant.NotAConstant, synthetics[FIELD].size()); synthetics[FIELD].put("assertionEmulation", synthField); //$NON-NLS-1$ in SourceTypeBinding.addSyntheticField(AssertStatement assertStatement, BlockScope blockScope).
*** Bug 28819 has been marked as a duplicate of this bug. ***
*** Bug 28760 has been marked as a duplicate of this bug. ***
*** Bug 28934 has been marked as a duplicate of this bug. ***
*** Bug 28953 has been marked as a duplicate of this bug. ***
*** Bug 28954 has been marked as a duplicate of this bug. ***
*** Bug 28980 has been marked as a duplicate of this bug. ***
How did it ever work ?
I think it never worked inside an inner class that required its enclosing instance. I will release the fix tomorrow.
Fixed and released in 2.1 stream. Regression test added.
*** Bug 29031 has been marked as a duplicate of this bug. ***
*** Bug 29029 has been marked as a duplicate of this bug. ***
*** Bug 29088 has been marked as a duplicate of this bug. ***
*** Bug 29197 has been marked as a duplicate of this bug. ***
*** Bug 29229 has been marked as a duplicate of this bug. ***
*** Bug 29267 has been marked as a duplicate of this bug. ***
*** Bug 30232 has been marked as a duplicate of this bug. ***
*** Bug 30418 has been marked as a duplicate of this bug. ***
*** Bug 30746 has been marked as a duplicate of this bug. ***
Verified.