Bug 76682 - Certain code prevents saving and copy operations
Summary: Certain code prevents saving and copy operations
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-20 13:33 EDT by James Elliott CLA
Modified: 2004-11-04 07:16 EST (History)
0 users

See Also:


Attachments
Test case (135 bytes, text/plain)
2004-10-20 17:16 EDT, Olivier Thomann CLA
no flags Details
Apply on HEAD (2.23 KB, patch)
2004-10-20 17:20 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Elliott CLA 2004-10-20 13:33:27 EDT
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()));
}
Comment 1 James Elliott CLA 2004-10-20 13:38:46 EDT
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.
Comment 2 Olivier Thomann CLA 2004-10-20 14:07:17 EDT
Could you please provide the contents of your .log file?
Look in .metadata folder.
Comment 3 James Elliott CLA 2004-10-20 15:03:06 EDT
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)
Comment 4 Olivier Thomann CLA 2004-10-20 16:53:50 EDT
Reproduced. Thanks for the stack trace.
Comment 5 Olivier Thomann CLA 2004-10-20 17:16:35 EDT
Created attachment 15312 [details]
Test case
Comment 6 Olivier Thomann CLA 2004-10-20 17:20:19 EDT
Created attachment 15313 [details]
Apply on HEAD
Comment 7 Olivier Thomann CLA 2004-10-20 17:21:00 EDT
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)
Comment 8 Philipe Mulet CLA 2004-10-27 05:36:46 EDT
Patch is good. Also avoid calling #computeConversion in this situation (when the
receiver is known to be invalid).
Added regression test: LookupTest#test049
Fixed
Comment 9 David Audel CLA 2004-11-04 07:16:53 EST
Verified for 3.1M3 with build I200411040100