-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
rc
-
generic
-
generic
-
Verified
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.
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.
- relates to
-
JDK-4513384 AssertionError whose "detail message" is Throwable should set cause
-
- Closed
-