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

Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type

    Details

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_20-ea"
        Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b23)
        Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)

        A DESCRIPTION OF THE PROBLEM :
        Let there be an non-static inner class with a constructor which has a generic parameter type. Invoking toString() on a j.l.r.Parameter instance representing this parameter fails with an ArrayIndexOutOfBoundsException. As of 1.8.0_20-ea-b23, also Parameter#getAnnotatedType() is effected.

        I believe this is related to issue https://bugs.openjdk.java.net/browse/JDK-5087240. I'm creating this separate issue as also getAnnotatedType() is concerned and now not only user code invoking Constructor#getGenericParameterTypes() is affected, but JDK code itself which invokes this method.

        Note that getAnnotatedType() used to work as of 1.8.0_11 (the implementation of Executable#getAnnotatedParameterTypes() has changed since then and now also uses getGenericParameterTypes()).


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class ParameterBug {

        public static void main(String[] args) throws Exception {
        Constructor<MyEntity> constructor = MyEntity.class.getConstructor( ReflectionBug.class, Set.class );
        for ( Parameter parameter : constructor.getParameters() ) {
        // the following line raises an AIOOBE for the second parameter
        System.out.println( parameter.toString() );

        // this fails as well
        System.out.println( parameter.getAnnotatedType() );
        }
        }

        public class MyEntity {
        public MyEntity(Set<?> names) {
        }
        }
        }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  emc Eric Mccorkle
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: