Community
Participate
Working Groups
Removed by Webmaster as requested by Author
Could you please provide the build id? This code compiles fine using HEAD.
(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
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[]
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; } }
Added FlowAnalysisTest#test060-061.
Created attachment 127492 [details] Proposed patch
Created attachment 127501 [details] Proposed patch for 3.4
Problem has been existing at least since 3.2
Erratum: Comment 5 should have read: Added FlowAnalysisTest#test061-062.
Released for 3.5M6. Fixed
Released in 3.3.x branch.
Released for 3.4.x
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)
Verified for 3.5M6 using I20090310-0100