Community
Participate
Working Groups
I get a "Save could not be completed." "Reason:" "org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding" This started after I added this line to my code: out.println("Started " + java.text.DateFormat.format(new java.util.Date())); If I comment out the line, I can save and copy. With the line uncommented again, neither operation works. Here is the rest of the code. private void printTest () throws IOException { File rebuiltLog = new File(workingDir, "rebuild.log"); PrintStream out; rebuiltLog.createNewFile(); out = new PrintStream(new FileOutputStream(rebuiltLog)); out.println("Started " + java.text.DateFormat.format(new java.util.Date())); }
I found out it is the java.text.DateFormat part of the line that cause the error. If I import java.text.DateFormat and just reference DateFormat the save works fine.
Could you please provide the contents of your .log file? Look in .metadata folder.
I think that is what you are looking for. !ENTRY org.eclipse.jdt.core 4 4 Oct 20, 2004 13:23:29.437 !MESSAGE Exception occurred during problem detection: !STACK 0 java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.computeConversion(QualifiedNameReference.java:272) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:335) at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:190) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:400) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:139) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:378) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:940) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:989) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:280) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:564) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:175) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:148) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:202) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:544) at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:978) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:58) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:700) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:739) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1104) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:88) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:129) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:96) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:75) at org.eclipse.jdt.internal.ui.text.JavaReconciler.process(JavaReconciler.java:315) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:204)
Reproduced. Thanks for the stack trace.
Created attachment 15312 [details] Test case
Created attachment 15313 [details] Apply on HEAD
With the proposed patch the test case returns: ---------- 1. ERROR in c:\tests_sources\X.java (at line 4) return "Started " + java.text.DateFormat.format(new java.util.Date()); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cannot make a static reference to the non-static method format(Date) from the type DateFormat ---------- 1 problem (1 error)
Patch is good. Also avoid calling #computeConversion in this situation (when the receiver is known to be invalid). Added regression test: LookupTest#test049 Fixed
Verified for 3.1M3 with build I200411040100