Bug 57743 - [Compiler] invalid byte code produced when catching Throwable
Summary: [Compiler] invalid byte code produced when catching Throwable
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 60040 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-07 11:00 EDT by Steve Loker CLA
Modified: 2004-05-18 13:51 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Loker CLA 2004-04-07 11:00:33 EDT
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)
Comment 1 Philipe Mulet CLA 2004-04-07 18:36:00 EDT
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;
				}
Comment 2 Philipe Mulet CLA 2004-04-07 18:52:35 EDT
Added AssertionTest#test012
Comment 3 Philipe Mulet CLA 2004-04-08 07:54:12 EDT
Backported with test to 2.1.x stream
Comment 4 Olivier Thomann CLA 2004-04-26 21:33:36 EDT
*** Bug 60040 has been marked as a duplicate of this bug. ***
Comment 5 Olivier Thomann CLA 2004-05-18 13:51:51 EDT
Verified in 200405180816