Bug 81971 - [1.5][compiler] compiler allows use of void type as method arguments
Summary: [1.5][compiler] compiler allows use of void type as method arguments
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 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 83478 85870 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-12-28 14:53 EST by Tom Hofmann CLA
Modified: 2005-02-18 16:11 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2004-12-28 14:53:43 EST
I20041216 (M4)

The following snippet compiled, but failed when run with a VerifyError ("failed
to pop argument off empty stack" or so):

catch (Exception e)
{
	System.out.println(e.printStackTrace());
}
Comment 1 Olivier Thomann CLA 2004-12-30 15:47:00 EST
Could you please provide full test case and compiler options used?
Thanks.
Comment 2 torkjel hongve CLA 2005-01-01 18:03:34 EST
I've bumped into the same thing (3.1M4, Linux). Test case: 

public class Test {
    public static void main(String[] args) {
        doFoo(getVoid());
    }

    private static void doFoo(Object o) { }

    private static void getVoid() { }
}


Eclipse will compile it, but gives the following error when running it: 

Exception in thread "main" java.lang.VerifyError: (class: Test, method: main 
signature: ([Ljava/lang/String;)V) Unable to pop operand off an empty stack



Trying the same thing with javac:

> /opt/jdk1.5.0_01/bin/javac Test.java
Test.java:3: 'void' type not allowed here
        doFoo(getVoid());
                     ^
1 error

Eclipse has Compiler compliance level = 5.0, but other than that only default 
compiler options are used for both eclipse and javac.

With Compiler compliance level = 1.4 eclipse gives the expected error message: 
"The method doFoo(Object) in the type Test is not applicable for the arguments 
(void)"
Comment 3 Philipe Mulet CLA 2005-01-02 07:06:42 EST
Definitely not good. Likely a consequence of changes near autoboxing support.
Comment 4 Philipe Mulet CLA 2005-01-03 15:48:53 EST
It appears we are incorrectly boxing 'void' into 'Object' (and of course it
doesn't verify properly since impossible conversion).
Comment 5 Philipe Mulet CLA 2005-01-04 05:03:58 EST
Removed erroneous rules for 'void' and 'Void'.
Fixed

Added regression test: AutoboxingTest#test072
Comment 6 Philipe Mulet CLA 2005-01-23 06:50:45 EST
*** Bug 83478 has been marked as a duplicate of this bug. ***
Comment 7 Jerome Lanneluc CLA 2005-02-15 06:04:45 EST
Verified in I20050214
Comment 8 Philipe Mulet CLA 2005-02-18 16:11:35 EST
*** Bug 85870 has been marked as a duplicate of this bug. ***