Error and runtime exception should be propagated instead of being wrapped in isSubstitutable
Mandy Chung
mandy.chung at oracle.com
Fri Feb 1 23:10:22 UTC 2019
My mistake. Fixed.
http://hg.openjdk.java.net/valhalla/valhalla/rev/6ece319093a2
Mandy
On 1/31/19 3:28 AM, Remi Forax wrote:
> Hi all,
> i was testing this code
>
> public class SubstituableTest {
> static value class Link {
> private final int value;
> private final Object next;
>
> public Link(int value, Object next) {
> this.value = value;
> this.next = next;
> }
>
> static Object times(int count) {
> return IntStream.range(0, count).boxed().reduce(null, (acc, index) -> new Link(index, acc), (l1, l2) -> { throw null; });
> }
> }
>
> public static void main(String[] args) {
> var l = Link.times(1_000);
>
> //System.out.println(l == l);
> System.out.println(ValueBootstrapMethods.isSubstitutable(l, l));
> }
> }
>
> and currently, it recreates a linked list of errors because errors are wrapped instead of being propagated
>
> I believe the bug is in this code:
> try {
> Class<?> type = a.getClass().isValue() ? a.getClass().asValueType() : a.getClass();
> return (boolean) substitutableInvoker(type).invoke(a, b);
> } catch (Throwable e) {
> if (VERBOSE) e.printStackTrace();
> throw new InternalError(e);
> }
>
> it should be:
> try {
> Class<?> type = a.getClass().isValue() ? a.getClass().asValueType() : a.getClass();
> return (boolean) substitutableInvoker(type).invoke(a, b);
> } catch(Error | Runtime e) {
> throw e;
> } catch (Throwable e) {
> if (VERBOSE) e.printStackTrace();
> throw new InternalError(e);
> }
>
> regards,
> Rémi
>
More information about the valhalla-dev
mailing list