Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7009361

JSR 292 Invalid value on stack on solaris-sparc with -Xcomp

XMLWordPrintable

    • b12
    • generic, sparc
    • generic, solaris
    • Not verified

        The following code prints invalid value in assertEquals() on solaris-sparc with -Xcomp option:

        public class T {
            static void assertEquals(Object exp, Object act) {
                System.out.println(exp + " vs " + act);
            }

            static MethodHandle asList;

            static void test() {
                MethodHandle makeEmptyList = MethodHandles.constant(List.class, Arrays.asList());
                MethodHandle asList = lookup().findStatic(Arrays.class, "asList", methodType(List.class, Object[].class));
                T.asList = asList;

                MethodHandle collectingTypeHandler = lookup()
                        .findStatic(lookup().lookupClass(), "collectingTypeHandler",
                                    methodType(MethodHandle.class, MethodHandle.class, MethodType.class));

                MethodHandle makeAnyList = makeEmptyList.withTypeHandler(collectingTypeHandler);

                assertEquals("TEST>[two, too]<TEST", makeAnyList.invokeGeneric("two", "too").toString());
            }

            static MethodHandle collectingTypeHandler(MethodHandle base, MethodType newType) {
                return asList.asCollector(Object[].class, newType.parameterCount()).asType(newType);
            }
        }

        With -Xcomp, it prints:

        (String,String)Object vs [two, too]

        With -Xint it prints:

        TEST>[two, too]<TEST vs [two, too]

              never Tom Rodriguez
              kshiroko Kirill Shirokov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: