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

javac does a naive implementation of some incorporation steps

XMLWordPrintable

    • b82

        This code:

        class ClassType<U> {
            U fu;
            ClassType() {}
            ClassType(ClassType<U> other) {
                this.fu = other.fu;
            }
            ClassType(U fu) {
                this.fu = fu;
            }
            @Override
            public String toString() {
                return "ClassType: " + String.valueOf(fu);
            }
        }

        public class Hang {
            static <U> ClassType<U> m(ClassType<U> src) {
                return new ClassType<U>(src);
            }

            public static void main(String argv[]) {
                ClassType<Number> c = m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>(m(new ClassType<>())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
                String result = c.toString();
                if (!result.equals("ClassType: null")) {
                    throw new Error();
                }
            }
        }

        Takes forever to be compiled. Main reason naive implementation of some incorporation steps. A huge speed-up can be obtained if some heavy operations like type substitution are not executed for those cases when they imply a no-op

              vromero Vicente Arturo Romero Zaldivar
              vromero Vicente Arturo Romero Zaldivar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: