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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b12
    • CPU:
      generic, sparc
    • OS:
      generic, solaris
    • Verification:
      Not verified

      Backports

        Description

        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]

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: