Summary: | [1.5][compiler] compiler allows use of void type as method arguments | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Tom Hofmann <eclipse> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | kwhittingham, max.gilead |
Version: | 3.1 | ||
Target Milestone: | 3.1 M5 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Tom Hofmann
2004-12-28 14:53:43 EST
Could you please provide full test case and compiler options used? Thanks. 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)"
Definitely not good. Likely a consequence of changes near autoboxing support. It appears we are incorrectly boxing 'void' into 'Object' (and of course it doesn't verify properly since impossible conversion). Removed erroneous rules for 'void' and 'Void'. Fixed Added regression test: AutoboxingTest#test072 *** Bug 83478 has been marked as a duplicate of this bug. *** Verified in I20050214 |