Community
Participate
Working Groups
Using the following example code: public class AssertFailureTest { public static void main( String[] args ) { try { throw new Throwable( "This is a test"); } catch( Throwable ioe ) { assert false : ioe; } } } and compiling and running in eclipse, I get the following error: -------------------------- begin output ----------------------- java.lang.VerifyError: (class: AssertFailureTest, method: main signature: ([Ljava/lang/String;)V) Expecting to find integer on stack Exception in thread "main" -------------------------- end output ------------------------- Java details: java version "1.4.2_04" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode) Also, I set the options in Windows->Preferences->Compiler->Compliance and Classfiles to: Compiler compliance level: 1.4 Generated .class files compatibility: 1.4 Source compatibility: 1.4 Disallow identifiers called 'assert': Error Other than those 4 settings, my settings are the same as the defaults. (Of course, I pointed eclipse at my own installed JDK when I set the Installed JREs)
Problem comes from invalid implicit conversion for well-known types. The id for Throwable is 21, and fools the implicit conversion computation since it is confused with boolean as per lower 4 bits. Implicit computation should check for id before doing bit manipulations in AssertStatement#resolve. Fix: switch(id) { case T_void : scope.problemReporter ().illegalVoidExpression(exceptionArgument); default: id = T_Object; case T_boolean : case T_byte : case T_char : case T_short : case T_double : case T_float : case T_int : case T_long : case T_String : exceptionArgument.implicitConversion = (id << 4) + id; }
Added AssertionTest#test012
Backported with test to 2.1.x stream
*** Bug 60040 has been marked as a duplicate of this bug. ***
Verified in 200405180816