Bug 410892 - I've run into an old bug 241044 (info cannot be null - somewhere in the incremental compiler)
Summary: I've run into an old bug 241044 (info cannot be null - somewhere in the incre...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 4.5 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard:
Keywords:
: 412777 453861 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-06-16 16:19 EDT by Erwin Smout CLA
Modified: 2020-04-10 18:01 EDT (History)
7 users (show)

See Also:
jarthana: review+


Attachments
The .log file containing the stack trace as well as the whole class source (901.20 KB, text/plain)
2013-06-18 07:34 EDT, Erwin Smout CLA
no flags Details
eclipse configuration (536.61 KB, text/plain)
2013-11-02 13:02 EDT, Claudio Nieder CLA
no flags Details
Proposed patch (7.50 KB, patch)
2014-11-07 12:15 EST, Olivier Thomann CLA
no flags Details | Diff
Proposed regression tests (6.62 KB, patch)
2014-11-07 12:18 EST, Olivier Thomann CLA
no flags Details | Diff
Better patch (8.43 KB, patch)
2014-11-13 11:30 EST, 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 Erwin Smout CLA 2013-06-16 16:19:55 EDT
The error message appeared when I used a switch (java.lang.String) construct.

It went away when I replaced the switch with a series of if (.equals) statements.

Don't know if this helps.
Comment 1 Stephan Herrmann CLA 2013-06-16 16:48:49 EDT
some questions:

- what is the exact version of plug-in org.eclipse.jdt.core you are using?

- can you try using a more recent version?

- can you isolate a minimal test case that shows the problem?

- please also post the stack trace

thanks
Comment 2 Jay Arthanareeswaran CLA 2013-06-18 04:35:52 EDT
These were comments from Erwin, which were made outside bugzilla:

(In reply to comment #1)
> some questions:
>
> - what is the exact version of plug-in org.eclipse.jdt.core you are  
> using?


Eclipse Java Development Tools

Version: 3.7.2.v20120120-1414-7z8gFcuFMP7BW5XTz0jLTnz0l9B1
Build id: M20120208-0800


> - can you try using a more recent version?

I ran the "check for updates" from the help menu and installed all the
updates.

The problem is still reproducible.

I may try Eclipse 4 when I have that up and running.



> - can you isolate a minimal test case that shows the problem?

I tried narrowing down the class by removing code and/or package
dependencies, but then the issue goes away.



> - please also post the stack trace

Where can I find that ?  All that happens is a pop-up window saying

    Errors occurred during the build.
Errors running builder 'Java Builder' on project 'SIRA_PRISE'.
info cannot be null

There are no log files appearing anywhere.
Comment 3 Jay Arthanareeswaran CLA 2013-06-18 04:36:53 EDT
(In reply to comment #2)
> Where can I find that ?  All that happens is a pop-up window saying
> 
>     Errors occurred during the build.
> Errors running builder 'Java Builder' on project 'SIRA_PRISE'.
> info cannot be null
> 
> There are no log files appearing anywhere.

The logs get stored to a file at the following location:

<workspace_location>/.metadata/.log
Comment 4 Erwin Smout CLA 2013-06-18 07:34:19 EDT
Created attachment 232492 [details]
The .log file containing the stack trace as well as the whole class source
Comment 5 Claudio Nieder CLA 2013-11-02 13:01:09 EDT
I found this bug, because I get also "info cannot be null" messages in 4.4M3.

eclipse.buildId=4.4.0.I20131030-2000
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -keyring /Users/claudio/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -keyring /Users/claudio/.eclipse_keyring -showlocation

Error
Sat Nov 02 17:57:38 CET 2013
Error in JDT Core during AST creation

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:4561)
	at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:3375)
	at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttribute(ClassFile.java:1190)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:296)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:228)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:562)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:631)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:360)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1206)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:685)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1181)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:807)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480)
	at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:170)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:155)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


eclipse.buildId=4.4.0.I20131030-2000
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -keyring /Users/claudio/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -keyring /Users/claudio/.eclipse_keyring -showlocation

Error
Sat Nov 02 17:57:38 CET 2013
Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".

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:4561)
	at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:3375)
	at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttribute(ClassFile.java:1190)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:296)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:228)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:562)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:631)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:360)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1206)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:685)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1181)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:807)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480)
	at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:170)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:155)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

I will add my eclipse configuration as attachment.
Comment 6 Claudio Nieder CLA 2013-11-02 13:02:38 EDT
Created attachment 237149 [details]
eclipse configuration
Comment 7 Stephan Herrmann CLA 2013-11-02 18:17:19 EDT
The stacktrace looks similar indeed.
Unfortunately it doesn't say much about the situation that triggered the bug.
If the bug can be reproduced on your project, could you perhaps extract
a small sample project that demonstrates the bug? TIA.

Also if Erwin could produce a self contained sample that would greatly help.
I tried to use the source from comment 4 but even after creating *many*
stub classes for missing dependencies, I could not observe the bug.
(I gave up about 40% into the source file - after creating 60+ stub classes).
Comment 8 Claudio Nieder CLA 2013-11-03 04:44:56 EST
Sorry, I can't help there as I continued work on that class since the error happened. I tried now to edit and play around in the spot I was working on when the error occurred but cannot reproduce or in any way trigger it.
Comment 9 Kevin Milburn CLA 2014-11-07 11:11:44 EST
I've recently encountered this problem in similar circumstances, with the exception that it's not during an incremental build, but it fails when using the Plugin Export Wizard.

The log generated within the export directory contains

	# 07/11/14 15:30:16 GMT
	# Eclipse Compiler for Java(TM) v20140902-0626, 3.10.0, Copyright IBM Corp 2000, 2013. All rights reserved.
	----------
	1. ERROR in C:\temp\testbug\test\src\Test.java (at line 0)
		

		^
	Internal compiler error: java.lang.IllegalArgumentException: info cannot be null at org.eclipse.jdt.internal.compiler.codegen.StackMapFrame.addStackItem(StackMapFrame.java:81)

(this was from Luna SR1, also failed with Kepler SR2 (v20140317-1741, 3.9.50))

The presence of the following code within the plugin is enough for the plugin export wizard to fail.  Eclipse does not have any issues itself with this code.

	public void testFunction() {
	    int var1 = 0;
	    int var2 = 0;
	    switch ("test") {
		case "test": 
		    var2 = ++var1 % 2;
		    break;
	    }
	}

From testing, a couple changes can be made which make the error go away:
  1.  move the definition of var1 out of the testFunction
  2.  split the incrementing of var1 out from the single statement
      i.e.  ++var1; var2 = var1 % 2;


Runtime Info:
Eclipse Luna SR1 (For RCP and RAP)
org.osgi.framework.os.name=Windows7
org.osgi.framework.processor=x86-64
java.version=1.8.0_11
org.eclipse.jdt (3.10.0.v20140925-0400) "Eclipse Java Development Tools"
org.eclipse.platform (4.4.0.v20140925-0400) "Eclipse Platform"
Comment 10 Olivier Thomann CLA 2014-11-07 12:15:31 EST
Created attachment 248506 [details]
Proposed patch

The problem was that the code generation was restarted to handle the unused local, but the catch clause of a try statement in the code generation of the switch on strings swallowed the abort method exception. Removing the catch clause fixes it. In fact, I don't think this catch was a good idea at all as it might hide potential bugs in the compiler.
Comment 11 Olivier Thomann CLA 2014-11-07 12:18:28 EST
Created attachment 248507 [details]
Proposed regression tests

Regression tests for the proposed patch. They handle the fact that optimized locals need to be set and they make the problem is reported only once. These are the changes in AbstractMethodDeclaration/Clinit/ConstructorDeclaration. When you reset the code generation, you also need to reset the problem count. Otherwise you can end up reporting all the warnings before the code generation restarts more than once.
Comment 12 Srikanth Sankaran CLA 2014-11-08 04:06:05 EST
(In reply to Olivier Thomann from comment #10)
> Created attachment 248506 [details]
> Proposed patch
> 
> The problem was that the code generation was restarted to handle the unused
> local, but the catch clause of a try statement in the code generation of the
> switch on strings swallowed the abort method exception. Removing the catch
> clause fixes it. In fact, I don't think this catch was a good idea at all as
> it might hide potential bugs in the compiler.

Sorry about that. I just looked at this part of the patch and it looks good.
I think Jay will take it forward to completion.
Comment 13 Kevin Milburn CLA 2014-11-10 05:19:01 EST
(In reply to Olivier Thomann from comment #10)

> The problem was that the code generation was restarted to handle the unused
> local ...

In case the patch doesn't already cover it, while the unused variable may have indicated an issue, the error occurs even when the variable is used.
Comment 14 Jay Arthanareeswaran CLA 2014-11-11 09:56:56 EST
This program:

class X {
    int foo() {
        int i=1;
        boolean b=false;
        b|=true;
        int k = 2;
        --k;
        k+=3;
        Integer j = 3;
        j++;
        i++;
        return i++;
    }
}

When "Preserver unused local variables" is deselected, fails to produce the "unused local variable" warnings. We have a couple of tests[1] that are looking for these warnings and fail. I suppose the tests shouldn't fail? I will investigate this.

[1] ProgrammingProblemsTest.test0046() and test0050().
Comment 15 Olivier Thomann CLA 2014-11-12 10:17:11 EST
I would say the tests are bogus. They might be a consequence of not resetting the problem count on restart when we realize that a variable is used. See the changes in AbstractMethodDeclaration/Clinit/ConstructorDeclaration.
In your example, all variables are used.
Comment 16 Jay Arthanareeswaran CLA 2014-11-13 01:06:40 EST
(In reply to Olivier Thomann from comment #15)
> I would say the tests are bogus. They might be a consequence of not
> resetting the problem count on restart when we realize that a variable is
> used. See the changes in
> AbstractMethodDeclaration/Clinit/ConstructorDeclaration.
> In your example, all variables are used.

Hmm.. Looks like I am missing something here. Doesn't that mean we are breaking the fix for bug 185682?
Comment 17 Olivier Thomann CLA 2014-11-13 10:08:10 EST
(In reply to Jayaprakash Arthanareeswaran from comment #16)
> (In reply to Olivier Thomann from comment #15)
> > I would say the tests are bogus. They might be a consequence of not
> > resetting the problem count on restart when we realize that a variable is
> > used. See the changes in
> > AbstractMethodDeclaration/Clinit/ConstructorDeclaration.
> > In your example, all variables are used.
> 
> Hmm.. Looks like I am missing something here. Doesn't that mean we are
> breaking the fix for bug 185682?
Sorry Jay, I was wrong. In your case, the return i++; makes i as being used and restart the code generation. I changed the code to flush problems already reported before the code generation is restarted.
In your case, we then lose the warning for b. This is because when the code generation is restarted the local has been marked as used.
See line 218 in org.eclipse.jdt.internal.compiler.ast.Reference.
The variable is reported as being used and to prevent that from being reported again, it is then marked as used. When the code generation restarts, it does no longer see the variable as being used.
I wonder whether this line was added to cover duplicate warnings from being issued because the problem count was not reset on restart.
It might be worth to try to comment out this line (218) and line 170 in the same class and restart all the tests.
Sorry for missing that change. The catch clause should still be removed, but in the original issue, that fix without the change in AbstractMethodDeclaration/Clinit/ConstructorDeclaration would report the same warning multiple times.
Let me know what you think. We can talk about it if needed.
Comment 18 Olivier Thomann CLA 2014-11-13 10:14:31 EST
With both lines commented out, all tests in ProgrammingProblemsTest are green.
Comment 19 Olivier Thomann CLA 2014-11-13 11:30:45 EST
Created attachment 248642 [details]
Better patch
Comment 20 Jay Arthanareeswaran CLA 2014-11-14 04:10:10 EST
Thank you very much Olivier!

Patch looks good to me. I have released in master:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=1850eabeac3bdcae6e357d374f46d85ea3488da4
Comment 21 Olivier Thomann CLA 2014-12-02 19:23:09 EST
*** Bug 453861 has been marked as a duplicate of this bug. ***
Comment 22 Jay Arthanareeswaran CLA 2014-12-10 00:28:34 EST
Verified for 4.5 M4 with build I20141209-2000
Comment 23 Stephan Herrmann CLA 2020-04-10 18:01:08 EDT
*** Bug 412777 has been marked as a duplicate of this bug. ***