United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6302175 Second argument of assert statement not always converted to a String
JDK-6302175 : Second argument of assert statement not always converted to a String

Details
Type:
Bug
Submit Date:
2005-07-26
Status:
Closed
Updated Date:
2014-02-26
Project Name:
JDK
Resolved Date:
2011-07-21
Component:
specification
OS:
generic
Sub-Component:
language
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
7 (rc)

Related Reports
Relates:

Sub Tasks

Description
From: ###@###.###

In JSR-41 it stated that expression2 was used to do "new
AssertionError(expression2)". This meant that the constructors of
AssertionError defined what happened based on the different types of
expression2. For the most part it just converts to a String which becomes
the detail message, but additionally the AssertionError(Object) constructor,
if passed a Throwable would set its own cause to be that Throwable. This was
considered a good thing as per bug 4513384.

In JLS 3e the conversion of expression2 to a String is made explicit. This
means that the only AssertionError constructor ever invoked should be the
one that takes an Object, and that it would always receive a String
argument. Hence there would never be a Throwable passed to the constructor
and so it would never become the cause of the AssertionError.

In practice it seems that javac in JDK 1.5 does not convert expression2 to a
string as specified but instead continues to pass it to the AssertionError
constructor. Hence we still get the behaviour from 1.4 defined by JSR-41,
but that behaviour is now in conflict with the JLS.

                                    

Comments
EVALUATION

I plan to remove the string conversion from JLS 14.10, so that it agrees with 4513384 and JSR41 and javac.
                                     
2006-12-15



Hardware and Software, Engineered to Work Together