Community
Participate
Working Groups
I20100915-2024 What steps will reproduce the problem? 1. Checkout the following project into your workspace: * org.eclipse.compare * org.eclipse.compare.core * org.eclipse.core.runtime * org.eclipse.equinox.common * org.eclipse.jface * org.eclipse.jface.text * org.eclipse.text 2. Import project from the attached zip 3. Open CompareMainRoutine 4. Try to fix the errors You should get this: -- Error Details -- Date: Fri Sep 17 12:20:06 CEST 2010 Message: Exception occurred during problem detection:----------------------------------- SOURCE BEGIN ------------------------------------- import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.contentmergeviewer.ITokenComparator; import org.eclipse.compare.contentmergeviewer.TextMergeViewer; import org.eclipse.compare.contentmergeviewer.TokenComparator; import org.eclipse.compare.internal.MergeViewerContentProvider; import org.eclipse.compare.internal.Utilities; import org.eclipse.compare.internal.merge.DocumentMerger; import org.eclipse.compare.internal.merge.DocumentMerger.IDocumentMergerInput; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; public class CompareMainRoutine { public static void main(String[] args) { CompareMainRoutine routine = new CompareMainRoutine(); routine.findDiff(".classpath", ".project"); } public CompareMainRoutine() { } public class DiffDataStructure { /** Delete type of difference - a portion of a file was removed in the other */ public static final int DELETE = 0; /** Add type of difference - a portion of a file was added in the other */ public static final int ADD = 1; /** Change type of difference - a portion of a file was changed in the other */ public static final int CHANGE = 2; public int type = 0; public int firstStart = 0; // start line number of subsequence in oldVersion public int firstEnd = 0; // end line number of subsequence in newVersion public int secondStart = 0; // start line number of subsequence in newVersion public int secondEnd = 0; // end line number of subsequence in newVersion } public static void findDiff(String oldVersion, String newVersion) { // The following are needed // 1. Read in the two before and after strings final String before; final String after; try { before = Utilities.readString(new FileInputStream(new File(oldVersion)), "cp1250"); after = Utilities.readString(new FileInputStream(new File(newVersion)), "cp1250"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // 2. Run the appropriate string comparison procedure from eclipse compare DocumentMerger merger = new DocumentMerger(new IDocumentMergerInput() { @Override public ITokenComparator createTokenComparator(String line) { return new TokenComparator(line); } @Override public CompareConfiguration getCompareConfiguration() { return null; } @Override public IDocument getDocument(char contributor) { switch (contributor) { case MergeViewerContentProvider.LEFT_CONTRIBUTOR: return new Document(before); case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: return new Document(after); } return null; } @Override public int getHunkStart() { return 0; } @Override public Position getRegion(char contributor) { switch (contributor) { case MergeViewerContentProvider.LEFT_CONTRIBUTOR: return fLeft.getRegion(); case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: return fRight.getRegion(); } return null; } @Override public boolean isHunkOnLeft() { return false; } @Override public boolean isIgnoreAncestor() { return true; } @Override public boolean isPatchHunk() { return false; } @Override public boolean isShowPseudoConflicts() { return false; } @Override public boolean isThreeWay() { return false; } @Override public boolean isPatchHunkOk() { return true; } }); try { merger.doDiff(); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } // 3. Output the results in a format compatible with the above data structure, i.e., DiffDataStructure } } ----------------------------------- SOURCE END ------------------------------------- Severity: Error Product: Eclipse SDK 3.7.0.v201009152024 (org.eclipse.sdk.ide) Plugin: org.eclipse.jdt.core Session Data: eclipse.buildId=I20100915-2024 java.version=1.6.0_17 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_CA Framework arguments: -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:MaxPermSize=256m Command-line arguments: -os win32 -ws win32 -arch x86 -data c:\workspace\eclipse\team\dev.eclipse.org_HEAD_extssh -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:MaxPermSize=256m Exception Stack Trace: java.lang.IllegalArgumentException: info cannot be null at org.eclipse.jdt.internal.compiler.codegen.StackMapFrame.addStackItem(StackMapFrame.java:81) at org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:4489) at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:3336) at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttribute(ClassFile.java:1161) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:245) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:179) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:542) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:611) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:361) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:889) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:928) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:202) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:268) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:190) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1244) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.initialReconcile(JavaReconcilingStrategy.java:178) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.initialReconcile(CompositeReconcilingStrategy.java:114) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.initialReconcile(JavaCompositeReconcilingStrategy.java:133) at org.eclipse.jface.text.reconciler.MonoReconciler.initialProcess(MonoReconciler.java:105) at org.eclipse.jdt.internal.ui.text.JavaReconciler.initialProcess(JavaReconciler.java:398) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:173) Followed by bunch of "Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".", "Error in JDT Core during reconcile" and "Error in JDT Core during AST creation" errors.
Created attachment 179100 [details] The problematic project exported to zip file
Once I've fixed the errors in the code, without any assistance from JDT and ignoring hordes of exceptions in the error log, the JDT seems to be back to normal. Lowering priority.
I'll take care of this.
The fix for bug 324848 exposes an existing bug. In your case the variable before and after may have not been initialized when used inside the anonymous type. We now properly report the problem against the anonymous type method declaration instead of flagging the outer method. The problem with that is that the code generation for the outer method cannot be done because the variable might not be initialized. In order to generate the anonymous type instantiation, the value of the local variable before is required, but at that moment it might not be initialized. I am working on a fix for M3.
Created attachment 179141 [details] Proposed fix + regression tests Patch under test
Created attachment 179145 [details] Proposed fix + regression tests Released patch (same patch with minor test changes)
Released for 3.7M3. Regression tests added in: org.eclipse.jdt.core.tests.compiler.regression.ProblemTypeAndMethodTest#test113 org.eclipse.jdt.core.tests.compiler.regression.InitializationTests#test325567
Verified for 3.7M3 using build I20101025-0901.