Bug 265962 - [compiler] Internal compiler error on while with return clause
Summary: [compiler] Internal compiler error on while with return clause
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-24 09:45 EST by Stefan Kolarov CLA
Modified: 2009-03-10 10:29 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (8.08 KB, patch)
2009-03-04 11:30 EST, Philipe Mulet CLA
no flags Details | Diff
Proposed patch for 3.4 (8.08 KB, patch)
2009-03-04 11:56 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Kolarov CLA 2009-02-24 09:45:52 EST
Removed by Webmaster as requested by Author
Comment 1 Olivier Thomann CLA 2009-02-24 09:51:59 EST
Could you please provide the build id?
This code compiles fine using HEAD.
Comment 2 Stefan Kolarov CLA 2009-02-24 16:59:31 EST
(In reply to comment #1)
> Could you please provide the build id?
> This code compiles fine using HEAD.
> 

As found on Help>About Eclipse SDK

Version: 3.4.1
Build id: M20080911-1700
Comment 3 Olivier Thomann CLA 2009-03-02 11:28:32 EST
This fails only with 3.4.2.
HEAD compiles without an error, but the generated code is far from optimal.

	public static void main(String[] args) {
		do {
			return;
		} while (isIS() && false);
	}

generates:
  // Method descriptor #17 ([Ljava/lang/String;)V
  // Stack: 1, Locals: 1
  public static void main(String[] args);
    0  return
    1  invokestatic X.isIS() : boolean [18]
    4  pop
    5  return
      Line numbers:
        [pc: 0, line: 8]
        [pc: 1, line: 9]
        [pc: 5, line: 10]
      Local variable table:
        [pc: 0, pc: 6] local: args index: 0 type: String[]

instead of:
  // Method descriptor #17 ([Ljava/lang/String;)V
  // Stack: 1, Locals: 1
  public static void main(String[] args);
    0  return
      Line numbers:
        [pc: 0, line: 8]
      Local variable table:
        [pc: 0, pc: 1] local: args index: 0 type: String[]
Comment 4 Philipe Mulet CLA 2009-03-04 09:18:01 EST
I'll look. Indeed, the code doesn't look happy.
btw - there is more to it, flow analysis is not detecting a problem here:

public class X {
        private static final boolean isIS() {
                return System.currentTimeMillis()<0 ;
        }
        public static void main(String[] args) {
                do {
                        return;
                } while(isIS() && false);
                return;
        }
}
Comment 5 Philipe Mulet CLA 2009-03-04 09:46:40 EST
Added FlowAnalysisTest#test060-061.
Comment 6 Philipe Mulet CLA 2009-03-04 11:30:06 EST
Created attachment 127492 [details]
Proposed patch
Comment 7 Philipe Mulet CLA 2009-03-04 11:56:43 EST
Created attachment 127501 [details]
Proposed patch for 3.4
Comment 8 Philipe Mulet CLA 2009-03-04 11:57:50 EST
Problem has been existing at least since 3.2
Comment 9 Philipe Mulet CLA 2009-03-04 12:31:18 EST
Erratum: Comment 5 should have read:
         Added FlowAnalysisTest#test061-062.
Comment 10 Philipe Mulet CLA 2009-03-04 12:46:03 EST
Released for 3.5M6.
Fixed
Comment 11 Philipe Mulet CLA 2009-03-04 12:51:58 EST
Released in 3.3.x branch.
Comment 12 Philipe Mulet CLA 2009-03-04 14:17:02 EST
Released for 3.4.x
Comment 13 Stefan Kolarov CLA 2009-03-06 04:52:21 EST
For the record, I am reposting my original bug report:

Here is example code to reporduce the issue. The stacktrace follows the code:

====== code ==========

package org.cheffo.test;

public class delme {
        private static final boolean isIS() {
                return System.currentTimeMillis()<0 ;
        }
        public static void main(String[] args) {
                do {
                        return;
                } while(isIS() && false);
        }
}

====== stacktrace ======

Internal compiler error java.lang.NullPointerException at
org.eclipse.jdt.internal.compiler.ast.MessageSend.generateCode(MessageSend.java:136)
at 

org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression.generateCode(AND_AND_Expression.java:89)
at 

org.eclipse.jdt.internal.compiler.ast.DoStatement.generateCode(DoStatement.java:152)
at 

org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:232)
at 

org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:179)
at 

org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:530)
at 

org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:581)
at 

org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:356)
at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:
 755) at
org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
at java.lang.Thread.run(Unknown Source)
Comment 14 Kent Johnson CLA 2009-03-10 10:29:58 EDT
Verified for 3.5M6 using I20090310-0100